blob: 6af1ac551ea3aa0468d585d1f750f30f21700c75 [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;
Will Deacon3141fcc2019-04-05 18:39:38 -0700127static unsigned long zero_ul;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800128static unsigned long one_ul = 1;
Christian Brauner6b65c262019-03-07 16:29:43 -0800129static unsigned long long_max = LONG_MAX;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700130static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700131static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700132#ifdef CONFIG_PRINTK
133static int ten_thousand = 10000;
134#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300135#ifdef CONFIG_PERF_EVENTS
136static int six_hundred_forty_kb = 640 * 1024;
137#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700138
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700139/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
140static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
143static int maxolduid = 65535;
144static int minolduid;
145
146static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700147static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Liu Hua80df2842014-04-07 15:38:57 -0700149/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
150#ifdef CONFIG_DETECT_HUNG_TASK
151static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
152#endif
153
Dave Youngd14f1722010-02-25 20:28:57 -0500154#ifdef CONFIG_INOTIFY_USER
155#include <linux/inotify.h>
156#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700157#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#endif
159
160#ifdef __hppa__
161extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530162#endif
163
164#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165extern int unaligned_enabled;
166#endif
167
Jes Sorensend2b176e2006-02-28 09:42:23 -0800168#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800169extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800170#endif
171
Vineet Guptab6fca722013-01-09 20:06:28 +0530172#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
173extern int no_unaligned_warning;
174#endif
175
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700176#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700177
178#define SYSCTL_WRITES_LEGACY -1
179#define SYSCTL_WRITES_WARN 0
180#define SYSCTL_WRITES_STRICT 1
181
Kees Cook41662f52016-01-20 15:00:45 -0800182static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700183
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700184static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700185 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700186static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800187 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700188#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700189
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700190#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700191static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700192 void __user *buffer, size_t *lenp, loff_t *ppos);
193#endif
194
Kees Cook54b50192012-07-30 14:39:18 -0700195static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
196 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700197#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700198static int proc_dostring_coredump(struct ctl_table *table, int write,
199 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700200#endif
Kees Cook54b50192012-07-30 14:39:18 -0700201
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700202#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800203/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100204static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700205
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700206static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700207 void __user *buffer, size_t *lenp,
208 loff_t *ppos)
209{
210 int error;
211
212 error = proc_dointvec(table, write, buffer, lenp, ppos);
213 if (error)
214 return error;
215
216 if (write)
217 sysrq_toggle_support(__sysrq_enabled);
218
219 return 0;
220}
221
222#endif
223
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700224static struct ctl_table kern_table[];
225static struct ctl_table vm_table[];
226static struct ctl_table fs_table[];
227static struct ctl_table debug_table[];
228static struct ctl_table dev_table[];
229extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800230#ifdef CONFIG_EPOLL
231extern struct ctl_table epoll_table[];
232#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
235int sysctl_legacy_va_layout;
236#endif
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238/* The default sysctl tables: */
239
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800240static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 .procname = "kernel",
243 .mode = 0555,
244 .child = kern_table,
245 },
246 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 .procname = "vm",
248 .mode = 0555,
249 .child = vm_table,
250 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 .procname = "fs",
253 .mode = 0555,
254 .child = fs_table,
255 },
256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 .procname = "debug",
258 .mode = 0555,
259 .child = debug_table,
260 },
261 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 .procname = "dev",
263 .mode = 0555,
264 .child = dev_table,
265 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700266 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267};
268
Ingo Molnar77e54a12007-07-09 18:52:00 +0200269#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100270static int min_sched_granularity_ns = 100000; /* 100 usecs */
271static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
272static int min_wakeup_granularity_ns; /* 0 usecs */
273static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200274#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100275static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
276static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200277#endif /* CONFIG_SMP */
278#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200279
Mel Gorman5e771902010-05-24 14:32:31 -0700280#ifdef CONFIG_COMPACTION
281static int min_extfrag_threshold;
282static int max_extfrag_threshold = 1000;
283#endif
284
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700285static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200286 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200287 .procname = "sched_child_runs_first",
288 .data = &sysctl_sched_child_runs_first,
289 .maxlen = sizeof(unsigned int),
290 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800291 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200292 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200293#ifdef CONFIG_SCHED_DEBUG
294 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100295 .procname = "sched_min_granularity_ns",
296 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200297 .maxlen = sizeof(unsigned int),
298 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800299 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100300 .extra1 = &min_sched_granularity_ns,
301 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200302 },
303 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200304 .procname = "sched_latency_ns",
305 .data = &sysctl_sched_latency,
306 .maxlen = sizeof(unsigned int),
307 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800308 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200309 .extra1 = &min_sched_granularity_ns,
310 .extra2 = &max_sched_granularity_ns,
311 },
312 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200313 .procname = "sched_wakeup_granularity_ns",
314 .data = &sysctl_sched_wakeup_granularity,
315 .maxlen = sizeof(unsigned int),
316 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800317 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200318 .extra1 = &min_wakeup_granularity_ns,
319 .extra2 = &max_wakeup_granularity_ns,
320 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200321#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200322 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100323 .procname = "sched_tunable_scaling",
324 .data = &sysctl_sched_tunable_scaling,
325 .maxlen = sizeof(enum sched_tunable_scaling),
326 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800327 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100328 .extra1 = &min_sched_tunable_scaling,
329 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200330 },
331 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900332 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200333 .data = &sysctl_sched_migration_cost,
334 .maxlen = sizeof(unsigned int),
335 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800336 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200337 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100338 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100339 .procname = "sched_nr_migrate",
340 .data = &sysctl_sched_nr_migrate,
341 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800343 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100344 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530345 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900346 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200347 .data = &sysctl_sched_time_avg,
348 .maxlen = sizeof(unsigned int),
349 .mode = 0644,
Ethan Zhaofe0034a2017-09-04 13:59:34 +0800350 .proc_handler = proc_dointvec_minmax,
351 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200352 },
353 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900354 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800355 .data = &sysctl_sched_shares_window,
356 .maxlen = sizeof(unsigned int),
357 .mode = 0644,
358 .proc_handler = proc_dointvec,
359 },
Mel Gormancb251762016-02-05 09:08:36 +0000360#ifdef CONFIG_SCHEDSTATS
361 {
362 .procname = "sched_schedstats",
363 .data = NULL,
364 .maxlen = sizeof(unsigned int),
365 .mode = 0644,
366 .proc_handler = sysctl_schedstats,
367 .extra1 = &zero,
368 .extra2 = &one,
369 },
370#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200371#endif /* CONFIG_SMP */
372#ifdef CONFIG_NUMA_BALANCING
373 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200374 .procname = "numa_balancing_scan_delay_ms",
375 .data = &sysctl_numa_balancing_scan_delay,
376 .maxlen = sizeof(unsigned int),
377 .mode = 0644,
378 .proc_handler = proc_dointvec,
379 },
380 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200381 .procname = "numa_balancing_scan_period_min_ms",
382 .data = &sysctl_numa_balancing_scan_period_min,
383 .maxlen = sizeof(unsigned int),
384 .mode = 0644,
385 .proc_handler = proc_dointvec,
386 },
387 {
388 .procname = "numa_balancing_scan_period_max_ms",
389 .data = &sysctl_numa_balancing_scan_period_max,
390 .maxlen = sizeof(unsigned int),
391 .mode = 0644,
392 .proc_handler = proc_dointvec,
393 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200394 {
395 .procname = "numa_balancing_scan_size_mb",
396 .data = &sysctl_numa_balancing_scan_size,
397 .maxlen = sizeof(unsigned int),
398 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400399 .proc_handler = proc_dointvec_minmax,
400 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200401 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100402 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800403 .procname = "numa_balancing",
404 .data = NULL, /* filled in by handler */
405 .maxlen = sizeof(unsigned int),
406 .mode = 0644,
407 .proc_handler = sysctl_numa_balancing,
408 .extra1 = &zero,
409 .extra2 = &one,
410 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200411#endif /* CONFIG_NUMA_BALANCING */
412#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200413 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100414 .procname = "sched_rt_period_us",
415 .data = &sysctl_sched_rt_period,
416 .maxlen = sizeof(unsigned int),
417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800418 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100419 },
420 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100421 .procname = "sched_rt_runtime_us",
422 .data = &sysctl_sched_rt_runtime,
423 .maxlen = sizeof(int),
424 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800425 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100426 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600427 {
428 .procname = "sched_rr_timeslice_ms",
429 .data = &sched_rr_timeslice,
430 .maxlen = sizeof(int),
431 .mode = 0644,
432 .proc_handler = sched_rr_handler,
433 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100434#ifdef CONFIG_SCHED_AUTOGROUP
435 {
436 .procname = "sched_autogroup_enabled",
437 .data = &sysctl_sched_autogroup_enabled,
438 .maxlen = sizeof(unsigned int),
439 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800440 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100441 .extra1 = &zero,
442 .extra2 = &one,
443 },
444#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700445#ifdef CONFIG_CFS_BANDWIDTH
446 {
447 .procname = "sched_cfs_bandwidth_slice_us",
448 .data = &sysctl_sched_cfs_bandwidth_slice,
449 .maxlen = sizeof(unsigned int),
450 .mode = 0644,
451 .proc_handler = proc_dointvec_minmax,
452 .extra1 = &one,
453 },
454#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700455#ifdef CONFIG_PROVE_LOCKING
456 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700457 .procname = "prove_locking",
458 .data = &prove_locking,
459 .maxlen = sizeof(int),
460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800461 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700462 },
463#endif
464#ifdef CONFIG_LOCK_STAT
465 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700466 .procname = "lock_stat",
467 .data = &lock_stat,
468 .maxlen = sizeof(int),
469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800470 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700471 },
472#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200473 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 .procname = "panic",
475 .data = &panic_timeout,
476 .maxlen = sizeof(int),
477 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800478 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 },
Alex Kelly046d6622012-10-04 17:15:23 -0700480#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 .procname = "core_uses_pid",
483 .data = &core_uses_pid,
484 .maxlen = sizeof(int),
485 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800486 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 },
488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 .procname = "core_pattern",
490 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700491 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700493 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 },
Neil Hormana2939802009-09-23 15:56:56 -0700495 {
Neil Hormana2939802009-09-23 15:56:56 -0700496 .procname = "core_pipe_limit",
497 .data = &core_pipe_limit,
498 .maxlen = sizeof(unsigned int),
499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800500 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700501 },
Alex Kelly046d6622012-10-04 17:15:23 -0700502#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800503#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700506 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800507 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800508 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700510 {
511 .procname = "sysctl_writes_strict",
512 .data = &sysctl_writes_strict,
513 .maxlen = sizeof(int),
514 .mode = 0644,
515 .proc_handler = proc_dointvec_minmax,
516 .extra1 = &neg_one,
517 .extra2 = &one,
518 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800519#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100520#ifdef CONFIG_LATENCYTOP
521 {
522 .procname = "latencytop",
523 .data = &latencytop_enabled,
524 .maxlen = sizeof(int),
525 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000526 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100527 },
528#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529#ifdef CONFIG_BLK_DEV_INITRD
530 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 .procname = "real-root-dev",
532 .data = &real_root_dev,
533 .maxlen = sizeof(int),
534 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800535 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 },
537#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700538 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700539 .procname = "print-fatal-signals",
540 .data = &print_fatal_signals,
541 .maxlen = sizeof(int),
542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800543 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700544 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700545#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 .procname = "reboot-cmd",
548 .data = reboot_command,
549 .maxlen = 256,
550 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800551 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 },
553 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 .procname = "stop-a",
555 .data = &stop_a_enabled,
556 .maxlen = sizeof (int),
557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800558 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 },
560 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 .procname = "scons-poweroff",
562 .data = &scons_pwroff,
563 .maxlen = sizeof (int),
564 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800565 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 },
567#endif
David S. Miller08714202008-11-16 23:49:24 -0800568#ifdef CONFIG_SPARC64
569 {
David S. Miller08714202008-11-16 23:49:24 -0800570 .procname = "tsb-ratio",
571 .data = &sysctl_tsb_ratio,
572 .maxlen = sizeof (int),
573 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800574 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800575 },
576#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577#ifdef __hppa__
578 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 .procname = "soft-power",
580 .data = &pwrsw_enabled,
581 .maxlen = sizeof (int),
582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800583 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530585#endif
586#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 .procname = "unaligned-trap",
589 .data = &unaligned_enabled,
590 .maxlen = sizeof (int),
591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 },
594#endif
595 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 .procname = "ctrl-alt-del",
597 .data = &C_A_D,
598 .maxlen = sizeof(int),
599 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800600 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400602#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200603 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200604 .procname = "ftrace_enabled",
605 .data = &ftrace_enabled,
606 .maxlen = sizeof(int),
607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800608 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200609 },
610#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500611#ifdef CONFIG_STACK_TRACER
612 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500613 .procname = "stack_tracer_enabled",
614 .data = &stack_tracer_enabled,
615 .maxlen = sizeof(int),
616 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800617 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500618 },
619#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400620#ifdef CONFIG_TRACING
621 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100622 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400623 .data = &ftrace_dump_on_oops,
624 .maxlen = sizeof(int),
625 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800626 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400627 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400628 {
629 .procname = "traceoff_on_warning",
630 .data = &__disable_trace_on_warning,
631 .maxlen = sizeof(__disable_trace_on_warning),
632 .mode = 0644,
633 .proc_handler = proc_dointvec,
634 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500635 {
636 .procname = "tracepoint_printk",
637 .data = &tracepoint_printk,
638 .maxlen = sizeof(tracepoint_printk),
639 .mode = 0644,
640 .proc_handler = proc_dointvec,
641 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400642#endif
Dave Young2965faa2015-09-09 15:38:55 -0700643#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800644 {
645 .procname = "kexec_load_disabled",
646 .data = &kexec_load_disabled,
647 .maxlen = sizeof(int),
648 .mode = 0644,
649 /* only handle a transition from default "0" to "1" */
650 .proc_handler = proc_dointvec_minmax,
651 .extra1 = &one,
652 .extra2 = &one,
653 },
654#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200655#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .procname = "modprobe",
658 .data = &modprobe_path,
659 .maxlen = KMOD_PATH_LEN,
660 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800661 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 },
Kees Cook3d433212009-04-02 15:49:29 -0700663 {
Kees Cook3d433212009-04-02 15:49:29 -0700664 .procname = "modules_disabled",
665 .data = &modules_disabled,
666 .maxlen = sizeof(int),
667 .mode = 0644,
668 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800669 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700670 .extra1 = &one,
671 .extra2 = &one,
672 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700674#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100677 .data = &uevent_helper,
678 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800680 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 },
Michael Marineau86d56132014-04-10 14:09:31 -0700682#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683#ifdef CONFIG_CHR_DEV_SG
684 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .procname = "sg-big-buff",
686 .data = &sg_big_buff,
687 .maxlen = sizeof (int),
688 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800689 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 },
691#endif
692#ifdef CONFIG_BSD_PROCESS_ACCT
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "acct",
695 .data = &acct_parm,
696 .maxlen = 3*sizeof(int),
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 },
700#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701#ifdef CONFIG_MAGIC_SYSRQ
702 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800704 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 .maxlen = sizeof (int),
706 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700707 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 },
709#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700710#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700713 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 .maxlen = sizeof (int),
715 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800716 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700718#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700721 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 .maxlen = sizeof(int),
723 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700724 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 },
726 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .procname = "random",
728 .mode = 0555,
729 .child = random_table,
730 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 {
Eric Paris17f60a72011-04-01 17:07:50 -0400732 .procname = "usermodehelper",
733 .mode = 0555,
734 .child = usermodehelper_table,
735 },
736 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 .procname = "overflowuid",
738 .data = &overflowuid,
739 .maxlen = sizeof(int),
740 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800741 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .extra1 = &minolduid,
743 .extra2 = &maxolduid,
744 },
745 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 .procname = "overflowgid",
747 .data = &overflowgid,
748 .maxlen = sizeof(int),
749 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800750 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 .extra1 = &minolduid,
752 .extra2 = &maxolduid,
753 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800754#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755#ifdef CONFIG_MATHEMU
756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .procname = "ieee_emulation_warnings",
758 .data = &sysctl_ieee_emulation_warnings,
759 .maxlen = sizeof(int),
760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800761 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 },
763#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200766 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 .maxlen = sizeof(int),
768 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800769 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 },
771#endif
772 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 .procname = "pid_max",
774 .data = &pid_max,
775 .maxlen = sizeof (int),
776 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800777 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 .extra1 = &pid_max_min,
779 .extra2 = &pid_max_max,
780 },
781 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 .procname = "panic_on_oops",
783 .data = &panic_on_oops,
784 .maxlen = sizeof(int),
785 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800786 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800788#if defined CONFIG_PRINTK
789 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800790 .procname = "printk",
791 .data = &console_loglevel,
792 .maxlen = 4*sizeof(int),
793 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800794 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800795 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700798 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 .maxlen = sizeof(int),
800 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800801 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 },
803 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700805 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 .maxlen = sizeof(int),
807 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800808 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 },
Dave Youngaf913222009-09-22 16:43:33 -0700810 {
Dave Youngaf913222009-09-22 16:43:33 -0700811 .procname = "printk_delay",
812 .data = &printk_delay_msec,
813 .maxlen = sizeof(int),
814 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800815 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700816 .extra1 = &zero,
817 .extra2 = &ten_thousand,
818 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700820 .procname = "printk_devkmsg",
821 .data = devkmsg_log_str,
822 .maxlen = DEVKMSG_STR_MAX_SIZE,
823 .mode = 0644,
824 .proc_handler = devkmsg_sysctl_set_loglvl,
825 },
826 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800827 .procname = "dmesg_restrict",
828 .data = &dmesg_restrict,
829 .maxlen = sizeof(int),
830 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700831 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800832 .extra1 = &zero,
833 .extra2 = &one,
834 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800835 {
836 .procname = "kptr_restrict",
837 .data = &kptr_restrict,
838 .maxlen = sizeof(int),
839 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700840 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800841 .extra1 = &zero,
842 .extra2 = &two,
843 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800844#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800845 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 .procname = "ngroups_max",
847 .data = &ngroups_max,
848 .maxlen = sizeof (int),
849 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800850 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 },
Dan Ballard73efc032011-10-31 17:11:20 -0700852 {
853 .procname = "cap_last_cap",
854 .data = (void *)&cap_last_cap,
855 .maxlen = sizeof(int),
856 .mode = 0444,
857 .proc_handler = proc_dointvec,
858 },
Don Zickus58687ac2010-05-07 17:11:44 -0400859#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500860 {
Don Zickus58687ac2010-05-07 17:11:44 -0400861 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200862 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500863 .maxlen = sizeof (int),
864 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700865 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700866 .extra1 = &zero,
867 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400868 },
869 {
870 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700871 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400872 .maxlen = sizeof(int),
873 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700874 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800875 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400876 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500877 },
Don Zickus2508ce12010-05-07 17:11:46 -0400878 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700879 .procname = "nmi_watchdog",
880 .data = &nmi_watchdog_enabled,
881 .maxlen = sizeof (int),
882 .mode = 0644,
883 .proc_handler = proc_nmi_watchdog,
884 .extra1 = &zero,
885#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
886 .extra2 = &one,
887#else
888 .extra2 = &zero,
889#endif
890 },
891 {
892 .procname = "soft_watchdog",
893 .data = &soft_watchdog_enabled,
894 .maxlen = sizeof (int),
895 .mode = 0644,
896 .proc_handler = proc_soft_watchdog,
897 .extra1 = &zero,
898 .extra2 = &one,
899 },
900 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700901 .procname = "watchdog_cpumask",
902 .data = &watchdog_cpumask_bits,
903 .maxlen = NR_CPUS,
904 .mode = 0644,
905 .proc_handler = proc_watchdog_cpumask,
906 },
907 {
Don Zickus2508ce12010-05-07 17:11:46 -0400908 .procname = "softlockup_panic",
909 .data = &softlockup_panic,
910 .maxlen = sizeof(int),
911 .mode = 0644,
912 .proc_handler = proc_dointvec_minmax,
913 .extra1 = &zero,
914 .extra2 = &one,
915 },
Don Zickusac1f5912015-11-05 18:44:44 -0800916#ifdef CONFIG_HARDLOCKUP_DETECTOR
917 {
918 .procname = "hardlockup_panic",
919 .data = &hardlockup_panic,
920 .maxlen = sizeof(int),
921 .mode = 0644,
922 .proc_handler = proc_dointvec_minmax,
923 .extra1 = &zero,
924 .extra2 = &one,
925 },
926#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700927#ifdef CONFIG_SMP
928 {
929 .procname = "softlockup_all_cpu_backtrace",
930 .data = &sysctl_softlockup_all_cpu_backtrace,
931 .maxlen = sizeof(int),
932 .mode = 0644,
933 .proc_handler = proc_dointvec_minmax,
934 .extra1 = &zero,
935 .extra2 = &one,
936 },
Jiri Kosina55537872015-11-05 18:44:41 -0800937 {
938 .procname = "hardlockup_all_cpu_backtrace",
939 .data = &sysctl_hardlockup_all_cpu_backtrace,
940 .maxlen = sizeof(int),
941 .mode = 0644,
942 .proc_handler = proc_dointvec_minmax,
943 .extra1 = &zero,
944 .extra2 = &one,
945 },
Aaron Tomlined235872014-06-23 13:22:05 -0700946#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500947#endif
948#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
949 {
950 .procname = "unknown_nmi_panic",
951 .data = &unknown_nmi_panic,
952 .maxlen = sizeof (int),
953 .mode = 0644,
954 .proc_handler = proc_dointvec,
955 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500956#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957#if defined(CONFIG_X86)
958 {
Don Zickus8da5add2006-09-26 10:52:27 +0200959 .procname = "panic_on_unrecovered_nmi",
960 .data = &panic_on_unrecovered_nmi,
961 .maxlen = sizeof(int),
962 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800963 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200964 },
965 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700966 .procname = "panic_on_io_nmi",
967 .data = &panic_on_io_nmi,
968 .maxlen = sizeof(int),
969 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700971 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900972#ifdef CONFIG_DEBUG_STACKOVERFLOW
973 {
974 .procname = "panic_on_stackoverflow",
975 .data = &sysctl_panic_on_stackoverflow,
976 .maxlen = sizeof(int),
977 .mode = 0644,
978 .proc_handler = proc_dointvec,
979 },
980#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700981 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982 .procname = "bootloader_type",
983 .data = &bootloader_type,
984 .maxlen = sizeof (int),
985 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800986 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100988 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700989 .procname = "bootloader_version",
990 .data = &bootloader_version,
991 .maxlen = sizeof (int),
992 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700994 },
995 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100996 .procname = "kstack_depth_to_print",
997 .data = &kstack_depth_to_print,
998 .maxlen = sizeof(int),
999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001001 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001002 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001003 .procname = "io_delay_type",
1004 .data = &io_delay_type,
1005 .maxlen = sizeof(int),
1006 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001007 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001008 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001010#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 .procname = "randomize_va_space",
1013 .data = &randomize_va_space,
1014 .maxlen = sizeof(int),
1015 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001016 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001018#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001019#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001020 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001021 .procname = "spin_retry",
1022 .data = &spin_retry,
1023 .maxlen = sizeof (int),
1024 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001025 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001026 },
1027#endif
Len Brown673d5b42007-07-28 03:33:16 -04001028#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001029 {
Pavel Machekc255d842006-02-20 18:27:58 -08001030 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001031 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001032 .maxlen = sizeof (unsigned long),
1033 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001034 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001035 },
1036#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301037#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001038 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001039 .procname = "ignore-unaligned-usertrap",
1040 .data = &no_unaligned_warning,
1041 .maxlen = sizeof (int),
1042 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001043 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001044 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301045#endif
1046#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001047 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001048 .procname = "unaligned-dump-stack",
1049 .data = &unaligned_dump_stack,
1050 .maxlen = sizeof (int),
1051 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001052 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001053 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001054#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001055#ifdef CONFIG_DETECT_HUNG_TASK
1056 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001057 .procname = "hung_task_panic",
1058 .data = &sysctl_hung_task_panic,
1059 .maxlen = sizeof(int),
1060 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001061 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001062 .extra1 = &zero,
1063 .extra2 = &one,
1064 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001065 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001066 .procname = "hung_task_check_count",
1067 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001068 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001069 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001070 .proc_handler = proc_dointvec_minmax,
1071 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001072 },
1073 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001074 .procname = "hung_task_timeout_secs",
1075 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001076 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001077 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001078 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001079 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001080 },
1081 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001082 .procname = "hung_task_warnings",
1083 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001084 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001085 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001086 .proc_handler = proc_dointvec_minmax,
1087 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001088 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001089#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001090#ifdef CONFIG_RT_MUTEXES
1091 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001092 .procname = "max_lock_depth",
1093 .data = &max_lock_depth,
1094 .maxlen = sizeof(int),
1095 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001096 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001097 },
1098#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001099 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001100 .procname = "poweroff_cmd",
1101 .data = &poweroff_cmd,
1102 .maxlen = POWEROFF_CMD_PATH_LEN,
1103 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001104 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001105 },
David Howells0b77f5b2008-04-29 01:01:32 -07001106#ifdef CONFIG_KEYS
1107 {
David Howells0b77f5b2008-04-29 01:01:32 -07001108 .procname = "keys",
1109 .mode = 0555,
1110 .child = key_sysctls,
1111 },
1112#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001113#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001114 /*
1115 * User-space scripts rely on the existence of this file
1116 * as a feature check for perf_events being enabled.
1117 *
1118 * So it's an ABI, do not remove!
1119 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001120 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001121 .procname = "perf_event_paranoid",
1122 .data = &sysctl_perf_event_paranoid,
1123 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001124 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001125 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001126 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001127 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001128 .procname = "perf_event_mlock_kb",
1129 .data = &sysctl_perf_event_mlock,
1130 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001131 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001132 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001133 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001134 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001135 .procname = "perf_event_max_sample_rate",
1136 .data = &sysctl_perf_event_sample_rate,
1137 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001138 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001139 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001140 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001141 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001142 {
1143 .procname = "perf_cpu_time_max_percent",
1144 .data = &sysctl_perf_cpu_time_max_percent,
1145 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1146 .mode = 0644,
1147 .proc_handler = perf_cpu_time_max_percent_handler,
1148 .extra1 = &zero,
1149 .extra2 = &one_hundred,
1150 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001151 {
1152 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001153 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001154 .maxlen = sizeof(sysctl_perf_event_max_stack),
1155 .mode = 0644,
1156 .proc_handler = perf_event_max_stack_handler,
1157 .extra1 = &zero,
1158 .extra2 = &six_hundred_forty_kb,
1159 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001160 {
1161 .procname = "perf_event_max_contexts_per_stack",
1162 .data = &sysctl_perf_event_max_contexts_per_stack,
1163 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1164 .mode = 0644,
1165 .proc_handler = perf_event_max_stack_handler,
1166 .extra1 = &zero,
1167 .extra2 = &one_thousand,
1168 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001169#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001170#ifdef CONFIG_KMEMCHECK
1171 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001172 .procname = "kmemcheck",
1173 .data = &kmemcheck_enabled,
1174 .maxlen = sizeof(int),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001177 },
1178#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001179 {
1180 .procname = "panic_on_warn",
1181 .data = &panic_on_warn,
1182 .maxlen = sizeof(int),
1183 .mode = 0644,
1184 .proc_handler = proc_dointvec_minmax,
1185 .extra1 = &zero,
1186 .extra2 = &one,
1187 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001188#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1189 {
1190 .procname = "timer_migration",
1191 .data = &sysctl_timer_migration,
1192 .maxlen = sizeof(unsigned int),
1193 .mode = 0644,
1194 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001195 .extra1 = &zero,
1196 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001197 },
1198#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001199#ifdef CONFIG_BPF_SYSCALL
1200 {
1201 .procname = "unprivileged_bpf_disabled",
1202 .data = &sysctl_unprivileged_bpf_disabled,
1203 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1204 .mode = 0644,
1205 /* only handle a transition from default "0" to "1" */
1206 .proc_handler = proc_dointvec_minmax,
1207 .extra1 = &one,
1208 .extra2 = &one,
1209 },
1210#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001211#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1212 {
1213 .procname = "panic_on_rcu_stall",
1214 .data = &sysctl_panic_on_rcu_stall,
1215 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1216 .mode = 0644,
1217 .proc_handler = proc_dointvec_minmax,
1218 .extra1 = &zero,
1219 .extra2 = &one,
1220 },
1221#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001222 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223};
1224
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001225static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 .procname = "overcommit_memory",
1228 .data = &sysctl_overcommit_memory,
1229 .maxlen = sizeof(sysctl_overcommit_memory),
1230 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001231 .proc_handler = proc_dointvec_minmax,
1232 .extra1 = &zero,
1233 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 },
1235 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001236 .procname = "panic_on_oom",
1237 .data = &sysctl_panic_on_oom,
1238 .maxlen = sizeof(sysctl_panic_on_oom),
1239 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001240 .proc_handler = proc_dointvec_minmax,
1241 .extra1 = &zero,
1242 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001243 },
1244 {
David Rientjesfe071d72007-10-16 23:25:56 -07001245 .procname = "oom_kill_allocating_task",
1246 .data = &sysctl_oom_kill_allocating_task,
1247 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1248 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001249 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001250 },
1251 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001252 .procname = "oom_dump_tasks",
1253 .data = &sysctl_oom_dump_tasks,
1254 .maxlen = sizeof(sysctl_oom_dump_tasks),
1255 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001256 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001257 },
1258 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 .procname = "overcommit_ratio",
1260 .data = &sysctl_overcommit_ratio,
1261 .maxlen = sizeof(sysctl_overcommit_ratio),
1262 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001263 .proc_handler = overcommit_ratio_handler,
1264 },
1265 {
1266 .procname = "overcommit_kbytes",
1267 .data = &sysctl_overcommit_kbytes,
1268 .maxlen = sizeof(sysctl_overcommit_kbytes),
1269 .mode = 0644,
1270 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 },
1272 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 .procname = "page-cluster",
1274 .data = &page_cluster,
1275 .maxlen = sizeof(int),
1276 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001277 .proc_handler = proc_dointvec_minmax,
1278 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 },
1280 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 .procname = "dirty_background_ratio",
1282 .data = &dirty_background_ratio,
1283 .maxlen = sizeof(dirty_background_ratio),
1284 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001285 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286 .extra1 = &zero,
1287 .extra2 = &one_hundred,
1288 },
1289 {
David Rientjes2da02992009-01-06 14:39:31 -08001290 .procname = "dirty_background_bytes",
1291 .data = &dirty_background_bytes,
1292 .maxlen = sizeof(dirty_background_bytes),
1293 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001294 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001295 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001296 },
1297 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298 .procname = "dirty_ratio",
1299 .data = &vm_dirty_ratio,
1300 .maxlen = sizeof(vm_dirty_ratio),
1301 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001302 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 .extra1 = &zero,
1304 .extra2 = &one_hundred,
1305 },
1306 {
David Rientjes2da02992009-01-06 14:39:31 -08001307 .procname = "dirty_bytes",
1308 .data = &vm_dirty_bytes,
1309 .maxlen = sizeof(vm_dirty_bytes),
1310 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001311 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001312 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001313 },
1314 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001316 .data = &dirty_writeback_interval,
1317 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001319 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 },
1321 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001323 .data = &dirty_expire_interval,
1324 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001326 .proc_handler = proc_dointvec_minmax,
1327 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328 },
1329 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001330 .procname = "dirtytime_expire_seconds",
1331 .data = &dirtytime_expire_interval,
1332 .maxlen = sizeof(dirty_expire_interval),
1333 .mode = 0644,
1334 .proc_handler = dirtytime_interval_handler,
1335 .extra1 = &zero,
1336 },
1337 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001338 .procname = "nr_pdflush_threads",
1339 .mode = 0444 /* read-only */,
1340 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 },
1342 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 .procname = "swappiness",
1344 .data = &vm_swappiness,
1345 .maxlen = sizeof(vm_swappiness),
1346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001347 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348 .extra1 = &zero,
1349 .extra2 = &one_hundred,
1350 },
1351#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001352 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001354 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 .maxlen = sizeof(unsigned long),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001358 },
1359#ifdef CONFIG_NUMA
1360 {
1361 .procname = "nr_hugepages_mempolicy",
1362 .data = NULL,
1363 .maxlen = sizeof(unsigned long),
1364 .mode = 0644,
1365 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001366 },
1367#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369 .procname = "hugetlb_shm_group",
1370 .data = &sysctl_hugetlb_shm_group,
1371 .maxlen = sizeof(gid_t),
1372 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001373 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 },
Mel Gorman396faf02007-07-17 04:03:13 -07001375 {
Mel Gorman396faf02007-07-17 04:03:13 -07001376 .procname = "hugepages_treat_as_movable",
1377 .data = &hugepages_treat_as_movable,
1378 .maxlen = sizeof(int),
1379 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001380 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001381 },
Adam Litke54f9f802007-10-16 01:26:20 -07001382 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001383 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001384 .data = NULL,
1385 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001387 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001388 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389#endif
1390 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 .procname = "lowmem_reserve_ratio",
1392 .data = &sysctl_lowmem_reserve_ratio,
1393 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1394 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001395 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396 },
1397 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001398 .procname = "drop_caches",
1399 .data = &sysctl_drop_caches,
1400 .maxlen = sizeof(int),
1401 .mode = 0644,
1402 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001403 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001404 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001405 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001406#ifdef CONFIG_COMPACTION
1407 {
1408 .procname = "compact_memory",
1409 .data = &sysctl_compact_memory,
1410 .maxlen = sizeof(int),
1411 .mode = 0200,
1412 .proc_handler = sysctl_compaction_handler,
1413 },
Mel Gorman5e771902010-05-24 14:32:31 -07001414 {
1415 .procname = "extfrag_threshold",
1416 .data = &sysctl_extfrag_threshold,
1417 .maxlen = sizeof(int),
1418 .mode = 0644,
1419 .proc_handler = sysctl_extfrag_handler,
1420 .extra1 = &min_extfrag_threshold,
1421 .extra2 = &max_extfrag_threshold,
1422 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001423 {
1424 .procname = "compact_unevictable_allowed",
1425 .data = &sysctl_compact_unevictable_allowed,
1426 .maxlen = sizeof(int),
1427 .mode = 0644,
1428 .proc_handler = proc_dointvec,
1429 .extra1 = &zero,
1430 .extra2 = &one,
1431 },
Mel Gorman5e771902010-05-24 14:32:31 -07001432
Mel Gorman76ab0f52010-05-24 14:32:28 -07001433#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001434 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 .procname = "min_free_kbytes",
1436 .data = &min_free_kbytes,
1437 .maxlen = sizeof(min_free_kbytes),
1438 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001439 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 .extra1 = &zero,
1441 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001442 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001443 .procname = "watermark_scale_factor",
1444 .data = &watermark_scale_factor,
1445 .maxlen = sizeof(watermark_scale_factor),
1446 .mode = 0644,
1447 .proc_handler = watermark_scale_factor_sysctl_handler,
1448 .extra1 = &one,
1449 .extra2 = &one_thousand,
1450 },
1451 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001452 .procname = "percpu_pagelist_fraction",
1453 .data = &percpu_pagelist_fraction,
1454 .maxlen = sizeof(percpu_pagelist_fraction),
1455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001456 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001457 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001458 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459#ifdef CONFIG_MMU
1460 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461 .procname = "max_map_count",
1462 .data = &sysctl_max_map_count,
1463 .maxlen = sizeof(sysctl_max_map_count),
1464 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001465 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001466 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001468#else
1469 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001470 .procname = "nr_trim_pages",
1471 .data = &sysctl_nr_trim_pages,
1472 .maxlen = sizeof(sysctl_nr_trim_pages),
1473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001474 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001475 .extra1 = &zero,
1476 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477#endif
1478 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 .procname = "laptop_mode",
1480 .data = &laptop_mode,
1481 .maxlen = sizeof(laptop_mode),
1482 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001483 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 },
1485 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 .procname = "block_dump",
1487 .data = &block_dump,
1488 .maxlen = sizeof(block_dump),
1489 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001490 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491 .extra1 = &zero,
1492 },
1493 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .procname = "vfs_cache_pressure",
1495 .data = &sysctl_vfs_cache_pressure,
1496 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001498 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 .extra1 = &zero,
1500 },
1501#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 .procname = "legacy_va_layout",
1504 .data = &sysctl_legacy_va_layout,
1505 .maxlen = sizeof(sysctl_legacy_va_layout),
1506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001507 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 .extra1 = &zero,
1509 },
1510#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001511#ifdef CONFIG_NUMA
1512 {
Christoph Lameter17436602006-01-18 17:42:32 -08001513 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001514 .data = &node_reclaim_mode,
1515 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001516 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001517 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001518 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001519 },
Christoph Lameter96146342006-07-03 00:24:13 -07001520 {
Christoph Lameter96146342006-07-03 00:24:13 -07001521 .procname = "min_unmapped_ratio",
1522 .data = &sysctl_min_unmapped_ratio,
1523 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001525 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001526 .extra1 = &zero,
1527 .extra2 = &one_hundred,
1528 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001529 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001530 .procname = "min_slab_ratio",
1531 .data = &sysctl_min_slab_ratio,
1532 .maxlen = sizeof(sysctl_min_slab_ratio),
1533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001534 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001535 .extra1 = &zero,
1536 .extra2 = &one_hundred,
1537 },
Christoph Lameter17436602006-01-18 17:42:32 -08001538#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001539#ifdef CONFIG_SMP
1540 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001541 .procname = "stat_interval",
1542 .data = &sysctl_stat_interval,
1543 .maxlen = sizeof(sysctl_stat_interval),
1544 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001545 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001546 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001547 {
1548 .procname = "stat_refresh",
1549 .data = NULL,
1550 .maxlen = 0,
1551 .mode = 0600,
1552 .proc_handler = vmstat_refresh,
1553 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001554#endif
David Howells6e141542009-12-15 19:27:45 +00001555#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001556 {
Eric Parised032182007-06-28 15:55:21 -04001557 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001558 .data = &dac_mmap_min_addr,
1559 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001560 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001561 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001562 },
David Howells6e141542009-12-15 19:27:45 +00001563#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001564#ifdef CONFIG_NUMA
1565 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001566 .procname = "numa_zonelist_order",
1567 .data = &numa_zonelist_order,
1568 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1569 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001570 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001571 },
1572#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001573#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001574 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001575 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001576 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001577#ifdef CONFIG_X86_32
1578 .data = &vdso32_enabled,
1579 .maxlen = sizeof(vdso32_enabled),
1580#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001581 .data = &vdso_enabled,
1582 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001583#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001584 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001585 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001586 .extra1 = &zero,
1587 },
1588#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001589#ifdef CONFIG_HIGHMEM
1590 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001591 .procname = "highmem_is_dirtyable",
1592 .data = &vm_highmem_is_dirtyable,
1593 .maxlen = sizeof(vm_highmem_is_dirtyable),
1594 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001595 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001596 .extra1 = &zero,
1597 .extra2 = &one,
1598 },
1599#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001600#ifdef CONFIG_MEMORY_FAILURE
1601 {
Andi Kleen6a460792009-09-16 11:50:15 +02001602 .procname = "memory_failure_early_kill",
1603 .data = &sysctl_memory_failure_early_kill,
1604 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001606 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001607 .extra1 = &zero,
1608 .extra2 = &one,
1609 },
1610 {
Andi Kleen6a460792009-09-16 11:50:15 +02001611 .procname = "memory_failure_recovery",
1612 .data = &sysctl_memory_failure_recovery,
1613 .maxlen = sizeof(sysctl_memory_failure_recovery),
1614 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001615 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001616 .extra1 = &zero,
1617 .extra2 = &one,
1618 },
1619#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001620 {
1621 .procname = "user_reserve_kbytes",
1622 .data = &sysctl_user_reserve_kbytes,
1623 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1624 .mode = 0644,
1625 .proc_handler = proc_doulongvec_minmax,
1626 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001627 {
1628 .procname = "admin_reserve_kbytes",
1629 .data = &sysctl_admin_reserve_kbytes,
1630 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1631 .mode = 0644,
1632 .proc_handler = proc_doulongvec_minmax,
1633 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001634#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1635 {
1636 .procname = "mmap_rnd_bits",
1637 .data = &mmap_rnd_bits,
1638 .maxlen = sizeof(mmap_rnd_bits),
1639 .mode = 0600,
1640 .proc_handler = proc_dointvec_minmax,
1641 .extra1 = (void *)&mmap_rnd_bits_min,
1642 .extra2 = (void *)&mmap_rnd_bits_max,
1643 },
1644#endif
1645#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1646 {
1647 .procname = "mmap_rnd_compat_bits",
1648 .data = &mmap_rnd_compat_bits,
1649 .maxlen = sizeof(mmap_rnd_compat_bits),
1650 .mode = 0600,
1651 .proc_handler = proc_dointvec_minmax,
1652 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1653 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1654 },
1655#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001656 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657};
1658
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001659static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661 .procname = "inode-nr",
1662 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001663 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001665 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 },
1667 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668 .procname = "inode-state",
1669 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001670 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001671 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001672 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 },
1674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001675 .procname = "file-nr",
1676 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001677 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001679 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 },
1681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682 .procname = "file-max",
1683 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001684 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001686 .proc_handler = proc_doulongvec_minmax,
Will Deacon3141fcc2019-04-05 18:39:38 -07001687 .extra1 = &zero_ul,
Christian Brauner6b65c262019-03-07 16:29:43 -08001688 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001689 },
1690 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001691 .procname = "nr_open",
1692 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001693 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001694 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001695 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001696 .extra1 = &sysctl_nr_open_min,
1697 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001698 },
1699 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700 .procname = "dentry-state",
1701 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001702 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001704 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705 },
1706 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707 .procname = "overflowuid",
1708 .data = &fs_overflowuid,
1709 .maxlen = sizeof(int),
1710 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001711 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712 .extra1 = &minolduid,
1713 .extra2 = &maxolduid,
1714 },
1715 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716 .procname = "overflowgid",
1717 .data = &fs_overflowgid,
1718 .maxlen = sizeof(int),
1719 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001720 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721 .extra1 = &minolduid,
1722 .extra2 = &maxolduid,
1723 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001724#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726 .procname = "leases-enable",
1727 .data = &leases_enable,
1728 .maxlen = sizeof(int),
1729 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001730 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001732#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733#ifdef CONFIG_DNOTIFY
1734 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735 .procname = "dir-notify-enable",
1736 .data = &dir_notify_enable,
1737 .maxlen = sizeof(int),
1738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001739 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 },
1741#endif
1742#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001743#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001744 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745 .procname = "lease-break-time",
1746 .data = &lease_break_time,
1747 .maxlen = sizeof(int),
1748 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001749 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001751#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001752#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 .procname = "aio-nr",
1755 .data = &aio_nr,
1756 .maxlen = sizeof(aio_nr),
1757 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001758 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001759 },
1760 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761 .procname = "aio-max-nr",
1762 .data = &aio_max_nr,
1763 .maxlen = sizeof(aio_max_nr),
1764 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001765 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001767#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001768#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001769 {
Robert Love0399cb02005-07-13 12:38:18 -04001770 .procname = "inotify",
1771 .mode = 0555,
1772 .child = inotify_table,
1773 },
1774#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001775#ifdef CONFIG_EPOLL
1776 {
1777 .procname = "epoll",
1778 .mode = 0555,
1779 .child = epoll_table,
1780 },
1781#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001783 {
Kees Cook800179c2012-07-25 17:29:07 -07001784 .procname = "protected_symlinks",
1785 .data = &sysctl_protected_symlinks,
1786 .maxlen = sizeof(int),
1787 .mode = 0600,
1788 .proc_handler = proc_dointvec_minmax,
1789 .extra1 = &zero,
1790 .extra2 = &one,
1791 },
1792 {
1793 .procname = "protected_hardlinks",
1794 .data = &sysctl_protected_hardlinks,
1795 .maxlen = sizeof(int),
1796 .mode = 0600,
1797 .proc_handler = proc_dointvec_minmax,
1798 .extra1 = &zero,
1799 .extra2 = &one,
1800 },
1801 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07001802 .procname = "protected_fifos",
1803 .data = &sysctl_protected_fifos,
1804 .maxlen = sizeof(int),
1805 .mode = 0600,
1806 .proc_handler = proc_dointvec_minmax,
1807 .extra1 = &zero,
1808 .extra2 = &two,
1809 },
1810 {
1811 .procname = "protected_regular",
1812 .data = &sysctl_protected_regular,
1813 .maxlen = sizeof(int),
1814 .mode = 0600,
1815 .proc_handler = proc_dointvec_minmax,
1816 .extra1 = &zero,
1817 .extra2 = &two,
1818 },
1819 {
Alan Coxd6e71142005-06-23 00:09:43 -07001820 .procname = "suid_dumpable",
1821 .data = &suid_dumpable,
1822 .maxlen = sizeof(int),
1823 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001824 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001825 .extra1 = &zero,
1826 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001827 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001828#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1829 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001830 .procname = "binfmt_misc",
1831 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001832 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001833 },
1834#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001835 {
Jens Axboeff9da692010-06-03 14:54:39 +02001836 .procname = "pipe-max-size",
1837 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001838 .maxlen = sizeof(int),
1839 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001840 .proc_handler = &pipe_proc_fn,
1841 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001842 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001843 {
1844 .procname = "pipe-user-pages-hard",
1845 .data = &pipe_user_pages_hard,
1846 .maxlen = sizeof(pipe_user_pages_hard),
1847 .mode = 0644,
1848 .proc_handler = proc_doulongvec_minmax,
1849 },
1850 {
1851 .procname = "pipe-user-pages-soft",
1852 .data = &pipe_user_pages_soft,
1853 .maxlen = sizeof(pipe_user_pages_soft),
1854 .mode = 0644,
1855 .proc_handler = proc_doulongvec_minmax,
1856 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001857 {
1858 .procname = "mount-max",
1859 .data = &sysctl_mount_max,
1860 .maxlen = sizeof(unsigned int),
1861 .mode = 0644,
1862 .proc_handler = proc_dointvec_minmax,
1863 .extra1 = &one,
1864 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001865 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001866};
1867
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001868static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001869#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001870 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001871 .procname = "exception-trace",
1872 .data = &show_unhandled_signals,
1873 .maxlen = sizeof(int),
1874 .mode = 0644,
1875 .proc_handler = proc_dointvec
1876 },
1877#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001878#if defined(CONFIG_OPTPROBES)
1879 {
1880 .procname = "kprobes-optimization",
1881 .data = &sysctl_kprobes_optimization,
1882 .maxlen = sizeof(int),
1883 .mode = 0644,
1884 .proc_handler = proc_kprobes_optimization_handler,
1885 .extra1 = &zero,
1886 .extra2 = &one,
1887 },
1888#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001889 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001890};
1891
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001892static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001893 { }
Robert Love0eeca282005-07-12 17:06:03 -04001894};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001896int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001897{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001898 struct ctl_table_header *hdr;
1899
1900 hdr = register_sysctl_table(sysctl_base_table);
1901 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001902 return 0;
1903}
1904
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001905#endif /* CONFIG_SYSCTL */
1906
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907/*
1908 * /proc/sys support
1909 */
1910
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001911#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001912
Kees Cookf8808302014-06-06 14:37:17 -07001913static int _proc_do_string(char *data, int maxlen, int write,
1914 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001915 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001916{
1917 size_t len;
1918 char __user *p;
1919 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001920
1921 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001922 *lenp = 0;
1923 return 0;
1924 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001925
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001926 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001927 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1928 /* Only continue writes not past the end of buffer. */
1929 len = strlen(data);
1930 if (len > maxlen - 1)
1931 len = maxlen - 1;
1932
1933 if (*ppos > len)
1934 return 0;
1935 len = *ppos;
1936 } else {
1937 /* Start writing from beginning of buffer. */
1938 len = 0;
1939 }
1940
Kees Cook2ca9bb42014-06-06 14:37:18 -07001941 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001942 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001943 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001944 if (get_user(c, p++))
1945 return -EFAULT;
1946 if (c == 0 || c == '\n')
1947 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001948 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001949 }
Kees Cookf8808302014-06-06 14:37:17 -07001950 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001951 } else {
1952 len = strlen(data);
1953 if (len > maxlen)
1954 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001955
1956 if (*ppos > len) {
1957 *lenp = 0;
1958 return 0;
1959 }
1960
1961 data += *ppos;
1962 len -= *ppos;
1963
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001964 if (len > *lenp)
1965 len = *lenp;
1966 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001967 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001968 return -EFAULT;
1969 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001970 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001971 return -EFAULT;
1972 len++;
1973 }
1974 *lenp = len;
1975 *ppos += len;
1976 }
1977 return 0;
1978}
1979
Kees Cookf4aacea2014-06-06 14:37:19 -07001980static void warn_sysctl_write(struct ctl_table *table)
1981{
1982 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1983 "This will not be supported in the future. To silence this\n"
1984 "warning, set kernel.sysctl_writes_strict = -1\n",
1985 current->comm, table->procname);
1986}
1987
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988/**
1989 * proc_dostring - read a string sysctl
1990 * @table: the sysctl table
1991 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001992 * @buffer: the user buffer
1993 * @lenp: the size of the user buffer
1994 * @ppos: file position
1995 *
1996 * Reads/writes a string from/to the user buffer. If the kernel
1997 * buffer provided is not large enough to hold the string, the
1998 * string is truncated. The copied string is %NULL-terminated.
1999 * If the string is being read by the user process, it is copied
2000 * and a newline '\n' is added. It is truncated if the buffer is
2001 * not large enough.
2002 *
2003 * Returns 0 on success.
2004 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002005int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006 void __user *buffer, size_t *lenp, loff_t *ppos)
2007{
Kees Cookf4aacea2014-06-06 14:37:19 -07002008 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2009 warn_sysctl_write(table);
2010
Kees Cookf8808302014-06-06 14:37:17 -07002011 return _proc_do_string((char *)(table->data), table->maxlen, write,
2012 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013}
2014
Amerigo Wang00b7c332010-05-05 00:26:45 +00002015static size_t proc_skip_spaces(char **buf)
2016{
2017 size_t ret;
2018 char *tmp = skip_spaces(*buf);
2019 ret = tmp - *buf;
2020 *buf = tmp;
2021 return ret;
2022}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002024static void proc_skip_char(char **buf, size_t *size, const char v)
2025{
2026 while (*size) {
2027 if (**buf != v)
2028 break;
2029 (*size)--;
2030 (*buf)++;
2031 }
2032}
2033
Amerigo Wang00b7c332010-05-05 00:26:45 +00002034#define TMPBUFLEN 22
2035/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002036 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002037 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002038 * @buf: a kernel buffer
2039 * @size: size of the kernel buffer
2040 * @val: this is where the number will be stored
2041 * @neg: set to %TRUE if number is negative
2042 * @perm_tr: a vector which contains the allowed trailers
2043 * @perm_tr_len: size of the perm_tr vector
2044 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002045 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002046 * In case of success %0 is returned and @buf and @size are updated with
2047 * the amount of bytes read. If @tr is non-NULL and a trailing
2048 * character exists (size is non-zero after returning from this
2049 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002050 */
2051static int proc_get_long(char **buf, size_t *size,
2052 unsigned long *val, bool *neg,
2053 const char *perm_tr, unsigned perm_tr_len, char *tr)
2054{
2055 int len;
2056 char *p, tmp[TMPBUFLEN];
2057
2058 if (!*size)
2059 return -EINVAL;
2060
2061 len = *size;
2062 if (len > TMPBUFLEN - 1)
2063 len = TMPBUFLEN - 1;
2064
2065 memcpy(tmp, *buf, len);
2066
2067 tmp[len] = 0;
2068 p = tmp;
2069 if (*p == '-' && *size > 1) {
2070 *neg = true;
2071 p++;
2072 } else
2073 *neg = false;
2074 if (!isdigit(*p))
2075 return -EINVAL;
2076
2077 *val = simple_strtoul(p, &p, 0);
2078
2079 len = p - tmp;
2080
2081 /* We don't know if the next char is whitespace thus we may accept
2082 * invalid integers (e.g. 1234...a) or two integers instead of one
2083 * (e.g. 123...1). So lets not allow such large numbers. */
2084 if (len == TMPBUFLEN - 1)
2085 return -EINVAL;
2086
2087 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2088 return -EINVAL;
2089
2090 if (tr && (len < *size))
2091 *tr = *p;
2092
2093 *buf += len;
2094 *size -= len;
2095
2096 return 0;
2097}
2098
2099/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002100 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002101 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002102 * @buf: the user buffer
2103 * @size: the size of the user buffer
2104 * @val: the integer to be converted
2105 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002106 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002107 * In case of success %0 is returned and @buf and @size are updated with
2108 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002109 */
2110static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2111 bool neg)
2112{
2113 int len;
2114 char tmp[TMPBUFLEN], *p = tmp;
2115
2116 sprintf(p, "%s%lu", neg ? "-" : "", val);
2117 len = strlen(tmp);
2118 if (len > *size)
2119 len = *size;
2120 if (copy_to_user(*buf, tmp, len))
2121 return -EFAULT;
2122 *size -= len;
2123 *buf += len;
2124 return 0;
2125}
2126#undef TMPBUFLEN
2127
2128static int proc_put_char(void __user **buf, size_t *size, char c)
2129{
2130 if (*size) {
2131 char __user **buffer = (char __user **)buf;
2132 if (put_user(c, *buffer))
2133 return -EFAULT;
2134 (*size)--, (*buffer)++;
2135 *buf = *buffer;
2136 }
2137 return 0;
2138}
2139
2140static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002141 int *valp,
2142 int write, void *data)
2143{
2144 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002145 if (*negp) {
2146 if (*lvalp > (unsigned long) INT_MAX + 1)
2147 return -EINVAL;
2148 *valp = -*lvalp;
2149 } else {
2150 if (*lvalp > (unsigned long) INT_MAX)
2151 return -EINVAL;
2152 *valp = *lvalp;
2153 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154 } else {
2155 int val = *valp;
2156 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002157 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002158 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002160 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002161 *lvalp = (unsigned long)val;
2162 }
2163 }
2164 return 0;
2165}
2166
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002167static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2168 int *valp,
2169 int write, void *data)
2170{
2171 if (write) {
2172 if (*negp)
2173 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002174 if (*lvalp > UINT_MAX)
2175 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002176 *valp = *lvalp;
2177 } else {
2178 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002179 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002180 *lvalp = (unsigned long)val;
2181 }
2182 return 0;
2183}
2184
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2186
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002187static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002188 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002189 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002190 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 int write, void *data),
2192 void *data)
2193{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002194 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002195 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002196 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197
Amerigo Wang00b7c332010-05-05 00:26:45 +00002198 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199 *lenp = 0;
2200 return 0;
2201 }
2202
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002203 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 vleft = table->maxlen / sizeof(*i);
2205 left = *lenp;
2206
2207 if (!conv)
2208 conv = do_proc_dointvec_conv;
2209
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002211 if (*ppos) {
2212 switch (sysctl_writes_strict) {
2213 case SYSCTL_WRITES_STRICT:
2214 goto out;
2215 case SYSCTL_WRITES_WARN:
2216 warn_sysctl_write(table);
2217 break;
2218 default:
2219 break;
2220 }
2221 }
2222
Amerigo Wang00b7c332010-05-05 00:26:45 +00002223 if (left > PAGE_SIZE - 1)
2224 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002225 p = kbuf = memdup_user_nul(buffer, left);
2226 if (IS_ERR(kbuf))
2227 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002228 }
2229
2230 for (; left && vleft--; i++, first=0) {
2231 unsigned long lval;
2232 bool neg;
2233
2234 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002235 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236
J. R. Okajima563b0462010-05-25 16:10:14 -07002237 if (!left)
2238 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002239 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002240 proc_wspace_sep,
2241 sizeof(proc_wspace_sep), NULL);
2242 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002244 if (conv(&neg, &lval, i, 1, data)) {
2245 err = -EINVAL;
2246 break;
2247 }
2248 } else {
2249 if (conv(&neg, &lval, i, 0, data)) {
2250 err = -EINVAL;
2251 break;
2252 }
2253 if (!first)
2254 err = proc_put_char(&buffer, &left, '\t');
2255 if (err)
2256 break;
2257 err = proc_put_long(&buffer, &left, lval, neg);
2258 if (err)
2259 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260 }
2261 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002262
2263 if (!write && !first && left && !err)
2264 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002265 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002266 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002267 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002268 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002269 if (first)
2270 return err ? : -EINVAL;
2271 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002273out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002275 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276}
2277
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002278static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002279 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002280 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002281 int write, void *data),
2282 void *data)
2283{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002284 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002285 buffer, lenp, ppos, conv, data);
2286}
2287
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288/**
2289 * proc_dointvec - read a vector of integers
2290 * @table: the sysctl table
2291 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 * @buffer: the user buffer
2293 * @lenp: the size of the user buffer
2294 * @ppos: file position
2295 *
2296 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2297 * values from/to the user buffer, treated as an ASCII string.
2298 *
2299 * Returns 0 on success.
2300 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002301int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 void __user *buffer, size_t *lenp, loff_t *ppos)
2303{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002304 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2305}
2306
2307/**
2308 * proc_douintvec - read a vector of unsigned integers
2309 * @table: the sysctl table
2310 * @write: %TRUE if this is a write to the sysctl file
2311 * @buffer: the user buffer
2312 * @lenp: the size of the user buffer
2313 * @ppos: file position
2314 *
2315 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2316 * values from/to the user buffer, treated as an ASCII string.
2317 *
2318 * Returns 0 on success.
2319 */
2320int proc_douintvec(struct ctl_table *table, int write,
2321 void __user *buffer, size_t *lenp, loff_t *ppos)
2322{
2323 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2324 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325}
2326
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002327/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002328 * Taint values can only be increased
2329 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002330 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002331static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002332 void __user *buffer, size_t *lenp, loff_t *ppos)
2333{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002334 struct ctl_table t;
2335 unsigned long tmptaint = get_taint();
2336 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002337
Bastian Blank91fcd412007-04-23 14:41:14 -07002338 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002339 return -EPERM;
2340
Andi Kleen25ddbb12008-10-15 22:01:41 -07002341 t = *table;
2342 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002343 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002344 if (err < 0)
2345 return err;
2346
2347 if (write) {
2348 /*
2349 * Poor man's atomic or. Not worth adding a primitive
2350 * to everyone's atomic.h for this
2351 */
2352 int i;
2353 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2354 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302355 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002356 }
2357 }
2358
2359 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002360}
2361
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002362#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002363static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002364 void __user *buffer, size_t *lenp, loff_t *ppos)
2365{
2366 if (write && !capable(CAP_SYS_ADMIN))
2367 return -EPERM;
2368
2369 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2370}
2371#endif
2372
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373struct do_proc_dointvec_minmax_conv_param {
2374 int *min;
2375 int *max;
2376};
2377
Amerigo Wang00b7c332010-05-05 00:26:45 +00002378static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2379 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380 int write, void *data)
2381{
2382 struct do_proc_dointvec_minmax_conv_param *param = data;
2383 if (write) {
Zev Weiss45a67f12019-03-11 23:28:02 -07002384 int val;
2385 if (*negp) {
2386 if (*lvalp > (unsigned long) INT_MAX + 1)
2387 return -EINVAL;
2388 val = -*lvalp;
2389 } else {
2390 if (*lvalp > (unsigned long) INT_MAX)
2391 return -EINVAL;
2392 val = *lvalp;
2393 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 if ((param->min && *param->min > val) ||
2395 (param->max && *param->max < val))
2396 return -EINVAL;
2397 *valp = val;
2398 } else {
2399 int val = *valp;
2400 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002401 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002402 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002404 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 *lvalp = (unsigned long)val;
2406 }
2407 }
2408 return 0;
2409}
2410
2411/**
2412 * proc_dointvec_minmax - read a vector of integers with min/max values
2413 * @table: the sysctl table
2414 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002415 * @buffer: the user buffer
2416 * @lenp: the size of the user buffer
2417 * @ppos: file position
2418 *
2419 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2420 * values from/to the user buffer, treated as an ASCII string.
2421 *
2422 * This routine will ensure the values are within the range specified by
2423 * table->extra1 (min) and table->extra2 (max).
2424 *
2425 * Returns 0 on success.
2426 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002427int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 void __user *buffer, size_t *lenp, loff_t *ppos)
2429{
2430 struct do_proc_dointvec_minmax_conv_param param = {
2431 .min = (int *) table->extra1,
2432 .max = (int *) table->extra2,
2433 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002434 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 do_proc_dointvec_minmax_conv, &param);
2436}
2437
Kees Cook54b50192012-07-30 14:39:18 -07002438static void validate_coredump_safety(void)
2439{
Alex Kelly046d6622012-10-04 17:15:23 -07002440#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002441 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002442 core_pattern[0] != '/' && core_pattern[0] != '|') {
2443 printk(KERN_WARNING "Unsafe core_pattern used with "\
2444 "suid_dumpable=2. Pipe handler or fully qualified "\
2445 "core dump path required.\n");
2446 }
Alex Kelly046d6622012-10-04 17:15:23 -07002447#endif
Kees Cook54b50192012-07-30 14:39:18 -07002448}
2449
2450static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2451 void __user *buffer, size_t *lenp, loff_t *ppos)
2452{
2453 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2454 if (!error)
2455 validate_coredump_safety();
2456 return error;
2457}
2458
Alex Kelly046d6622012-10-04 17:15:23 -07002459#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002460static int proc_dostring_coredump(struct ctl_table *table, int write,
2461 void __user *buffer, size_t *lenp, loff_t *ppos)
2462{
2463 int error = proc_dostring(table, write, buffer, lenp, ppos);
2464 if (!error)
2465 validate_coredump_safety();
2466 return error;
2467}
Alex Kelly046d6622012-10-04 17:15:23 -07002468#endif
Kees Cook54b50192012-07-30 14:39:18 -07002469
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002470static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 void __user *buffer,
2472 size_t *lenp, loff_t *ppos,
2473 unsigned long convmul,
2474 unsigned long convdiv)
2475{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002476 unsigned long *i, *min, *max;
2477 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002478 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002479 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002480
2481 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482 *lenp = 0;
2483 return 0;
2484 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002485
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002486 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487 min = (unsigned long *) table->extra1;
2488 max = (unsigned long *) table->extra2;
2489 vleft = table->maxlen / sizeof(unsigned long);
2490 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002491
2492 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002493 if (*ppos) {
2494 switch (sysctl_writes_strict) {
2495 case SYSCTL_WRITES_STRICT:
2496 goto out;
2497 case SYSCTL_WRITES_WARN:
2498 warn_sysctl_write(table);
2499 break;
2500 default:
2501 break;
2502 }
2503 }
2504
Amerigo Wang00b7c332010-05-05 00:26:45 +00002505 if (left > PAGE_SIZE - 1)
2506 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002507 p = kbuf = memdup_user_nul(buffer, left);
2508 if (IS_ERR(kbuf))
2509 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002510 }
2511
Eric Dumazet27b3d802010-10-07 12:59:29 -07002512 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002513 unsigned long val;
2514
Linus Torvalds1da177e2005-04-16 15:20:36 -07002515 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002516 bool neg;
2517
Al Viro70f6cbb2015-12-24 00:13:10 -05002518 left -= proc_skip_spaces(&p);
Cheng Lin0e5c7502019-01-03 15:26:13 -08002519 if (!left)
2520 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002521
Al Viro70f6cbb2015-12-24 00:13:10 -05002522 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002523 proc_wspace_sep,
2524 sizeof(proc_wspace_sep), NULL);
2525 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526 break;
2527 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002529 val = convmul * val / convdiv;
Christian Brauner726f69d2019-05-14 15:44:55 -07002530 if ((min && val < *min) || (max && val > *max)) {
2531 err = -EINVAL;
2532 break;
2533 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534 *i = val;
2535 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002536 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002537 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002538 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002539 if (err)
2540 break;
2541 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002542 err = proc_put_long(&buffer, &left, val, false);
2543 if (err)
2544 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545 }
2546 }
2547
Amerigo Wang00b7c332010-05-05 00:26:45 +00002548 if (!write && !first && left && !err)
2549 err = proc_put_char(&buffer, &left, '\n');
2550 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002551 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002553 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002554 if (first)
2555 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002558out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002560 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561}
2562
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002563static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002564 void __user *buffer,
2565 size_t *lenp, loff_t *ppos,
2566 unsigned long convmul,
2567 unsigned long convdiv)
2568{
2569 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002570 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002571}
2572
Linus Torvalds1da177e2005-04-16 15:20:36 -07002573/**
2574 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2575 * @table: the sysctl table
2576 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577 * @buffer: the user buffer
2578 * @lenp: the size of the user buffer
2579 * @ppos: file position
2580 *
2581 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2582 * values from/to the user buffer, treated as an ASCII string.
2583 *
2584 * This routine will ensure the values are within the range specified by
2585 * table->extra1 (min) and table->extra2 (max).
2586 *
2587 * Returns 0 on success.
2588 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002589int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 void __user *buffer, size_t *lenp, loff_t *ppos)
2591{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002592 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593}
2594
2595/**
2596 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2597 * @table: the sysctl table
2598 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 * @buffer: the user buffer
2600 * @lenp: the size of the user buffer
2601 * @ppos: file position
2602 *
2603 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2604 * values from/to the user buffer, treated as an ASCII string. The values
2605 * are treated as milliseconds, and converted to jiffies when they are stored.
2606 *
2607 * This routine will ensure the values are within the range specified by
2608 * table->extra1 (min) and table->extra2 (max).
2609 *
2610 * Returns 0 on success.
2611 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002612int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 void __user *buffer,
2614 size_t *lenp, loff_t *ppos)
2615{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002616 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617 lenp, ppos, HZ, 1000l);
2618}
2619
2620
Amerigo Wang00b7c332010-05-05 00:26:45 +00002621static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 int *valp,
2623 int write, void *data)
2624{
2625 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002626 if (*lvalp > LONG_MAX / HZ)
2627 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2629 } else {
2630 int val = *valp;
2631 unsigned long lval;
2632 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002633 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002634 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002636 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002637 lval = (unsigned long)val;
2638 }
2639 *lvalp = lval / HZ;
2640 }
2641 return 0;
2642}
2643
Amerigo Wang00b7c332010-05-05 00:26:45 +00002644static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 int *valp,
2646 int write, void *data)
2647{
2648 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002649 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2650 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2652 } else {
2653 int val = *valp;
2654 unsigned long lval;
2655 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002656 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002657 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002659 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 lval = (unsigned long)val;
2661 }
2662 *lvalp = jiffies_to_clock_t(lval);
2663 }
2664 return 0;
2665}
2666
Amerigo Wang00b7c332010-05-05 00:26:45 +00002667static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668 int *valp,
2669 int write, void *data)
2670{
2671 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002672 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2673
2674 if (jif > INT_MAX)
2675 return 1;
2676 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 } else {
2678 int val = *valp;
2679 unsigned long lval;
2680 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002681 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002682 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002684 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685 lval = (unsigned long)val;
2686 }
2687 *lvalp = jiffies_to_msecs(lval);
2688 }
2689 return 0;
2690}
2691
2692/**
2693 * proc_dointvec_jiffies - read a vector of integers as seconds
2694 * @table: the sysctl table
2695 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002696 * @buffer: the user buffer
2697 * @lenp: the size of the user buffer
2698 * @ppos: file position
2699 *
2700 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2701 * values from/to the user buffer, treated as an ASCII string.
2702 * The values read are assumed to be in seconds, and are converted into
2703 * jiffies.
2704 *
2705 * Returns 0 on success.
2706 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002707int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002708 void __user *buffer, size_t *lenp, loff_t *ppos)
2709{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002710 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002711 do_proc_dointvec_jiffies_conv,NULL);
2712}
2713
2714/**
2715 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2716 * @table: the sysctl table
2717 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 * @buffer: the user buffer
2719 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002720 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002721 *
2722 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2723 * values from/to the user buffer, treated as an ASCII string.
2724 * The values read are assumed to be in 1/USER_HZ seconds, and
2725 * are converted into jiffies.
2726 *
2727 * Returns 0 on success.
2728 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002729int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730 void __user *buffer, size_t *lenp, loff_t *ppos)
2731{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002732 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733 do_proc_dointvec_userhz_jiffies_conv,NULL);
2734}
2735
2736/**
2737 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2738 * @table: the sysctl table
2739 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002740 * @buffer: the user buffer
2741 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002742 * @ppos: file position
2743 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002744 *
2745 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2746 * values from/to the user buffer, treated as an ASCII string.
2747 * The values read are assumed to be in 1/1000 seconds, and
2748 * are converted into jiffies.
2749 *
2750 * Returns 0 on success.
2751 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002752int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002753 void __user *buffer, size_t *lenp, loff_t *ppos)
2754{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002755 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002756 do_proc_dointvec_ms_jiffies_conv, NULL);
2757}
2758
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002759static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002760 void __user *buffer, size_t *lenp, loff_t *ppos)
2761{
2762 struct pid *new_pid;
2763 pid_t tmp;
2764 int r;
2765
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002766 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002767
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002768 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002769 lenp, ppos, NULL, NULL);
2770 if (r || !write)
2771 return r;
2772
2773 new_pid = find_get_pid(tmp);
2774 if (!new_pid)
2775 return -ESRCH;
2776
2777 put_pid(xchg(&cad_pid, new_pid));
2778 return 0;
2779}
2780
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002781/**
2782 * proc_do_large_bitmap - read/write from/to a large bitmap
2783 * @table: the sysctl table
2784 * @write: %TRUE if this is a write to the sysctl file
2785 * @buffer: the user buffer
2786 * @lenp: the size of the user buffer
2787 * @ppos: file position
2788 *
2789 * The bitmap is stored at table->data and the bitmap length (in bits)
2790 * in table->maxlen.
2791 *
2792 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2793 * large bitmaps may be represented in a compact manner. Writing into
2794 * the file will clear the bitmap then update it with the given input.
2795 *
2796 * Returns 0 on success.
2797 */
2798int proc_do_large_bitmap(struct ctl_table *table, int write,
2799 void __user *buffer, size_t *lenp, loff_t *ppos)
2800{
2801 int err = 0;
2802 bool first = 1;
2803 size_t left = *lenp;
2804 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002805 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002806 unsigned long *tmp_bitmap = NULL;
2807 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2808
WANG Cong122ff242014-05-12 16:04:53 -07002809 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002810 *lenp = 0;
2811 return 0;
2812 }
2813
2814 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002815 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002816
2817 if (left > PAGE_SIZE - 1)
2818 left = PAGE_SIZE - 1;
2819
Al Viro70f6cbb2015-12-24 00:13:10 -05002820 p = kbuf = memdup_user_nul(buffer, left);
2821 if (IS_ERR(kbuf))
2822 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002823
2824 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2825 GFP_KERNEL);
2826 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002827 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002828 return -ENOMEM;
2829 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002830 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002831 while (!err && left) {
2832 unsigned long val_a, val_b;
2833 bool neg;
2834
Al Viro70f6cbb2015-12-24 00:13:10 -05002835 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002836 sizeof(tr_a), &c);
2837 if (err)
2838 break;
2839 if (val_a >= bitmap_len || neg) {
2840 err = -EINVAL;
2841 break;
2842 }
2843
2844 val_b = val_a;
2845 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002846 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002847 left--;
2848 }
2849
2850 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002851 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002852 &neg, tr_b, sizeof(tr_b),
2853 &c);
2854 if (err)
2855 break;
2856 if (val_b >= bitmap_len || neg ||
2857 val_a > val_b) {
2858 err = -EINVAL;
2859 break;
2860 }
2861 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002862 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002863 left--;
2864 }
2865 }
2866
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002867 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002868 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002869 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002870 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002871 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002872 } else {
2873 unsigned long bit_a, bit_b = 0;
2874
2875 while (left) {
2876 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2877 if (bit_a >= bitmap_len)
2878 break;
2879 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2880 bit_a + 1) - 1;
2881
2882 if (!first) {
2883 err = proc_put_char(&buffer, &left, ',');
2884 if (err)
2885 break;
2886 }
2887 err = proc_put_long(&buffer, &left, bit_a, false);
2888 if (err)
2889 break;
2890 if (bit_a != bit_b) {
2891 err = proc_put_char(&buffer, &left, '-');
2892 if (err)
2893 break;
2894 err = proc_put_long(&buffer, &left, bit_b, false);
2895 if (err)
2896 break;
2897 }
2898
2899 first = 0; bit_b++;
2900 }
2901 if (!err)
2902 err = proc_put_char(&buffer, &left, '\n');
2903 }
2904
2905 if (!err) {
2906 if (write) {
2907 if (*ppos)
2908 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2909 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002910 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002911 }
2912 kfree(tmp_bitmap);
2913 *lenp -= left;
2914 *ppos += *lenp;
2915 return 0;
2916 } else {
2917 kfree(tmp_bitmap);
2918 return err;
2919 }
2920}
2921
Jovi Zhang55610502011-01-12 17:00:45 -08002922#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002923
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002924int proc_dostring(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
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002930int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002931 void __user *buffer, size_t *lenp, loff_t *ppos)
2932{
2933 return -ENOSYS;
2934}
2935
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002936int proc_douintvec(struct ctl_table *table, int write,
2937 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_minmax(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_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_userhz_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_dointvec_ms_jiffies(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
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002966int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967 void __user *buffer, size_t *lenp, loff_t *ppos)
2968{
2969 return -ENOSYS;
2970}
2971
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002972int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002973 void __user *buffer,
2974 size_t *lenp, loff_t *ppos)
2975{
2976 return -ENOSYS;
2977}
2978
2979
Jovi Zhang55610502011-01-12 17:00:45 -08002980#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002981
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982/*
2983 * No sense putting this after each symbol definition, twice,
2984 * exception granted :-)
2985 */
2986EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002987EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002988EXPORT_SYMBOL(proc_dointvec_jiffies);
2989EXPORT_SYMBOL(proc_dointvec_minmax);
2990EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2991EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2992EXPORT_SYMBOL(proc_dostring);
2993EXPORT_SYMBOL(proc_doulongvec_minmax);
2994EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);