blob: efd340a510a9576524cda91bcc31198cc4bed5ba [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080022#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070027#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080028#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080029#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070031#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020033#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080066#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070067#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050068#include <linux/mount.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#include <asm/uaccess.h>
71#include <asm/processor.h>
72
Andi Kleen29cbc782006-09-30 01:47:55 +020073#ifdef CONFIG_X86
74#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010075#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010076#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020077#endif
David Howellsd550bbd2012-03-28 18:30:03 +010078#ifdef CONFIG_SPARC
79#include <asm/setup.h>
80#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080081#ifdef CONFIG_BSD_PROCESS_ACCT
82#include <linux/acct.h>
83#endif
Dave Young4f0e0562010-03-10 15:24:09 -080084#ifdef CONFIG_RT_MUTEXES
85#include <linux/rtmutex.h>
86#endif
Dave Young2edf5e42010-03-10 15:24:10 -080087#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88#include <linux/lockdep.h>
89#endif
Dave Young15485a42010-03-10 15:24:07 -080090#ifdef CONFIG_CHR_DEV_SG
91#include <scsi/sg.h>
92#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020093
Don Zickus58687ac2010-05-07 17:11:44 -040094#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050095#include <linux/nmi.h>
96#endif
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#if defined(CONFIG_SYSCTL)
99
100/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300111extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400117#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118static int sixty = 60;
119#endif
120
Aaron Tomlin270750db2014-01-20 17:34:13 +0000121static int __maybe_unused neg_one = -1;
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700126static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700129static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700130#ifdef CONFIG_PRINTK
131static int ten_thousand = 10000;
132#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300133#ifdef CONFIG_PERF_EVENTS
134static int six_hundred_forty_kb = 640 * 1024;
135#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
143
144static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700145static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Liu Hua80df2842014-04-07 15:38:57 -0700147/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
148#ifdef CONFIG_DETECT_HUNG_TASK
149static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
150#endif
151
Dave Youngd14f1722010-02-25 20:28:57 -0500152#ifdef CONFIG_INOTIFY_USER
153#include <linux/inotify.h>
154#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700155#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#endif
157
158#ifdef __hppa__
159extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530160#endif
161
162#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163extern int unaligned_enabled;
164#endif
165
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800167extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800168#endif
169
Vineet Guptab6fca722013-01-09 20:06:28 +0530170#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
171extern int no_unaligned_warning;
172#endif
173
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700174#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700175
176#define SYSCTL_WRITES_LEGACY -1
177#define SYSCTL_WRITES_WARN 0
178#define SYSCTL_WRITES_STRICT 1
179
Kees Cook41662f52016-01-20 15:00:45 -0800180static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700181
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700182static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700183 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700184static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800185 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700186#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700187
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700188#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700189static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700190 void __user *buffer, size_t *lenp, loff_t *ppos);
191#endif
192
Kees Cook54b50192012-07-30 14:39:18 -0700193static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
194 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700195#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700196static int proc_dostring_coredump(struct ctl_table *table, int write,
197 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700198#endif
Kees Cook54b50192012-07-30 14:39:18 -0700199
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700200#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800201/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100202static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700203
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700204static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700205 void __user *buffer, size_t *lenp,
206 loff_t *ppos)
207{
208 int error;
209
210 error = proc_dointvec(table, write, buffer, lenp, ppos);
211 if (error)
212 return error;
213
214 if (write)
215 sysrq_toggle_support(__sysrq_enabled);
216
217 return 0;
218}
219
220#endif
221
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700222static struct ctl_table kern_table[];
223static struct ctl_table vm_table[];
224static struct ctl_table fs_table[];
225static struct ctl_table debug_table[];
226static struct ctl_table dev_table[];
227extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800228#ifdef CONFIG_EPOLL
229extern struct ctl_table epoll_table[];
230#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
233int sysctl_legacy_va_layout;
234#endif
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236/* The default sysctl tables: */
237
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800238static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .procname = "kernel",
241 .mode = 0555,
242 .child = kern_table,
243 },
244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .procname = "vm",
246 .mode = 0555,
247 .child = vm_table,
248 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 .procname = "fs",
251 .mode = 0555,
252 .child = fs_table,
253 },
254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 .procname = "debug",
256 .mode = 0555,
257 .child = debug_table,
258 },
259 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 .procname = "dev",
261 .mode = 0555,
262 .child = dev_table,
263 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700264 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265};
266
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100268static int min_sched_granularity_ns = 100000; /* 100 usecs */
269static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
270static int min_wakeup_granularity_ns; /* 0 usecs */
271static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200272#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100273static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
274static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200275#endif /* CONFIG_SMP */
276#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200277
Mel Gorman5e771902010-05-24 14:32:31 -0700278#ifdef CONFIG_COMPACTION
279static int min_extfrag_threshold;
280static int max_extfrag_threshold = 1000;
281#endif
282
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700283static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200284 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200285 .procname = "sched_child_runs_first",
286 .data = &sysctl_sched_child_runs_first,
287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800289 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200290 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200291#ifdef CONFIG_SCHED_DEBUG
292 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100293 .procname = "sched_min_granularity_ns",
294 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200295 .maxlen = sizeof(unsigned int),
296 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800297 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100298 .extra1 = &min_sched_granularity_ns,
299 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200300 },
301 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200302 .procname = "sched_latency_ns",
303 .data = &sysctl_sched_latency,
304 .maxlen = sizeof(unsigned int),
305 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800306 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200307 .extra1 = &min_sched_granularity_ns,
308 .extra2 = &max_sched_granularity_ns,
309 },
310 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200311 .procname = "sched_wakeup_granularity_ns",
312 .data = &sysctl_sched_wakeup_granularity,
313 .maxlen = sizeof(unsigned int),
314 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800315 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200316 .extra1 = &min_wakeup_granularity_ns,
317 .extra2 = &max_wakeup_granularity_ns,
318 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200319#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200320 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100321 .procname = "sched_tunable_scaling",
322 .data = &sysctl_sched_tunable_scaling,
323 .maxlen = sizeof(enum sched_tunable_scaling),
324 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800325 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100326 .extra1 = &min_sched_tunable_scaling,
327 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200328 },
329 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900330 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200331 .data = &sysctl_sched_migration_cost,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800334 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200335 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100336 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100337 .procname = "sched_nr_migrate",
338 .data = &sysctl_sched_nr_migrate,
339 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800341 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100342 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530343 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900344 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200345 .data = &sysctl_sched_time_avg,
346 .maxlen = sizeof(unsigned int),
347 .mode = 0644,
Ethan Zhaofe0034a2017-09-04 13:59:34 +0800348 .proc_handler = proc_dointvec_minmax,
349 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200350 },
351 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900352 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800353 .data = &sysctl_sched_shares_window,
354 .maxlen = sizeof(unsigned int),
355 .mode = 0644,
356 .proc_handler = proc_dointvec,
357 },
Mel Gormancb251762016-02-05 09:08:36 +0000358#ifdef CONFIG_SCHEDSTATS
359 {
360 .procname = "sched_schedstats",
361 .data = NULL,
362 .maxlen = sizeof(unsigned int),
363 .mode = 0644,
364 .proc_handler = sysctl_schedstats,
365 .extra1 = &zero,
366 .extra2 = &one,
367 },
368#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200369#endif /* CONFIG_SMP */
370#ifdef CONFIG_NUMA_BALANCING
371 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200372 .procname = "numa_balancing_scan_delay_ms",
373 .data = &sysctl_numa_balancing_scan_delay,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
378 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200379 .procname = "numa_balancing_scan_period_min_ms",
380 .data = &sysctl_numa_balancing_scan_period_min,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec,
384 },
385 {
386 .procname = "numa_balancing_scan_period_max_ms",
387 .data = &sysctl_numa_balancing_scan_period_max,
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
390 .proc_handler = proc_dointvec,
391 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200392 {
393 .procname = "numa_balancing_scan_size_mb",
394 .data = &sysctl_numa_balancing_scan_size,
395 .maxlen = sizeof(unsigned int),
396 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400397 .proc_handler = proc_dointvec_minmax,
398 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200399 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100400 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800401 .procname = "numa_balancing",
402 .data = NULL, /* filled in by handler */
403 .maxlen = sizeof(unsigned int),
404 .mode = 0644,
405 .proc_handler = sysctl_numa_balancing,
406 .extra1 = &zero,
407 .extra2 = &one,
408 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200409#endif /* CONFIG_NUMA_BALANCING */
410#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200411 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100412 .procname = "sched_rt_period_us",
413 .data = &sysctl_sched_rt_period,
414 .maxlen = sizeof(unsigned int),
415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800416 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100417 },
418 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100419 .procname = "sched_rt_runtime_us",
420 .data = &sysctl_sched_rt_runtime,
421 .maxlen = sizeof(int),
422 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800423 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100424 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600425 {
426 .procname = "sched_rr_timeslice_ms",
427 .data = &sched_rr_timeslice,
428 .maxlen = sizeof(int),
429 .mode = 0644,
430 .proc_handler = sched_rr_handler,
431 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100432#ifdef CONFIG_SCHED_AUTOGROUP
433 {
434 .procname = "sched_autogroup_enabled",
435 .data = &sysctl_sched_autogroup_enabled,
436 .maxlen = sizeof(unsigned int),
437 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800438 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100439 .extra1 = &zero,
440 .extra2 = &one,
441 },
442#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700443#ifdef CONFIG_CFS_BANDWIDTH
444 {
445 .procname = "sched_cfs_bandwidth_slice_us",
446 .data = &sysctl_sched_cfs_bandwidth_slice,
447 .maxlen = sizeof(unsigned int),
448 .mode = 0644,
449 .proc_handler = proc_dointvec_minmax,
450 .extra1 = &one,
451 },
452#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700453#ifdef CONFIG_PROVE_LOCKING
454 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700455 .procname = "prove_locking",
456 .data = &prove_locking,
457 .maxlen = sizeof(int),
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700460 },
461#endif
462#ifdef CONFIG_LOCK_STAT
463 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700464 .procname = "lock_stat",
465 .data = &lock_stat,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700469 },
470#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "panic",
473 .data = &panic_timeout,
474 .maxlen = sizeof(int),
475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800476 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
Alex Kelly046d6622012-10-04 17:15:23 -0700478#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "core_uses_pid",
481 .data = &core_uses_pid,
482 .maxlen = sizeof(int),
483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800484 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 },
486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .procname = "core_pattern",
488 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700489 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700491 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
Neil Hormana2939802009-09-23 15:56:56 -0700493 {
Neil Hormana2939802009-09-23 15:56:56 -0700494 .procname = "core_pipe_limit",
495 .data = &core_pipe_limit,
496 .maxlen = sizeof(unsigned int),
497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700499 },
Alex Kelly046d6622012-10-04 17:15:23 -0700500#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800501#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700504 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800506 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700508 {
509 .procname = "sysctl_writes_strict",
510 .data = &sysctl_writes_strict,
511 .maxlen = sizeof(int),
512 .mode = 0644,
513 .proc_handler = proc_dointvec_minmax,
514 .extra1 = &neg_one,
515 .extra2 = &one,
516 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800517#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100518#ifdef CONFIG_LATENCYTOP
519 {
520 .procname = "latencytop",
521 .data = &latencytop_enabled,
522 .maxlen = sizeof(int),
523 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000524 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100525 },
526#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527#ifdef CONFIG_BLK_DEV_INITRD
528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 .procname = "real-root-dev",
530 .data = &real_root_dev,
531 .maxlen = sizeof(int),
532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800533 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 },
535#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700536 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700537 .procname = "print-fatal-signals",
538 .data = &print_fatal_signals,
539 .maxlen = sizeof(int),
540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800541 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700542 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700543#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .procname = "reboot-cmd",
546 .data = reboot_command,
547 .maxlen = 256,
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 },
551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .procname = "stop-a",
553 .data = &stop_a_enabled,
554 .maxlen = sizeof (int),
555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 },
558 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 .procname = "scons-poweroff",
560 .data = &scons_pwroff,
561 .maxlen = sizeof (int),
562 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800563 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 },
565#endif
David S. Miller08714202008-11-16 23:49:24 -0800566#ifdef CONFIG_SPARC64
567 {
David S. Miller08714202008-11-16 23:49:24 -0800568 .procname = "tsb-ratio",
569 .data = &sysctl_tsb_ratio,
570 .maxlen = sizeof (int),
571 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800572 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800573 },
574#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575#ifdef __hppa__
576 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .procname = "soft-power",
578 .data = &pwrsw_enabled,
579 .maxlen = sizeof (int),
580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530583#endif
584#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 .procname = "unaligned-trap",
587 .data = &unaligned_enabled,
588 .maxlen = sizeof (int),
589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800590 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 },
592#endif
593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "ctrl-alt-del",
595 .data = &C_A_D,
596 .maxlen = sizeof(int),
597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800598 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400600#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200601 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200602 .procname = "ftrace_enabled",
603 .data = &ftrace_enabled,
604 .maxlen = sizeof(int),
605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800606 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200607 },
608#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500609#ifdef CONFIG_STACK_TRACER
610 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500611 .procname = "stack_tracer_enabled",
612 .data = &stack_tracer_enabled,
613 .maxlen = sizeof(int),
614 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800615 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500616 },
617#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400618#ifdef CONFIG_TRACING
619 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100620 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400621 .data = &ftrace_dump_on_oops,
622 .maxlen = sizeof(int),
623 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800624 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400625 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400626 {
627 .procname = "traceoff_on_warning",
628 .data = &__disable_trace_on_warning,
629 .maxlen = sizeof(__disable_trace_on_warning),
630 .mode = 0644,
631 .proc_handler = proc_dointvec,
632 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500633 {
634 .procname = "tracepoint_printk",
635 .data = &tracepoint_printk,
636 .maxlen = sizeof(tracepoint_printk),
637 .mode = 0644,
638 .proc_handler = proc_dointvec,
639 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400640#endif
Dave Young2965faa2015-09-09 15:38:55 -0700641#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800642 {
643 .procname = "kexec_load_disabled",
644 .data = &kexec_load_disabled,
645 .maxlen = sizeof(int),
646 .mode = 0644,
647 /* only handle a transition from default "0" to "1" */
648 .proc_handler = proc_dointvec_minmax,
649 .extra1 = &one,
650 .extra2 = &one,
651 },
652#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200653#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 .procname = "modprobe",
656 .data = &modprobe_path,
657 .maxlen = KMOD_PATH_LEN,
658 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 },
Kees Cook3d433212009-04-02 15:49:29 -0700661 {
Kees Cook3d433212009-04-02 15:49:29 -0700662 .procname = "modules_disabled",
663 .data = &modules_disabled,
664 .maxlen = sizeof(int),
665 .mode = 0644,
666 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800667 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700668 .extra1 = &one,
669 .extra2 = &one,
670 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700672#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100675 .data = &uevent_helper,
676 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800678 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 },
Michael Marineau86d56132014-04-10 14:09:31 -0700680#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681#ifdef CONFIG_CHR_DEV_SG
682 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 .procname = "sg-big-buff",
684 .data = &sg_big_buff,
685 .maxlen = sizeof (int),
686 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800687 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 },
689#endif
690#ifdef CONFIG_BSD_PROCESS_ACCT
691 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 .procname = "acct",
693 .data = &acct_parm,
694 .maxlen = 3*sizeof(int),
695 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800696 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 },
698#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699#ifdef CONFIG_MAGIC_SYSRQ
700 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800702 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .maxlen = sizeof (int),
704 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700705 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 },
707#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700708#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700711 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .maxlen = sizeof (int),
713 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700716#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700719 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .maxlen = sizeof(int),
721 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700722 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 },
724 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 .procname = "random",
726 .mode = 0555,
727 .child = random_table,
728 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 {
Eric Paris17f60a72011-04-01 17:07:50 -0400730 .procname = "usermodehelper",
731 .mode = 0555,
732 .child = usermodehelper_table,
733 },
734 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .procname = "overflowuid",
736 .data = &overflowuid,
737 .maxlen = sizeof(int),
738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .extra1 = &minolduid,
741 .extra2 = &maxolduid,
742 },
743 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .procname = "overflowgid",
745 .data = &overflowgid,
746 .maxlen = sizeof(int),
747 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800748 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .extra1 = &minolduid,
750 .extra2 = &maxolduid,
751 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800752#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753#ifdef CONFIG_MATHEMU
754 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 .procname = "ieee_emulation_warnings",
756 .data = &sysctl_ieee_emulation_warnings,
757 .maxlen = sizeof(int),
758 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800759 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 },
761#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200764 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 .maxlen = sizeof(int),
766 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800767 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 },
769#endif
770 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 .procname = "pid_max",
772 .data = &pid_max,
773 .maxlen = sizeof (int),
774 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800775 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 .extra1 = &pid_max_min,
777 .extra2 = &pid_max_max,
778 },
779 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 .procname = "panic_on_oops",
781 .data = &panic_on_oops,
782 .maxlen = sizeof(int),
783 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800784 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800786#if defined CONFIG_PRINTK
787 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800788 .procname = "printk",
789 .data = &console_loglevel,
790 .maxlen = 4*sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800793 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700796 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 .maxlen = sizeof(int),
798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 },
801 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700803 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 .maxlen = sizeof(int),
805 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800806 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 },
Dave Youngaf913222009-09-22 16:43:33 -0700808 {
Dave Youngaf913222009-09-22 16:43:33 -0700809 .procname = "printk_delay",
810 .data = &printk_delay_msec,
811 .maxlen = sizeof(int),
812 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800813 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700814 .extra1 = &zero,
815 .extra2 = &ten_thousand,
816 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700818 .procname = "printk_devkmsg",
819 .data = devkmsg_log_str,
820 .maxlen = DEVKMSG_STR_MAX_SIZE,
821 .mode = 0644,
822 .proc_handler = devkmsg_sysctl_set_loglvl,
823 },
824 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800825 .procname = "dmesg_restrict",
826 .data = &dmesg_restrict,
827 .maxlen = sizeof(int),
828 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700829 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800830 .extra1 = &zero,
831 .extra2 = &one,
832 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800833 {
834 .procname = "kptr_restrict",
835 .data = &kptr_restrict,
836 .maxlen = sizeof(int),
837 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700838 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800839 .extra1 = &zero,
840 .extra2 = &two,
841 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800842#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800843 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 .procname = "ngroups_max",
845 .data = &ngroups_max,
846 .maxlen = sizeof (int),
847 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800848 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 },
Dan Ballard73efc032011-10-31 17:11:20 -0700850 {
851 .procname = "cap_last_cap",
852 .data = (void *)&cap_last_cap,
853 .maxlen = sizeof(int),
854 .mode = 0444,
855 .proc_handler = proc_dointvec,
856 },
Don Zickus58687ac2010-05-07 17:11:44 -0400857#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500858 {
Don Zickus58687ac2010-05-07 17:11:44 -0400859 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200860 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500861 .maxlen = sizeof (int),
862 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700863 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700864 .extra1 = &zero,
865 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400866 },
867 {
868 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700869 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400870 .maxlen = sizeof(int),
871 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700872 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800873 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400874 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500875 },
Don Zickus2508ce12010-05-07 17:11:46 -0400876 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700877 .procname = "nmi_watchdog",
878 .data = &nmi_watchdog_enabled,
879 .maxlen = sizeof (int),
880 .mode = 0644,
881 .proc_handler = proc_nmi_watchdog,
882 .extra1 = &zero,
883#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
884 .extra2 = &one,
885#else
886 .extra2 = &zero,
887#endif
888 },
889 {
890 .procname = "soft_watchdog",
891 .data = &soft_watchdog_enabled,
892 .maxlen = sizeof (int),
893 .mode = 0644,
894 .proc_handler = proc_soft_watchdog,
895 .extra1 = &zero,
896 .extra2 = &one,
897 },
898 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700899 .procname = "watchdog_cpumask",
900 .data = &watchdog_cpumask_bits,
901 .maxlen = NR_CPUS,
902 .mode = 0644,
903 .proc_handler = proc_watchdog_cpumask,
904 },
905 {
Don Zickus2508ce12010-05-07 17:11:46 -0400906 .procname = "softlockup_panic",
907 .data = &softlockup_panic,
908 .maxlen = sizeof(int),
909 .mode = 0644,
910 .proc_handler = proc_dointvec_minmax,
911 .extra1 = &zero,
912 .extra2 = &one,
913 },
Don Zickusac1f5912015-11-05 18:44:44 -0800914#ifdef CONFIG_HARDLOCKUP_DETECTOR
915 {
916 .procname = "hardlockup_panic",
917 .data = &hardlockup_panic,
918 .maxlen = sizeof(int),
919 .mode = 0644,
920 .proc_handler = proc_dointvec_minmax,
921 .extra1 = &zero,
922 .extra2 = &one,
923 },
924#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700925#ifdef CONFIG_SMP
926 {
927 .procname = "softlockup_all_cpu_backtrace",
928 .data = &sysctl_softlockup_all_cpu_backtrace,
929 .maxlen = sizeof(int),
930 .mode = 0644,
931 .proc_handler = proc_dointvec_minmax,
932 .extra1 = &zero,
933 .extra2 = &one,
934 },
Jiri Kosina55537872015-11-05 18:44:41 -0800935 {
936 .procname = "hardlockup_all_cpu_backtrace",
937 .data = &sysctl_hardlockup_all_cpu_backtrace,
938 .maxlen = sizeof(int),
939 .mode = 0644,
940 .proc_handler = proc_dointvec_minmax,
941 .extra1 = &zero,
942 .extra2 = &one,
943 },
Aaron Tomlined235872014-06-23 13:22:05 -0700944#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500945#endif
946#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
947 {
948 .procname = "unknown_nmi_panic",
949 .data = &unknown_nmi_panic,
950 .maxlen = sizeof (int),
951 .mode = 0644,
952 .proc_handler = proc_dointvec,
953 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500954#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955#if defined(CONFIG_X86)
956 {
Don Zickus8da5add2006-09-26 10:52:27 +0200957 .procname = "panic_on_unrecovered_nmi",
958 .data = &panic_on_unrecovered_nmi,
959 .maxlen = sizeof(int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200962 },
963 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700964 .procname = "panic_on_io_nmi",
965 .data = &panic_on_io_nmi,
966 .maxlen = sizeof(int),
967 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800968 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700969 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900970#ifdef CONFIG_DEBUG_STACKOVERFLOW
971 {
972 .procname = "panic_on_stackoverflow",
973 .data = &sysctl_panic_on_stackoverflow,
974 .maxlen = sizeof(int),
975 .mode = 0644,
976 .proc_handler = proc_dointvec,
977 },
978#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700979 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 .procname = "bootloader_type",
981 .data = &bootloader_type,
982 .maxlen = sizeof (int),
983 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100986 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700987 .procname = "bootloader_version",
988 .data = &bootloader_version,
989 .maxlen = sizeof (int),
990 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800991 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700992 },
993 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100994 .procname = "kstack_depth_to_print",
995 .data = &kstack_depth_to_print,
996 .maxlen = sizeof(int),
997 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800998 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100999 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001000 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001001 .procname = "io_delay_type",
1002 .data = &io_delay_type,
1003 .maxlen = sizeof(int),
1004 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001005 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001006 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001008#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 .procname = "randomize_va_space",
1011 .data = &randomize_va_space,
1012 .maxlen = sizeof(int),
1013 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001014 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001016#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001017#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001018 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001019 .procname = "spin_retry",
1020 .data = &spin_retry,
1021 .maxlen = sizeof (int),
1022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001024 },
1025#endif
Len Brown673d5b42007-07-28 03:33:16 -04001026#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001027 {
Pavel Machekc255d842006-02-20 18:27:58 -08001028 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001029 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001030 .maxlen = sizeof (unsigned long),
1031 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001032 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001033 },
1034#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301035#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001036 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001037 .procname = "ignore-unaligned-usertrap",
1038 .data = &no_unaligned_warning,
1039 .maxlen = sizeof (int),
1040 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001041 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001042 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301043#endif
1044#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001045 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001046 .procname = "unaligned-dump-stack",
1047 .data = &unaligned_dump_stack,
1048 .maxlen = sizeof (int),
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001051 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001052#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001053#ifdef CONFIG_DETECT_HUNG_TASK
1054 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001055 .procname = "hung_task_panic",
1056 .data = &sysctl_hung_task_panic,
1057 .maxlen = sizeof(int),
1058 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001059 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001060 .extra1 = &zero,
1061 .extra2 = &one,
1062 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001063 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001064 .procname = "hung_task_check_count",
1065 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001066 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001067 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001068 .proc_handler = proc_dointvec_minmax,
1069 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001070 },
1071 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001072 .procname = "hung_task_timeout_secs",
1073 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001074 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001077 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001078 },
1079 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001080 .procname = "hung_task_warnings",
1081 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001082 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001083 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001084 .proc_handler = proc_dointvec_minmax,
1085 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001086 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001087#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001088#ifdef CONFIG_RT_MUTEXES
1089 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001090 .procname = "max_lock_depth",
1091 .data = &max_lock_depth,
1092 .maxlen = sizeof(int),
1093 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001094 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001095 },
1096#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001097 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001098 .procname = "poweroff_cmd",
1099 .data = &poweroff_cmd,
1100 .maxlen = POWEROFF_CMD_PATH_LEN,
1101 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001102 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001103 },
David Howells0b77f5b2008-04-29 01:01:32 -07001104#ifdef CONFIG_KEYS
1105 {
David Howells0b77f5b2008-04-29 01:01:32 -07001106 .procname = "keys",
1107 .mode = 0555,
1108 .child = key_sysctls,
1109 },
1110#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001111#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001112 /*
1113 * User-space scripts rely on the existence of this file
1114 * as a feature check for perf_events being enabled.
1115 *
1116 * So it's an ABI, do not remove!
1117 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001118 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001119 .procname = "perf_event_paranoid",
1120 .data = &sysctl_perf_event_paranoid,
1121 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001124 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001125 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001126 .procname = "perf_event_mlock_kb",
1127 .data = &sysctl_perf_event_mlock,
1128 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001129 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001130 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001131 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001132 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001133 .procname = "perf_event_max_sample_rate",
1134 .data = &sysctl_perf_event_sample_rate,
1135 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001136 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001137 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001138 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001139 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001140 {
1141 .procname = "perf_cpu_time_max_percent",
1142 .data = &sysctl_perf_cpu_time_max_percent,
1143 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1144 .mode = 0644,
1145 .proc_handler = perf_cpu_time_max_percent_handler,
1146 .extra1 = &zero,
1147 .extra2 = &one_hundred,
1148 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001149 {
1150 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001151 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001152 .maxlen = sizeof(sysctl_perf_event_max_stack),
1153 .mode = 0644,
1154 .proc_handler = perf_event_max_stack_handler,
1155 .extra1 = &zero,
1156 .extra2 = &six_hundred_forty_kb,
1157 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001158 {
1159 .procname = "perf_event_max_contexts_per_stack",
1160 .data = &sysctl_perf_event_max_contexts_per_stack,
1161 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1162 .mode = 0644,
1163 .proc_handler = perf_event_max_stack_handler,
1164 .extra1 = &zero,
1165 .extra2 = &one_thousand,
1166 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001167#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001168#ifdef CONFIG_KMEMCHECK
1169 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001170 .procname = "kmemcheck",
1171 .data = &kmemcheck_enabled,
1172 .maxlen = sizeof(int),
1173 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001174 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001175 },
1176#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001177 {
1178 .procname = "panic_on_warn",
1179 .data = &panic_on_warn,
1180 .maxlen = sizeof(int),
1181 .mode = 0644,
1182 .proc_handler = proc_dointvec_minmax,
1183 .extra1 = &zero,
1184 .extra2 = &one,
1185 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001186#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1187 {
1188 .procname = "timer_migration",
1189 .data = &sysctl_timer_migration,
1190 .maxlen = sizeof(unsigned int),
1191 .mode = 0644,
1192 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001193 .extra1 = &zero,
1194 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001195 },
1196#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001197#ifdef CONFIG_BPF_SYSCALL
1198 {
1199 .procname = "unprivileged_bpf_disabled",
1200 .data = &sysctl_unprivileged_bpf_disabled,
1201 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1202 .mode = 0644,
1203 /* only handle a transition from default "0" to "1" */
1204 .proc_handler = proc_dointvec_minmax,
1205 .extra1 = &one,
1206 .extra2 = &one,
1207 },
1208#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001209#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1210 {
1211 .procname = "panic_on_rcu_stall",
1212 .data = &sysctl_panic_on_rcu_stall,
1213 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1214 .mode = 0644,
1215 .proc_handler = proc_dointvec_minmax,
1216 .extra1 = &zero,
1217 .extra2 = &one,
1218 },
1219#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001220 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221};
1222
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001223static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 .procname = "overcommit_memory",
1226 .data = &sysctl_overcommit_memory,
1227 .maxlen = sizeof(sysctl_overcommit_memory),
1228 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001229 .proc_handler = proc_dointvec_minmax,
1230 .extra1 = &zero,
1231 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 },
1233 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001234 .procname = "panic_on_oom",
1235 .data = &sysctl_panic_on_oom,
1236 .maxlen = sizeof(sysctl_panic_on_oom),
1237 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001238 .proc_handler = proc_dointvec_minmax,
1239 .extra1 = &zero,
1240 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001241 },
1242 {
David Rientjesfe071d72007-10-16 23:25:56 -07001243 .procname = "oom_kill_allocating_task",
1244 .data = &sysctl_oom_kill_allocating_task,
1245 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1246 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001247 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001248 },
1249 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001250 .procname = "oom_dump_tasks",
1251 .data = &sysctl_oom_dump_tasks,
1252 .maxlen = sizeof(sysctl_oom_dump_tasks),
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001255 },
1256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 .procname = "overcommit_ratio",
1258 .data = &sysctl_overcommit_ratio,
1259 .maxlen = sizeof(sysctl_overcommit_ratio),
1260 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001261 .proc_handler = overcommit_ratio_handler,
1262 },
1263 {
1264 .procname = "overcommit_kbytes",
1265 .data = &sysctl_overcommit_kbytes,
1266 .maxlen = sizeof(sysctl_overcommit_kbytes),
1267 .mode = 0644,
1268 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 },
1270 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 .procname = "page-cluster",
1272 .data = &page_cluster,
1273 .maxlen = sizeof(int),
1274 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001275 .proc_handler = proc_dointvec_minmax,
1276 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277 },
1278 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 .procname = "dirty_background_ratio",
1280 .data = &dirty_background_ratio,
1281 .maxlen = sizeof(dirty_background_ratio),
1282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001283 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284 .extra1 = &zero,
1285 .extra2 = &one_hundred,
1286 },
1287 {
David Rientjes2da02992009-01-06 14:39:31 -08001288 .procname = "dirty_background_bytes",
1289 .data = &dirty_background_bytes,
1290 .maxlen = sizeof(dirty_background_bytes),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001293 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001294 },
1295 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 .procname = "dirty_ratio",
1297 .data = &vm_dirty_ratio,
1298 .maxlen = sizeof(vm_dirty_ratio),
1299 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001300 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 .extra1 = &zero,
1302 .extra2 = &one_hundred,
1303 },
1304 {
David Rientjes2da02992009-01-06 14:39:31 -08001305 .procname = "dirty_bytes",
1306 .data = &vm_dirty_bytes,
1307 .maxlen = sizeof(vm_dirty_bytes),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001310 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001311 },
1312 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001314 .data = &dirty_writeback_interval,
1315 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001317 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 },
1319 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001321 .data = &dirty_expire_interval,
1322 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001324 .proc_handler = proc_dointvec_minmax,
1325 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001326 },
1327 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001328 .procname = "dirtytime_expire_seconds",
1329 .data = &dirtytime_expire_interval,
1330 .maxlen = sizeof(dirty_expire_interval),
1331 .mode = 0644,
1332 .proc_handler = dirtytime_interval_handler,
1333 .extra1 = &zero,
1334 },
1335 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001336 .procname = "nr_pdflush_threads",
1337 .mode = 0444 /* read-only */,
1338 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 },
1340 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 .procname = "swappiness",
1342 .data = &vm_swappiness,
1343 .maxlen = sizeof(vm_swappiness),
1344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001345 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 .extra1 = &zero,
1347 .extra2 = &one_hundred,
1348 },
1349#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001350 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001352 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .maxlen = sizeof(unsigned long),
1354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001355 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001356 },
1357#ifdef CONFIG_NUMA
1358 {
1359 .procname = "nr_hugepages_mempolicy",
1360 .data = NULL,
1361 .maxlen = sizeof(unsigned long),
1362 .mode = 0644,
1363 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001364 },
1365#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 .procname = "hugetlb_shm_group",
1368 .data = &sysctl_hugetlb_shm_group,
1369 .maxlen = sizeof(gid_t),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 },
Mel Gorman396faf02007-07-17 04:03:13 -07001373 {
Mel Gorman396faf02007-07-17 04:03:13 -07001374 .procname = "hugepages_treat_as_movable",
1375 .data = &hugepages_treat_as_movable,
1376 .maxlen = sizeof(int),
1377 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001378 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001379 },
Adam Litke54f9f802007-10-16 01:26:20 -07001380 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001381 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001382 .data = NULL,
1383 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001384 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001385 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001386 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387#endif
1388 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 .procname = "lowmem_reserve_ratio",
1390 .data = &sysctl_lowmem_reserve_ratio,
1391 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001393 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 },
1395 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001396 .procname = "drop_caches",
1397 .data = &sysctl_drop_caches,
1398 .maxlen = sizeof(int),
1399 .mode = 0644,
1400 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001401 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001402 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001403 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001404#ifdef CONFIG_COMPACTION
1405 {
1406 .procname = "compact_memory",
1407 .data = &sysctl_compact_memory,
1408 .maxlen = sizeof(int),
1409 .mode = 0200,
1410 .proc_handler = sysctl_compaction_handler,
1411 },
Mel Gorman5e771902010-05-24 14:32:31 -07001412 {
1413 .procname = "extfrag_threshold",
1414 .data = &sysctl_extfrag_threshold,
1415 .maxlen = sizeof(int),
1416 .mode = 0644,
1417 .proc_handler = sysctl_extfrag_handler,
1418 .extra1 = &min_extfrag_threshold,
1419 .extra2 = &max_extfrag_threshold,
1420 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001421 {
1422 .procname = "compact_unevictable_allowed",
1423 .data = &sysctl_compact_unevictable_allowed,
1424 .maxlen = sizeof(int),
1425 .mode = 0644,
1426 .proc_handler = proc_dointvec,
1427 .extra1 = &zero,
1428 .extra2 = &one,
1429 },
Mel Gorman5e771902010-05-24 14:32:31 -07001430
Mel Gorman76ab0f52010-05-24 14:32:28 -07001431#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001432 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 .procname = "min_free_kbytes",
1434 .data = &min_free_kbytes,
1435 .maxlen = sizeof(min_free_kbytes),
1436 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001437 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 .extra1 = &zero,
1439 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001440 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001441 .procname = "watermark_scale_factor",
1442 .data = &watermark_scale_factor,
1443 .maxlen = sizeof(watermark_scale_factor),
1444 .mode = 0644,
1445 .proc_handler = watermark_scale_factor_sysctl_handler,
1446 .extra1 = &one,
1447 .extra2 = &one_thousand,
1448 },
1449 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001450 .procname = "percpu_pagelist_fraction",
1451 .data = &percpu_pagelist_fraction,
1452 .maxlen = sizeof(percpu_pagelist_fraction),
1453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001455 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001456 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457#ifdef CONFIG_MMU
1458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 .procname = "max_map_count",
1460 .data = &sysctl_max_map_count,
1461 .maxlen = sizeof(sysctl_max_map_count),
1462 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001463 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001464 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001466#else
1467 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001468 .procname = "nr_trim_pages",
1469 .data = &sysctl_nr_trim_pages,
1470 .maxlen = sizeof(sysctl_nr_trim_pages),
1471 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001472 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001473 .extra1 = &zero,
1474 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475#endif
1476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .procname = "laptop_mode",
1478 .data = &laptop_mode,
1479 .maxlen = sizeof(laptop_mode),
1480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001481 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 },
1483 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 .procname = "block_dump",
1485 .data = &block_dump,
1486 .maxlen = sizeof(block_dump),
1487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001488 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 .extra1 = &zero,
1490 },
1491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .procname = "vfs_cache_pressure",
1493 .data = &sysctl_vfs_cache_pressure,
1494 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001496 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 .extra1 = &zero,
1498 },
1499#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .procname = "legacy_va_layout",
1502 .data = &sysctl_legacy_va_layout,
1503 .maxlen = sizeof(sysctl_legacy_va_layout),
1504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001505 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .extra1 = &zero,
1507 },
1508#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001509#ifdef CONFIG_NUMA
1510 {
Christoph Lameter17436602006-01-18 17:42:32 -08001511 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001512 .data = &node_reclaim_mode,
1513 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001516 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001517 },
Christoph Lameter96146342006-07-03 00:24:13 -07001518 {
Christoph Lameter96146342006-07-03 00:24:13 -07001519 .procname = "min_unmapped_ratio",
1520 .data = &sysctl_min_unmapped_ratio,
1521 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001523 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001524 .extra1 = &zero,
1525 .extra2 = &one_hundred,
1526 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001527 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001528 .procname = "min_slab_ratio",
1529 .data = &sysctl_min_slab_ratio,
1530 .maxlen = sizeof(sysctl_min_slab_ratio),
1531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001532 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001533 .extra1 = &zero,
1534 .extra2 = &one_hundred,
1535 },
Christoph Lameter17436602006-01-18 17:42:32 -08001536#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001537#ifdef CONFIG_SMP
1538 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001539 .procname = "stat_interval",
1540 .data = &sysctl_stat_interval,
1541 .maxlen = sizeof(sysctl_stat_interval),
1542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001543 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001544 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001545 {
1546 .procname = "stat_refresh",
1547 .data = NULL,
1548 .maxlen = 0,
1549 .mode = 0600,
1550 .proc_handler = vmstat_refresh,
1551 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001552#endif
David Howells6e141542009-12-15 19:27:45 +00001553#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001554 {
Eric Parised032182007-06-28 15:55:21 -04001555 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001556 .data = &dac_mmap_min_addr,
1557 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001558 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001559 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001560 },
David Howells6e141542009-12-15 19:27:45 +00001561#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001562#ifdef CONFIG_NUMA
1563 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001564 .procname = "numa_zonelist_order",
1565 .data = &numa_zonelist_order,
1566 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001568 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001569 },
1570#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001571#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001572 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001573 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001574 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001575#ifdef CONFIG_X86_32
1576 .data = &vdso32_enabled,
1577 .maxlen = sizeof(vdso32_enabled),
1578#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001579 .data = &vdso_enabled,
1580 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001581#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001583 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001584 .extra1 = &zero,
1585 },
1586#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001587#ifdef CONFIG_HIGHMEM
1588 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001589 .procname = "highmem_is_dirtyable",
1590 .data = &vm_highmem_is_dirtyable,
1591 .maxlen = sizeof(vm_highmem_is_dirtyable),
1592 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001593 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001594 .extra1 = &zero,
1595 .extra2 = &one,
1596 },
1597#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001598#ifdef CONFIG_MEMORY_FAILURE
1599 {
Andi Kleen6a460792009-09-16 11:50:15 +02001600 .procname = "memory_failure_early_kill",
1601 .data = &sysctl_memory_failure_early_kill,
1602 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1603 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001604 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001605 .extra1 = &zero,
1606 .extra2 = &one,
1607 },
1608 {
Andi Kleen6a460792009-09-16 11:50:15 +02001609 .procname = "memory_failure_recovery",
1610 .data = &sysctl_memory_failure_recovery,
1611 .maxlen = sizeof(sysctl_memory_failure_recovery),
1612 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001613 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001614 .extra1 = &zero,
1615 .extra2 = &one,
1616 },
1617#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001618 {
1619 .procname = "user_reserve_kbytes",
1620 .data = &sysctl_user_reserve_kbytes,
1621 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1622 .mode = 0644,
1623 .proc_handler = proc_doulongvec_minmax,
1624 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001625 {
1626 .procname = "admin_reserve_kbytes",
1627 .data = &sysctl_admin_reserve_kbytes,
1628 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1629 .mode = 0644,
1630 .proc_handler = proc_doulongvec_minmax,
1631 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001632#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1633 {
1634 .procname = "mmap_rnd_bits",
1635 .data = &mmap_rnd_bits,
1636 .maxlen = sizeof(mmap_rnd_bits),
1637 .mode = 0600,
1638 .proc_handler = proc_dointvec_minmax,
1639 .extra1 = (void *)&mmap_rnd_bits_min,
1640 .extra2 = (void *)&mmap_rnd_bits_max,
1641 },
1642#endif
1643#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1644 {
1645 .procname = "mmap_rnd_compat_bits",
1646 .data = &mmap_rnd_compat_bits,
1647 .maxlen = sizeof(mmap_rnd_compat_bits),
1648 .mode = 0600,
1649 .proc_handler = proc_dointvec_minmax,
1650 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1651 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1652 },
1653#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001654 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655};
1656
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001657static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 .procname = "inode-nr",
1660 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001661 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001663 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 },
1665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 .procname = "inode-state",
1667 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001668 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001670 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001671 },
1672 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 .procname = "file-nr",
1674 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001675 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001677 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678 },
1679 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 .procname = "file-max",
1681 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001682 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001684 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 },
1686 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001687 .procname = "nr_open",
1688 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001689 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001691 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001692 .extra1 = &sysctl_nr_open_min,
1693 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001694 },
1695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 .procname = "dentry-state",
1697 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001698 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001700 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701 },
1702 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 .procname = "overflowuid",
1704 .data = &fs_overflowuid,
1705 .maxlen = sizeof(int),
1706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001707 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001708 .extra1 = &minolduid,
1709 .extra2 = &maxolduid,
1710 },
1711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712 .procname = "overflowgid",
1713 .data = &fs_overflowgid,
1714 .maxlen = sizeof(int),
1715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001716 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717 .extra1 = &minolduid,
1718 .extra2 = &maxolduid,
1719 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001720#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 .procname = "leases-enable",
1723 .data = &leases_enable,
1724 .maxlen = sizeof(int),
1725 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001726 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001728#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729#ifdef CONFIG_DNOTIFY
1730 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731 .procname = "dir-notify-enable",
1732 .data = &dir_notify_enable,
1733 .maxlen = sizeof(int),
1734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001735 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 },
1737#endif
1738#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001739#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 .procname = "lease-break-time",
1742 .data = &lease_break_time,
1743 .maxlen = sizeof(int),
1744 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001745 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001747#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001748#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 .procname = "aio-nr",
1751 .data = &aio_nr,
1752 .maxlen = sizeof(aio_nr),
1753 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001754 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 },
1756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 .procname = "aio-max-nr",
1758 .data = &aio_max_nr,
1759 .maxlen = sizeof(aio_max_nr),
1760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001761 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001763#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001764#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001765 {
Robert Love0399cb02005-07-13 12:38:18 -04001766 .procname = "inotify",
1767 .mode = 0555,
1768 .child = inotify_table,
1769 },
1770#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001771#ifdef CONFIG_EPOLL
1772 {
1773 .procname = "epoll",
1774 .mode = 0555,
1775 .child = epoll_table,
1776 },
1777#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001779 {
Kees Cook800179c2012-07-25 17:29:07 -07001780 .procname = "protected_symlinks",
1781 .data = &sysctl_protected_symlinks,
1782 .maxlen = sizeof(int),
1783 .mode = 0600,
1784 .proc_handler = proc_dointvec_minmax,
1785 .extra1 = &zero,
1786 .extra2 = &one,
1787 },
1788 {
1789 .procname = "protected_hardlinks",
1790 .data = &sysctl_protected_hardlinks,
1791 .maxlen = sizeof(int),
1792 .mode = 0600,
1793 .proc_handler = proc_dointvec_minmax,
1794 .extra1 = &zero,
1795 .extra2 = &one,
1796 },
1797 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07001798 .procname = "protected_fifos",
1799 .data = &sysctl_protected_fifos,
1800 .maxlen = sizeof(int),
1801 .mode = 0600,
1802 .proc_handler = proc_dointvec_minmax,
1803 .extra1 = &zero,
1804 .extra2 = &two,
1805 },
1806 {
1807 .procname = "protected_regular",
1808 .data = &sysctl_protected_regular,
1809 .maxlen = sizeof(int),
1810 .mode = 0600,
1811 .proc_handler = proc_dointvec_minmax,
1812 .extra1 = &zero,
1813 .extra2 = &two,
1814 },
1815 {
Alan Coxd6e71142005-06-23 00:09:43 -07001816 .procname = "suid_dumpable",
1817 .data = &suid_dumpable,
1818 .maxlen = sizeof(int),
1819 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001820 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001821 .extra1 = &zero,
1822 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001823 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001824#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1825 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001826 .procname = "binfmt_misc",
1827 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001828 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001829 },
1830#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001831 {
Jens Axboeff9da692010-06-03 14:54:39 +02001832 .procname = "pipe-max-size",
1833 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001834 .maxlen = sizeof(int),
1835 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001836 .proc_handler = &pipe_proc_fn,
1837 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001838 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001839 {
1840 .procname = "pipe-user-pages-hard",
1841 .data = &pipe_user_pages_hard,
1842 .maxlen = sizeof(pipe_user_pages_hard),
1843 .mode = 0644,
1844 .proc_handler = proc_doulongvec_minmax,
1845 },
1846 {
1847 .procname = "pipe-user-pages-soft",
1848 .data = &pipe_user_pages_soft,
1849 .maxlen = sizeof(pipe_user_pages_soft),
1850 .mode = 0644,
1851 .proc_handler = proc_doulongvec_minmax,
1852 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001853 {
1854 .procname = "mount-max",
1855 .data = &sysctl_mount_max,
1856 .maxlen = sizeof(unsigned int),
1857 .mode = 0644,
1858 .proc_handler = proc_dointvec_minmax,
1859 .extra1 = &one,
1860 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001861 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862};
1863
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001864static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001865#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001866 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001867 .procname = "exception-trace",
1868 .data = &show_unhandled_signals,
1869 .maxlen = sizeof(int),
1870 .mode = 0644,
1871 .proc_handler = proc_dointvec
1872 },
1873#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001874#if defined(CONFIG_OPTPROBES)
1875 {
1876 .procname = "kprobes-optimization",
1877 .data = &sysctl_kprobes_optimization,
1878 .maxlen = sizeof(int),
1879 .mode = 0644,
1880 .proc_handler = proc_kprobes_optimization_handler,
1881 .extra1 = &zero,
1882 .extra2 = &one,
1883 },
1884#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001885 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886};
1887
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001888static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001889 { }
Robert Love0eeca282005-07-12 17:06:03 -04001890};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001892int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001893{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001894 struct ctl_table_header *hdr;
1895
1896 hdr = register_sysctl_table(sysctl_base_table);
1897 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001898 return 0;
1899}
1900
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001901#endif /* CONFIG_SYSCTL */
1902
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903/*
1904 * /proc/sys support
1905 */
1906
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001907#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908
Kees Cookf8808302014-06-06 14:37:17 -07001909static int _proc_do_string(char *data, int maxlen, int write,
1910 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001911 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001912{
1913 size_t len;
1914 char __user *p;
1915 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001916
1917 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001918 *lenp = 0;
1919 return 0;
1920 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001921
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001922 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001923 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1924 /* Only continue writes not past the end of buffer. */
1925 len = strlen(data);
1926 if (len > maxlen - 1)
1927 len = maxlen - 1;
1928
1929 if (*ppos > len)
1930 return 0;
1931 len = *ppos;
1932 } else {
1933 /* Start writing from beginning of buffer. */
1934 len = 0;
1935 }
1936
Kees Cook2ca9bb42014-06-06 14:37:18 -07001937 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001938 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001939 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001940 if (get_user(c, p++))
1941 return -EFAULT;
1942 if (c == 0 || c == '\n')
1943 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001944 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001945 }
Kees Cookf8808302014-06-06 14:37:17 -07001946 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001947 } else {
1948 len = strlen(data);
1949 if (len > maxlen)
1950 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001951
1952 if (*ppos > len) {
1953 *lenp = 0;
1954 return 0;
1955 }
1956
1957 data += *ppos;
1958 len -= *ppos;
1959
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001960 if (len > *lenp)
1961 len = *lenp;
1962 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001963 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001964 return -EFAULT;
1965 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001966 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001967 return -EFAULT;
1968 len++;
1969 }
1970 *lenp = len;
1971 *ppos += len;
1972 }
1973 return 0;
1974}
1975
Kees Cookf4aacea2014-06-06 14:37:19 -07001976static void warn_sysctl_write(struct ctl_table *table)
1977{
1978 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1979 "This will not be supported in the future. To silence this\n"
1980 "warning, set kernel.sysctl_writes_strict = -1\n",
1981 current->comm, table->procname);
1982}
1983
Linus Torvalds1da177e2005-04-16 15:20:36 -07001984/**
1985 * proc_dostring - read a string sysctl
1986 * @table: the sysctl table
1987 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988 * @buffer: the user buffer
1989 * @lenp: the size of the user buffer
1990 * @ppos: file position
1991 *
1992 * Reads/writes a string from/to the user buffer. If the kernel
1993 * buffer provided is not large enough to hold the string, the
1994 * string is truncated. The copied string is %NULL-terminated.
1995 * If the string is being read by the user process, it is copied
1996 * and a newline '\n' is added. It is truncated if the buffer is
1997 * not large enough.
1998 *
1999 * Returns 0 on success.
2000 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002001int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002 void __user *buffer, size_t *lenp, loff_t *ppos)
2003{
Kees Cookf4aacea2014-06-06 14:37:19 -07002004 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2005 warn_sysctl_write(table);
2006
Kees Cookf8808302014-06-06 14:37:17 -07002007 return _proc_do_string((char *)(table->data), table->maxlen, write,
2008 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009}
2010
Amerigo Wang00b7c332010-05-05 00:26:45 +00002011static size_t proc_skip_spaces(char **buf)
2012{
2013 size_t ret;
2014 char *tmp = skip_spaces(*buf);
2015 ret = tmp - *buf;
2016 *buf = tmp;
2017 return ret;
2018}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002020static void proc_skip_char(char **buf, size_t *size, const char v)
2021{
2022 while (*size) {
2023 if (**buf != v)
2024 break;
2025 (*size)--;
2026 (*buf)++;
2027 }
2028}
2029
Amerigo Wang00b7c332010-05-05 00:26:45 +00002030#define TMPBUFLEN 22
2031/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002032 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002033 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002034 * @buf: a kernel buffer
2035 * @size: size of the kernel buffer
2036 * @val: this is where the number will be stored
2037 * @neg: set to %TRUE if number is negative
2038 * @perm_tr: a vector which contains the allowed trailers
2039 * @perm_tr_len: size of the perm_tr vector
2040 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002041 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002042 * In case of success %0 is returned and @buf and @size are updated with
2043 * the amount of bytes read. If @tr is non-NULL and a trailing
2044 * character exists (size is non-zero after returning from this
2045 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002046 */
2047static int proc_get_long(char **buf, size_t *size,
2048 unsigned long *val, bool *neg,
2049 const char *perm_tr, unsigned perm_tr_len, char *tr)
2050{
2051 int len;
2052 char *p, tmp[TMPBUFLEN];
2053
2054 if (!*size)
2055 return -EINVAL;
2056
2057 len = *size;
2058 if (len > TMPBUFLEN - 1)
2059 len = TMPBUFLEN - 1;
2060
2061 memcpy(tmp, *buf, len);
2062
2063 tmp[len] = 0;
2064 p = tmp;
2065 if (*p == '-' && *size > 1) {
2066 *neg = true;
2067 p++;
2068 } else
2069 *neg = false;
2070 if (!isdigit(*p))
2071 return -EINVAL;
2072
2073 *val = simple_strtoul(p, &p, 0);
2074
2075 len = p - tmp;
2076
2077 /* We don't know if the next char is whitespace thus we may accept
2078 * invalid integers (e.g. 1234...a) or two integers instead of one
2079 * (e.g. 123...1). So lets not allow such large numbers. */
2080 if (len == TMPBUFLEN - 1)
2081 return -EINVAL;
2082
2083 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2084 return -EINVAL;
2085
2086 if (tr && (len < *size))
2087 *tr = *p;
2088
2089 *buf += len;
2090 *size -= len;
2091
2092 return 0;
2093}
2094
2095/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002096 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002097 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002098 * @buf: the user buffer
2099 * @size: the size of the user buffer
2100 * @val: the integer to be converted
2101 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002102 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002103 * In case of success %0 is returned and @buf and @size are updated with
2104 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002105 */
2106static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2107 bool neg)
2108{
2109 int len;
2110 char tmp[TMPBUFLEN], *p = tmp;
2111
2112 sprintf(p, "%s%lu", neg ? "-" : "", val);
2113 len = strlen(tmp);
2114 if (len > *size)
2115 len = *size;
2116 if (copy_to_user(*buf, tmp, len))
2117 return -EFAULT;
2118 *size -= len;
2119 *buf += len;
2120 return 0;
2121}
2122#undef TMPBUFLEN
2123
2124static int proc_put_char(void __user **buf, size_t *size, char c)
2125{
2126 if (*size) {
2127 char __user **buffer = (char __user **)buf;
2128 if (put_user(c, *buffer))
2129 return -EFAULT;
2130 (*size)--, (*buffer)++;
2131 *buf = *buffer;
2132 }
2133 return 0;
2134}
2135
2136static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 int *valp,
2138 int write, void *data)
2139{
2140 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002141 if (*negp) {
2142 if (*lvalp > (unsigned long) INT_MAX + 1)
2143 return -EINVAL;
2144 *valp = -*lvalp;
2145 } else {
2146 if (*lvalp > (unsigned long) INT_MAX)
2147 return -EINVAL;
2148 *valp = *lvalp;
2149 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002150 } else {
2151 int val = *valp;
2152 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002153 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002154 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002156 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157 *lvalp = (unsigned long)val;
2158 }
2159 }
2160 return 0;
2161}
2162
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002163static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2164 int *valp,
2165 int write, void *data)
2166{
2167 if (write) {
2168 if (*negp)
2169 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002170 if (*lvalp > UINT_MAX)
2171 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002172 *valp = *lvalp;
2173 } else {
2174 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002175 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002176 *lvalp = (unsigned long)val;
2177 }
2178 return 0;
2179}
2180
Amerigo Wang00b7c332010-05-05 00:26:45 +00002181static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2182
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002183static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002184 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002185 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002186 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187 int write, void *data),
2188 void *data)
2189{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002190 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002191 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002192 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193
Amerigo Wang00b7c332010-05-05 00:26:45 +00002194 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 *lenp = 0;
2196 return 0;
2197 }
2198
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002199 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200 vleft = table->maxlen / sizeof(*i);
2201 left = *lenp;
2202
2203 if (!conv)
2204 conv = do_proc_dointvec_conv;
2205
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002207 if (*ppos) {
2208 switch (sysctl_writes_strict) {
2209 case SYSCTL_WRITES_STRICT:
2210 goto out;
2211 case SYSCTL_WRITES_WARN:
2212 warn_sysctl_write(table);
2213 break;
2214 default:
2215 break;
2216 }
2217 }
2218
Amerigo Wang00b7c332010-05-05 00:26:45 +00002219 if (left > PAGE_SIZE - 1)
2220 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002221 p = kbuf = memdup_user_nul(buffer, left);
2222 if (IS_ERR(kbuf))
2223 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002224 }
2225
2226 for (; left && vleft--; i++, first=0) {
2227 unsigned long lval;
2228 bool neg;
2229
2230 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002231 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002232
J. R. Okajima563b0462010-05-25 16:10:14 -07002233 if (!left)
2234 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002235 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236 proc_wspace_sep,
2237 sizeof(proc_wspace_sep), NULL);
2238 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002240 if (conv(&neg, &lval, i, 1, data)) {
2241 err = -EINVAL;
2242 break;
2243 }
2244 } else {
2245 if (conv(&neg, &lval, i, 0, data)) {
2246 err = -EINVAL;
2247 break;
2248 }
2249 if (!first)
2250 err = proc_put_char(&buffer, &left, '\t');
2251 if (err)
2252 break;
2253 err = proc_put_long(&buffer, &left, lval, neg);
2254 if (err)
2255 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256 }
2257 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002258
2259 if (!write && !first && left && !err)
2260 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002261 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002262 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002263 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002264 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002265 if (first)
2266 return err ? : -EINVAL;
2267 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002269out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002271 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272}
2273
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002274static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002275 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002276 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002277 int write, void *data),
2278 void *data)
2279{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002280 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002281 buffer, lenp, ppos, conv, data);
2282}
2283
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284/**
2285 * proc_dointvec - read a vector of integers
2286 * @table: the sysctl table
2287 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288 * @buffer: the user buffer
2289 * @lenp: the size of the user buffer
2290 * @ppos: file position
2291 *
2292 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2293 * values from/to the user buffer, treated as an ASCII string.
2294 *
2295 * Returns 0 on success.
2296 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002297int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 void __user *buffer, size_t *lenp, loff_t *ppos)
2299{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002300 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2301}
2302
2303/**
2304 * proc_douintvec - read a vector of unsigned integers
2305 * @table: the sysctl table
2306 * @write: %TRUE if this is a write to the sysctl file
2307 * @buffer: the user buffer
2308 * @lenp: the size of the user buffer
2309 * @ppos: file position
2310 *
2311 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2312 * values from/to the user buffer, treated as an ASCII string.
2313 *
2314 * Returns 0 on success.
2315 */
2316int proc_douintvec(struct ctl_table *table, int write,
2317 void __user *buffer, size_t *lenp, loff_t *ppos)
2318{
2319 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2320 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321}
2322
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002323/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002324 * Taint values can only be increased
2325 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002326 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002327static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002328 void __user *buffer, size_t *lenp, loff_t *ppos)
2329{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002330 struct ctl_table t;
2331 unsigned long tmptaint = get_taint();
2332 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002333
Bastian Blank91fcd412007-04-23 14:41:14 -07002334 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002335 return -EPERM;
2336
Andi Kleen25ddbb12008-10-15 22:01:41 -07002337 t = *table;
2338 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002339 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002340 if (err < 0)
2341 return err;
2342
2343 if (write) {
2344 /*
2345 * Poor man's atomic or. Not worth adding a primitive
2346 * to everyone's atomic.h for this
2347 */
2348 int i;
2349 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2350 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302351 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002352 }
2353 }
2354
2355 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002356}
2357
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002358#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002359static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002360 void __user *buffer, size_t *lenp, loff_t *ppos)
2361{
2362 if (write && !capable(CAP_SYS_ADMIN))
2363 return -EPERM;
2364
2365 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2366}
2367#endif
2368
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369struct do_proc_dointvec_minmax_conv_param {
2370 int *min;
2371 int *max;
2372};
2373
Amerigo Wang00b7c332010-05-05 00:26:45 +00002374static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2375 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 int write, void *data)
2377{
2378 struct do_proc_dointvec_minmax_conv_param *param = data;
2379 if (write) {
Zev Weiss45a67f12019-03-11 23:28:02 -07002380 int val;
2381 if (*negp) {
2382 if (*lvalp > (unsigned long) INT_MAX + 1)
2383 return -EINVAL;
2384 val = -*lvalp;
2385 } else {
2386 if (*lvalp > (unsigned long) INT_MAX)
2387 return -EINVAL;
2388 val = *lvalp;
2389 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 if ((param->min && *param->min > val) ||
2391 (param->max && *param->max < val))
2392 return -EINVAL;
2393 *valp = val;
2394 } else {
2395 int val = *valp;
2396 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002397 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002398 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002400 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 *lvalp = (unsigned long)val;
2402 }
2403 }
2404 return 0;
2405}
2406
2407/**
2408 * proc_dointvec_minmax - read a vector of integers with min/max values
2409 * @table: the sysctl table
2410 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411 * @buffer: the user buffer
2412 * @lenp: the size of the user buffer
2413 * @ppos: file position
2414 *
2415 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2416 * values from/to the user buffer, treated as an ASCII string.
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 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002423int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002424 void __user *buffer, size_t *lenp, loff_t *ppos)
2425{
2426 struct do_proc_dointvec_minmax_conv_param param = {
2427 .min = (int *) table->extra1,
2428 .max = (int *) table->extra2,
2429 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002430 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 do_proc_dointvec_minmax_conv, &param);
2432}
2433
Kees Cook54b50192012-07-30 14:39:18 -07002434static void validate_coredump_safety(void)
2435{
Alex Kelly046d6622012-10-04 17:15:23 -07002436#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002437 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002438 core_pattern[0] != '/' && core_pattern[0] != '|') {
2439 printk(KERN_WARNING "Unsafe core_pattern used with "\
2440 "suid_dumpable=2. Pipe handler or fully qualified "\
2441 "core dump path required.\n");
2442 }
Alex Kelly046d6622012-10-04 17:15:23 -07002443#endif
Kees Cook54b50192012-07-30 14:39:18 -07002444}
2445
2446static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2447 void __user *buffer, size_t *lenp, loff_t *ppos)
2448{
2449 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2450 if (!error)
2451 validate_coredump_safety();
2452 return error;
2453}
2454
Alex Kelly046d6622012-10-04 17:15:23 -07002455#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002456static int proc_dostring_coredump(struct ctl_table *table, int write,
2457 void __user *buffer, size_t *lenp, loff_t *ppos)
2458{
2459 int error = proc_dostring(table, write, buffer, lenp, ppos);
2460 if (!error)
2461 validate_coredump_safety();
2462 return error;
2463}
Alex Kelly046d6622012-10-04 17:15:23 -07002464#endif
Kees Cook54b50192012-07-30 14:39:18 -07002465
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002466static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 void __user *buffer,
2468 size_t *lenp, loff_t *ppos,
2469 unsigned long convmul,
2470 unsigned long convdiv)
2471{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002472 unsigned long *i, *min, *max;
2473 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002474 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002475 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002476
2477 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478 *lenp = 0;
2479 return 0;
2480 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002481
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002482 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 min = (unsigned long *) table->extra1;
2484 max = (unsigned long *) table->extra2;
2485 vleft = table->maxlen / sizeof(unsigned long);
2486 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002487
2488 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002489 if (*ppos) {
2490 switch (sysctl_writes_strict) {
2491 case SYSCTL_WRITES_STRICT:
2492 goto out;
2493 case SYSCTL_WRITES_WARN:
2494 warn_sysctl_write(table);
2495 break;
2496 default:
2497 break;
2498 }
2499 }
2500
Amerigo Wang00b7c332010-05-05 00:26:45 +00002501 if (left > PAGE_SIZE - 1)
2502 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002503 p = kbuf = memdup_user_nul(buffer, left);
2504 if (IS_ERR(kbuf))
2505 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002506 }
2507
Eric Dumazet27b3d802010-10-07 12:59:29 -07002508 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002509 unsigned long val;
2510
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002512 bool neg;
2513
Al Viro70f6cbb2015-12-24 00:13:10 -05002514 left -= proc_skip_spaces(&p);
Cheng Lin0e5c7502019-01-03 15:26:13 -08002515 if (!left)
2516 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002517
Al Viro70f6cbb2015-12-24 00:13:10 -05002518 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002519 proc_wspace_sep,
2520 sizeof(proc_wspace_sep), NULL);
2521 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522 break;
2523 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002525 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526 if ((min && val < *min) || (max && val > *max))
2527 continue;
2528 *i = val;
2529 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002530 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002531 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002532 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002533 if (err)
2534 break;
2535 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002536 err = proc_put_long(&buffer, &left, val, false);
2537 if (err)
2538 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 }
2540 }
2541
Amerigo Wang00b7c332010-05-05 00:26:45 +00002542 if (!write && !first && left && !err)
2543 err = proc_put_char(&buffer, &left, '\n');
2544 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002545 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002547 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002548 if (first)
2549 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002552out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002554 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555}
2556
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002557static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002558 void __user *buffer,
2559 size_t *lenp, loff_t *ppos,
2560 unsigned long convmul,
2561 unsigned long convdiv)
2562{
2563 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002564 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002565}
2566
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567/**
2568 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2569 * @table: the sysctl table
2570 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 * @buffer: the user buffer
2572 * @lenp: the size of the user buffer
2573 * @ppos: file position
2574 *
2575 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2576 * values from/to the user buffer, treated as an ASCII string.
2577 *
2578 * This routine will ensure the values are within the range specified by
2579 * table->extra1 (min) and table->extra2 (max).
2580 *
2581 * Returns 0 on success.
2582 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002583int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 void __user *buffer, size_t *lenp, loff_t *ppos)
2585{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002586 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587}
2588
2589/**
2590 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2591 * @table: the sysctl table
2592 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 * @buffer: the user buffer
2594 * @lenp: the size of the user buffer
2595 * @ppos: file position
2596 *
2597 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2598 * values from/to the user buffer, treated as an ASCII string. The values
2599 * are treated as milliseconds, and converted to jiffies when they are stored.
2600 *
2601 * This routine will ensure the values are within the range specified by
2602 * table->extra1 (min) and table->extra2 (max).
2603 *
2604 * Returns 0 on success.
2605 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002606int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 void __user *buffer,
2608 size_t *lenp, loff_t *ppos)
2609{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002610 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 lenp, ppos, HZ, 1000l);
2612}
2613
2614
Amerigo Wang00b7c332010-05-05 00:26:45 +00002615static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 int *valp,
2617 int write, void *data)
2618{
2619 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002620 if (*lvalp > LONG_MAX / HZ)
2621 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2623 } else {
2624 int val = *valp;
2625 unsigned long lval;
2626 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002627 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002628 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002630 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 lval = (unsigned long)val;
2632 }
2633 *lvalp = lval / HZ;
2634 }
2635 return 0;
2636}
2637
Amerigo Wang00b7c332010-05-05 00:26:45 +00002638static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639 int *valp,
2640 int write, void *data)
2641{
2642 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002643 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2644 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2646 } else {
2647 int val = *valp;
2648 unsigned long lval;
2649 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002650 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002651 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002653 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 lval = (unsigned long)val;
2655 }
2656 *lvalp = jiffies_to_clock_t(lval);
2657 }
2658 return 0;
2659}
2660
Amerigo Wang00b7c332010-05-05 00:26:45 +00002661static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 int *valp,
2663 int write, void *data)
2664{
2665 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002666 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2667
2668 if (jif > INT_MAX)
2669 return 1;
2670 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671 } else {
2672 int val = *valp;
2673 unsigned long lval;
2674 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002675 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002676 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002678 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 lval = (unsigned long)val;
2680 }
2681 *lvalp = jiffies_to_msecs(lval);
2682 }
2683 return 0;
2684}
2685
2686/**
2687 * proc_dointvec_jiffies - read a vector of integers as seconds
2688 * @table: the sysctl table
2689 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690 * @buffer: the user buffer
2691 * @lenp: the size of the user buffer
2692 * @ppos: file position
2693 *
2694 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2695 * values from/to the user buffer, treated as an ASCII string.
2696 * The values read are assumed to be in seconds, and are converted into
2697 * jiffies.
2698 *
2699 * Returns 0 on success.
2700 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002701int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702 void __user *buffer, size_t *lenp, loff_t *ppos)
2703{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002704 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705 do_proc_dointvec_jiffies_conv,NULL);
2706}
2707
2708/**
2709 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2710 * @table: the sysctl table
2711 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002712 * @buffer: the user buffer
2713 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002714 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 *
2716 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2717 * values from/to the user buffer, treated as an ASCII string.
2718 * The values read are assumed to be in 1/USER_HZ seconds, and
2719 * are converted into jiffies.
2720 *
2721 * Returns 0 on success.
2722 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002723int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002724 void __user *buffer, size_t *lenp, loff_t *ppos)
2725{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002726 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 do_proc_dointvec_userhz_jiffies_conv,NULL);
2728}
2729
2730/**
2731 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2732 * @table: the sysctl table
2733 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002734 * @buffer: the user buffer
2735 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002736 * @ppos: file position
2737 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002738 *
2739 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2740 * values from/to the user buffer, treated as an ASCII string.
2741 * The values read are assumed to be in 1/1000 seconds, and
2742 * are converted into jiffies.
2743 *
2744 * Returns 0 on success.
2745 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002746int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002747 void __user *buffer, size_t *lenp, loff_t *ppos)
2748{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002749 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750 do_proc_dointvec_ms_jiffies_conv, NULL);
2751}
2752
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002753static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002754 void __user *buffer, size_t *lenp, loff_t *ppos)
2755{
2756 struct pid *new_pid;
2757 pid_t tmp;
2758 int r;
2759
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002760 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002761
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002762 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002763 lenp, ppos, NULL, NULL);
2764 if (r || !write)
2765 return r;
2766
2767 new_pid = find_get_pid(tmp);
2768 if (!new_pid)
2769 return -ESRCH;
2770
2771 put_pid(xchg(&cad_pid, new_pid));
2772 return 0;
2773}
2774
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002775/**
2776 * proc_do_large_bitmap - read/write from/to a large bitmap
2777 * @table: the sysctl table
2778 * @write: %TRUE if this is a write to the sysctl file
2779 * @buffer: the user buffer
2780 * @lenp: the size of the user buffer
2781 * @ppos: file position
2782 *
2783 * The bitmap is stored at table->data and the bitmap length (in bits)
2784 * in table->maxlen.
2785 *
2786 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2787 * large bitmaps may be represented in a compact manner. Writing into
2788 * the file will clear the bitmap then update it with the given input.
2789 *
2790 * Returns 0 on success.
2791 */
2792int proc_do_large_bitmap(struct ctl_table *table, int write,
2793 void __user *buffer, size_t *lenp, loff_t *ppos)
2794{
2795 int err = 0;
2796 bool first = 1;
2797 size_t left = *lenp;
2798 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002799 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002800 unsigned long *tmp_bitmap = NULL;
2801 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2802
WANG Cong122ff242014-05-12 16:04:53 -07002803 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002804 *lenp = 0;
2805 return 0;
2806 }
2807
2808 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002809 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002810
2811 if (left > PAGE_SIZE - 1)
2812 left = PAGE_SIZE - 1;
2813
Al Viro70f6cbb2015-12-24 00:13:10 -05002814 p = kbuf = memdup_user_nul(buffer, left);
2815 if (IS_ERR(kbuf))
2816 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002817
2818 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2819 GFP_KERNEL);
2820 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002821 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002822 return -ENOMEM;
2823 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002824 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002825 while (!err && left) {
2826 unsigned long val_a, val_b;
2827 bool neg;
2828
Al Viro70f6cbb2015-12-24 00:13:10 -05002829 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002830 sizeof(tr_a), &c);
2831 if (err)
2832 break;
2833 if (val_a >= bitmap_len || neg) {
2834 err = -EINVAL;
2835 break;
2836 }
2837
2838 val_b = val_a;
2839 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002840 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002841 left--;
2842 }
2843
2844 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002845 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002846 &neg, tr_b, sizeof(tr_b),
2847 &c);
2848 if (err)
2849 break;
2850 if (val_b >= bitmap_len || neg ||
2851 val_a > val_b) {
2852 err = -EINVAL;
2853 break;
2854 }
2855 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002856 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002857 left--;
2858 }
2859 }
2860
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002861 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002862 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002863 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002864 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002865 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002866 } else {
2867 unsigned long bit_a, bit_b = 0;
2868
2869 while (left) {
2870 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2871 if (bit_a >= bitmap_len)
2872 break;
2873 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2874 bit_a + 1) - 1;
2875
2876 if (!first) {
2877 err = proc_put_char(&buffer, &left, ',');
2878 if (err)
2879 break;
2880 }
2881 err = proc_put_long(&buffer, &left, bit_a, false);
2882 if (err)
2883 break;
2884 if (bit_a != bit_b) {
2885 err = proc_put_char(&buffer, &left, '-');
2886 if (err)
2887 break;
2888 err = proc_put_long(&buffer, &left, bit_b, false);
2889 if (err)
2890 break;
2891 }
2892
2893 first = 0; bit_b++;
2894 }
2895 if (!err)
2896 err = proc_put_char(&buffer, &left, '\n');
2897 }
2898
2899 if (!err) {
2900 if (write) {
2901 if (*ppos)
2902 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2903 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002904 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002905 }
2906 kfree(tmp_bitmap);
2907 *lenp -= left;
2908 *ppos += *lenp;
2909 return 0;
2910 } else {
2911 kfree(tmp_bitmap);
2912 return err;
2913 }
2914}
2915
Jovi Zhang55610502011-01-12 17:00:45 -08002916#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002917
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002918int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002919 void __user *buffer, size_t *lenp, loff_t *ppos)
2920{
2921 return -ENOSYS;
2922}
2923
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002924int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002925 void __user *buffer, size_t *lenp, loff_t *ppos)
2926{
2927 return -ENOSYS;
2928}
2929
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002930int proc_douintvec(struct ctl_table *table, int write,
2931 void __user *buffer, size_t *lenp, loff_t *ppos)
2932{
2933 return -ENOSYS;
2934}
2935
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002936int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002937 void __user *buffer, size_t *lenp, loff_t *ppos)
2938{
2939 return -ENOSYS;
2940}
2941
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002942int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 void __user *buffer, size_t *lenp, loff_t *ppos)
2944{
2945 return -ENOSYS;
2946}
2947
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002948int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002949 void __user *buffer, size_t *lenp, loff_t *ppos)
2950{
2951 return -ENOSYS;
2952}
2953
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002954int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955 void __user *buffer, size_t *lenp, loff_t *ppos)
2956{
2957 return -ENOSYS;
2958}
2959
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002960int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002961 void __user *buffer, size_t *lenp, loff_t *ppos)
2962{
2963 return -ENOSYS;
2964}
2965
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002966int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967 void __user *buffer,
2968 size_t *lenp, loff_t *ppos)
2969{
2970 return -ENOSYS;
2971}
2972
2973
Jovi Zhang55610502011-01-12 17:00:45 -08002974#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002975
Linus Torvalds1da177e2005-04-16 15:20:36 -07002976/*
2977 * No sense putting this after each symbol definition, twice,
2978 * exception granted :-)
2979 */
2980EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002981EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982EXPORT_SYMBOL(proc_dointvec_jiffies);
2983EXPORT_SYMBOL(proc_dointvec_minmax);
2984EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2985EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2986EXPORT_SYMBOL(proc_dostring);
2987EXPORT_SYMBOL(proc_doulongvec_minmax);
2988EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);