blob: dea7e5546e279a7ae2aa610e0b70da3332c6ee8c [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;
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700126static int __maybe_unused three = 3;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700127static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800128static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700130static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700131#ifdef CONFIG_PRINTK
132static int ten_thousand = 10000;
133#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300134#ifdef CONFIG_PERF_EVENTS
135static int six_hundred_forty_kb = 640 * 1024;
136#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700137
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700138/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
139static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
142static int maxolduid = 65535;
143static int minolduid;
144
145static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700146static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Liu Hua80df2842014-04-07 15:38:57 -0700148/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
149#ifdef CONFIG_DETECT_HUNG_TASK
150static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
151#endif
152
Dave Youngd14f1722010-02-25 20:28:57 -0500153#ifdef CONFIG_INOTIFY_USER
154#include <linux/inotify.h>
155#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700156#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#endif
158
159#ifdef __hppa__
160extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530161#endif
162
163#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164extern int unaligned_enabled;
165#endif
166
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800168extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800169#endif
170
Vineet Guptab6fca722013-01-09 20:06:28 +0530171#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
172extern int no_unaligned_warning;
173#endif
174
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700175#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700176
177#define SYSCTL_WRITES_LEGACY -1
178#define SYSCTL_WRITES_WARN 0
179#define SYSCTL_WRITES_STRICT 1
180
Kees Cook41662f52016-01-20 15:00:45 -0800181static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700182
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700183static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700184 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700185static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800186 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700187#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700188
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700189#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700190static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700191 void __user *buffer, size_t *lenp, loff_t *ppos);
192#endif
193
Kees Cook54b50192012-07-30 14:39:18 -0700194static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
195 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700196#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700197static int proc_dostring_coredump(struct ctl_table *table, int write,
198 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700199#endif
Kees Cook54b50192012-07-30 14:39:18 -0700200
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700201#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800202/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100203static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700204
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700205static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700206 void __user *buffer, size_t *lenp,
207 loff_t *ppos)
208{
209 int error;
210
211 error = proc_dointvec(table, write, buffer, lenp, ppos);
212 if (error)
213 return error;
214
215 if (write)
216 sysrq_toggle_support(__sysrq_enabled);
217
218 return 0;
219}
220
221#endif
222
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700223static struct ctl_table kern_table[];
224static struct ctl_table vm_table[];
225static struct ctl_table fs_table[];
226static struct ctl_table debug_table[];
227static struct ctl_table dev_table[];
228extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800229#ifdef CONFIG_EPOLL
230extern struct ctl_table epoll_table[];
231#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
233#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
234int sysctl_legacy_va_layout;
235#endif
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237/* The default sysctl tables: */
238
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800239static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 .procname = "kernel",
242 .mode = 0555,
243 .child = kern_table,
244 },
245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .procname = "vm",
247 .mode = 0555,
248 .child = vm_table,
249 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 .procname = "fs",
252 .mode = 0555,
253 .child = fs_table,
254 },
255 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 .procname = "debug",
257 .mode = 0555,
258 .child = debug_table,
259 },
260 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 .procname = "dev",
262 .mode = 0555,
263 .child = dev_table,
264 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700265 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266};
267
Ingo Molnar77e54a12007-07-09 18:52:00 +0200268#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100269static int min_sched_granularity_ns = 100000; /* 100 usecs */
270static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
271static int min_wakeup_granularity_ns; /* 0 usecs */
272static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200273#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100274static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
275static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200276#endif /* CONFIG_SMP */
277#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200278
Mel Gorman5e771902010-05-24 14:32:31 -0700279#ifdef CONFIG_COMPACTION
280static int min_extfrag_threshold;
281static int max_extfrag_threshold = 1000;
282#endif
283
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700284static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200285 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200286 .procname = "sched_child_runs_first",
287 .data = &sysctl_sched_child_runs_first,
288 .maxlen = sizeof(unsigned int),
289 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800290 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200291 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800292#ifdef CONFIG_SCHED_WALT
293 {
294 .procname = "sched_cpu_high_irqload",
295 .data = &sysctl_sched_cpu_high_irqload,
296 .maxlen = sizeof(unsigned int),
297 .mode = 0644,
298 .proc_handler = proc_dointvec,
299 },
Joonwoo Park6f188472017-06-16 11:32:17 -0700300 {
301 .procname = "sched_group_upmigrate",
302 .data = &sysctl_sched_group_upmigrate_pct,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700305 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700306 .extra1 = &sysctl_sched_group_downmigrate_pct,
307 },
308 {
309 .procname = "sched_group_downmigrate",
310 .data = &sysctl_sched_group_downmigrate_pct,
311 .maxlen = sizeof(unsigned int),
312 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700313 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700314 .extra1 = &zero,
315 .extra2 = &sysctl_sched_group_upmigrate_pct,
316 },
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530317 {
318 .procname = "sched_boost",
319 .data = &sysctl_sched_boost,
320 .maxlen = sizeof(unsigned int),
321 .mode = 0644,
322 .proc_handler = sched_boost_handler,
323 .extra1 = &zero,
324 .extra2 = &three,
325 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800326#endif
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530327 {
328 .procname = "sched_upmigrate",
329 .data = &sysctl_sched_capacity_margin,
330 .maxlen = sizeof(unsigned int),
331 .mode = 0644,
332 .proc_handler = sched_updown_migrate_handler,
333 },
334 {
335 .procname = "sched_downmigrate",
336 .data = &sysctl_sched_capacity_margin_down,
337 .maxlen = sizeof(unsigned int),
338 .mode = 0644,
339 .proc_handler = sched_updown_migrate_handler,
340 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200341#ifdef CONFIG_SCHED_DEBUG
342 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100343 .procname = "sched_min_granularity_ns",
344 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200345 .maxlen = sizeof(unsigned int),
346 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800347 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100348 .extra1 = &min_sched_granularity_ns,
349 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200350 },
351 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200352 .procname = "sched_latency_ns",
353 .data = &sysctl_sched_latency,
354 .maxlen = sizeof(unsigned int),
355 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800356 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200357 .extra1 = &min_sched_granularity_ns,
358 .extra2 = &max_sched_granularity_ns,
359 },
360 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000361 .procname = "sched_sync_hint_enable",
362 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100363 .maxlen = sizeof(unsigned int),
364 .mode = 0644,
365 .proc_handler = proc_dointvec,
366 },
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -0700367#ifdef CONFIG_SCHED_WALT
368 {
369 .procname = "sched_use_walt_cpu_util",
370 .data = &sysctl_sched_use_walt_cpu_util,
371 .maxlen = sizeof(unsigned int),
372 .mode = 0644,
373 .proc_handler = proc_dointvec,
374 },
375 {
376 .procname = "sched_use_walt_task_util",
377 .data = &sysctl_sched_use_walt_task_util,
378 .maxlen = sizeof(unsigned int),
379 .mode = 0644,
380 .proc_handler = proc_dointvec,
381 },
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -0700382#endif
Juri Lelli1931b932016-07-29 14:04:11 +0100383 {
Todd Kjosc6a6f3b2016-03-11 16:44:16 -0800384 .procname = "sched_initial_task_util",
385 .data = &sysctl_sched_initial_task_util,
386 .maxlen = sizeof(unsigned int),
387 .mode = 0644,
388 .proc_handler = proc_dointvec,
389 },
390 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100391 .procname = "sched_cstate_aware",
392 .data = &sysctl_sched_cstate_aware,
393 .maxlen = sizeof(unsigned int),
394 .mode = 0644,
395 .proc_handler = proc_dointvec,
396 },
397 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200398 .procname = "sched_wakeup_granularity_ns",
399 .data = &sysctl_sched_wakeup_granularity,
400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800402 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200403 .extra1 = &min_wakeup_granularity_ns,
404 .extra2 = &max_wakeup_granularity_ns,
405 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200406#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200407 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100408 .procname = "sched_tunable_scaling",
409 .data = &sysctl_sched_tunable_scaling,
410 .maxlen = sizeof(enum sched_tunable_scaling),
411 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800412 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100413 .extra1 = &min_sched_tunable_scaling,
414 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200415 },
416 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900417 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200418 .data = &sysctl_sched_migration_cost,
419 .maxlen = sizeof(unsigned int),
420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800421 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200422 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100423 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100424 .procname = "sched_nr_migrate",
425 .data = &sysctl_sched_nr_migrate,
426 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100427 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800428 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100429 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530430 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900431 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200432 .data = &sysctl_sched_time_avg,
433 .maxlen = sizeof(unsigned int),
434 .mode = 0644,
Pavankumar Kondeti12939492017-02-02 14:24:34 +0530435 .proc_handler = proc_dointvec_minmax,
436 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200437 },
438 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900439 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800440 .data = &sysctl_sched_shares_window,
441 .maxlen = sizeof(unsigned int),
442 .mode = 0644,
443 .proc_handler = proc_dointvec,
444 },
Mel Gormancb251762016-02-05 09:08:36 +0000445#ifdef CONFIG_SCHEDSTATS
446 {
447 .procname = "sched_schedstats",
448 .data = NULL,
449 .maxlen = sizeof(unsigned int),
450 .mode = 0644,
451 .proc_handler = sysctl_schedstats,
452 .extra1 = &zero,
453 .extra2 = &one,
454 },
455#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200456#endif /* CONFIG_SMP */
457#ifdef CONFIG_NUMA_BALANCING
458 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200459 .procname = "numa_balancing_scan_delay_ms",
460 .data = &sysctl_numa_balancing_scan_delay,
461 .maxlen = sizeof(unsigned int),
462 .mode = 0644,
463 .proc_handler = proc_dointvec,
464 },
465 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200466 .procname = "numa_balancing_scan_period_min_ms",
467 .data = &sysctl_numa_balancing_scan_period_min,
468 .maxlen = sizeof(unsigned int),
469 .mode = 0644,
470 .proc_handler = proc_dointvec,
471 },
472 {
473 .procname = "numa_balancing_scan_period_max_ms",
474 .data = &sysctl_numa_balancing_scan_period_max,
475 .maxlen = sizeof(unsigned int),
476 .mode = 0644,
477 .proc_handler = proc_dointvec,
478 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200479 {
480 .procname = "numa_balancing_scan_size_mb",
481 .data = &sysctl_numa_balancing_scan_size,
482 .maxlen = sizeof(unsigned int),
483 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400484 .proc_handler = proc_dointvec_minmax,
485 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200486 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100487 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800488 .procname = "numa_balancing",
489 .data = NULL, /* filled in by handler */
490 .maxlen = sizeof(unsigned int),
491 .mode = 0644,
492 .proc_handler = sysctl_numa_balancing,
493 .extra1 = &zero,
494 .extra2 = &one,
495 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200496#endif /* CONFIG_NUMA_BALANCING */
497#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200498 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100499 .procname = "sched_rt_period_us",
500 .data = &sysctl_sched_rt_period,
501 .maxlen = sizeof(unsigned int),
502 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800503 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100504 },
505 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100506 .procname = "sched_rt_runtime_us",
507 .data = &sysctl_sched_rt_runtime,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800510 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100511 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600512 {
513 .procname = "sched_rr_timeslice_ms",
514 .data = &sched_rr_timeslice,
515 .maxlen = sizeof(int),
516 .mode = 0644,
517 .proc_handler = sched_rr_handler,
518 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100519#ifdef CONFIG_SCHED_AUTOGROUP
520 {
521 .procname = "sched_autogroup_enabled",
522 .data = &sysctl_sched_autogroup_enabled,
523 .maxlen = sizeof(unsigned int),
524 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800525 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100526 .extra1 = &zero,
527 .extra2 = &one,
528 },
529#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700530#ifdef CONFIG_CFS_BANDWIDTH
531 {
532 .procname = "sched_cfs_bandwidth_slice_us",
533 .data = &sysctl_sched_cfs_bandwidth_slice,
534 .maxlen = sizeof(unsigned int),
535 .mode = 0644,
536 .proc_handler = proc_dointvec_minmax,
537 .extra1 = &one,
538 },
539#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100540#ifdef CONFIG_SCHED_TUNE
541 {
542 .procname = "sched_cfs_boost",
543 .data = &sysctl_sched_cfs_boost,
544 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100545#ifdef CONFIG_CGROUP_SCHEDTUNE
546 .mode = 0444,
547#else
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100548 .mode = 0644,
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100549#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100550 .proc_handler = &sysctl_sched_cfs_boost_handler,
551 .extra1 = &zero,
552 .extra2 = &one_hundred,
553 },
554#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700555#ifdef CONFIG_PROVE_LOCKING
556 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700557 .procname = "prove_locking",
558 .data = &prove_locking,
559 .maxlen = sizeof(int),
560 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800561 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700562 },
563#endif
564#ifdef CONFIG_LOCK_STAT
565 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700566 .procname = "lock_stat",
567 .data = &lock_stat,
568 .maxlen = sizeof(int),
569 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800570 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700571 },
572#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200573 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 .procname = "panic",
575 .data = &panic_timeout,
576 .maxlen = sizeof(int),
577 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800578 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 },
Alex Kelly046d6622012-10-04 17:15:23 -0700580#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 .procname = "core_uses_pid",
583 .data = &core_uses_pid,
584 .maxlen = sizeof(int),
585 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800586 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 },
588 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 .procname = "core_pattern",
590 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700591 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700593 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 },
Neil Hormana2939802009-09-23 15:56:56 -0700595 {
Neil Hormana2939802009-09-23 15:56:56 -0700596 .procname = "core_pipe_limit",
597 .data = &core_pipe_limit,
598 .maxlen = sizeof(unsigned int),
599 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800600 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700601 },
Alex Kelly046d6622012-10-04 17:15:23 -0700602#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800603#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700606 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800608 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700610 {
611 .procname = "sysctl_writes_strict",
612 .data = &sysctl_writes_strict,
613 .maxlen = sizeof(int),
614 .mode = 0644,
615 .proc_handler = proc_dointvec_minmax,
616 .extra1 = &neg_one,
617 .extra2 = &one,
618 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800619#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100620#ifdef CONFIG_LATENCYTOP
621 {
622 .procname = "latencytop",
623 .data = &latencytop_enabled,
624 .maxlen = sizeof(int),
625 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000626 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100627 },
628#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629#ifdef CONFIG_BLK_DEV_INITRD
630 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 .procname = "real-root-dev",
632 .data = &real_root_dev,
633 .maxlen = sizeof(int),
634 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800635 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 },
637#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700638 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700639 .procname = "print-fatal-signals",
640 .data = &print_fatal_signals,
641 .maxlen = sizeof(int),
642 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800643 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700644 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700645#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 .procname = "reboot-cmd",
648 .data = reboot_command,
649 .maxlen = 256,
650 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800651 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 },
653 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .procname = "stop-a",
655 .data = &stop_a_enabled,
656 .maxlen = sizeof (int),
657 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800658 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 },
660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "scons-poweroff",
662 .data = &scons_pwroff,
663 .maxlen = sizeof (int),
664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 },
667#endif
David S. Miller08714202008-11-16 23:49:24 -0800668#ifdef CONFIG_SPARC64
669 {
David S. Miller08714202008-11-16 23:49:24 -0800670 .procname = "tsb-ratio",
671 .data = &sysctl_tsb_ratio,
672 .maxlen = sizeof (int),
673 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800674 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800675 },
676#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677#ifdef __hppa__
678 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .procname = "soft-power",
680 .data = &pwrsw_enabled,
681 .maxlen = sizeof (int),
682 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530685#endif
686#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 .procname = "unaligned-trap",
689 .data = &unaligned_enabled,
690 .maxlen = sizeof (int),
691 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800692 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 },
694#endif
695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 .procname = "ctrl-alt-del",
697 .data = &C_A_D,
698 .maxlen = sizeof(int),
699 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800700 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400702#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200703 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200704 .procname = "ftrace_enabled",
705 .data = &ftrace_enabled,
706 .maxlen = sizeof(int),
707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200709 },
710#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500711#ifdef CONFIG_STACK_TRACER
712 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500713 .procname = "stack_tracer_enabled",
714 .data = &stack_tracer_enabled,
715 .maxlen = sizeof(int),
716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800717 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500718 },
719#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400720#ifdef CONFIG_TRACING
721 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100722 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400723 .data = &ftrace_dump_on_oops,
724 .maxlen = sizeof(int),
725 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800726 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400727 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400728 {
729 .procname = "traceoff_on_warning",
730 .data = &__disable_trace_on_warning,
731 .maxlen = sizeof(__disable_trace_on_warning),
732 .mode = 0644,
733 .proc_handler = proc_dointvec,
734 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500735 {
736 .procname = "tracepoint_printk",
737 .data = &tracepoint_printk,
738 .maxlen = sizeof(tracepoint_printk),
739 .mode = 0644,
740 .proc_handler = proc_dointvec,
741 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400742#endif
Dave Young2965faa2015-09-09 15:38:55 -0700743#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800744 {
745 .procname = "kexec_load_disabled",
746 .data = &kexec_load_disabled,
747 .maxlen = sizeof(int),
748 .mode = 0644,
749 /* only handle a transition from default "0" to "1" */
750 .proc_handler = proc_dointvec_minmax,
751 .extra1 = &one,
752 .extra2 = &one,
753 },
754#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200755#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .procname = "modprobe",
758 .data = &modprobe_path,
759 .maxlen = KMOD_PATH_LEN,
760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800761 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 },
Kees Cook3d433212009-04-02 15:49:29 -0700763 {
Kees Cook3d433212009-04-02 15:49:29 -0700764 .procname = "modules_disabled",
765 .data = &modules_disabled,
766 .maxlen = sizeof(int),
767 .mode = 0644,
768 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800769 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700770 .extra1 = &one,
771 .extra2 = &one,
772 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700774#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100777 .data = &uevent_helper,
778 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800780 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 },
Michael Marineau86d56132014-04-10 14:09:31 -0700782#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783#ifdef CONFIG_CHR_DEV_SG
784 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 .procname = "sg-big-buff",
786 .data = &sg_big_buff,
787 .maxlen = sizeof (int),
788 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800789 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 },
791#endif
792#ifdef CONFIG_BSD_PROCESS_ACCT
793 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 .procname = "acct",
795 .data = &acct_parm,
796 .maxlen = 3*sizeof(int),
797 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800798 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 },
800#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801#ifdef CONFIG_MAGIC_SYSRQ
802 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800804 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 .maxlen = sizeof (int),
806 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700807 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 },
809#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700810#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700813 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 .maxlen = sizeof (int),
815 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800816 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700818#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700821 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 .maxlen = sizeof(int),
823 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700824 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 },
826 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 .procname = "random",
828 .mode = 0555,
829 .child = random_table,
830 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 {
Eric Paris17f60a72011-04-01 17:07:50 -0400832 .procname = "usermodehelper",
833 .mode = 0555,
834 .child = usermodehelper_table,
835 },
836 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 .procname = "overflowuid",
838 .data = &overflowuid,
839 .maxlen = sizeof(int),
840 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800841 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 .extra1 = &minolduid,
843 .extra2 = &maxolduid,
844 },
845 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 .procname = "overflowgid",
847 .data = &overflowgid,
848 .maxlen = sizeof(int),
849 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800850 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 .extra1 = &minolduid,
852 .extra2 = &maxolduid,
853 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800854#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855#ifdef CONFIG_MATHEMU
856 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 .procname = "ieee_emulation_warnings",
858 .data = &sysctl_ieee_emulation_warnings,
859 .maxlen = sizeof(int),
860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 },
863#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200866 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 .maxlen = sizeof(int),
868 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800869 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 },
871#endif
872 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 .procname = "pid_max",
874 .data = &pid_max,
875 .maxlen = sizeof (int),
876 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800877 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 .extra1 = &pid_max_min,
879 .extra2 = &pid_max_max,
880 },
881 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 .procname = "panic_on_oops",
883 .data = &panic_on_oops,
884 .maxlen = sizeof(int),
885 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800886 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800888#if defined CONFIG_PRINTK
889 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800890 .procname = "printk",
891 .data = &console_loglevel,
892 .maxlen = 4*sizeof(int),
893 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800894 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800895 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700898 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 .maxlen = sizeof(int),
900 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800901 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 },
903 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700905 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 .maxlen = sizeof(int),
907 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800908 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 },
Dave Youngaf913222009-09-22 16:43:33 -0700910 {
Dave Youngaf913222009-09-22 16:43:33 -0700911 .procname = "printk_delay",
912 .data = &printk_delay_msec,
913 .maxlen = sizeof(int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700916 .extra1 = &zero,
917 .extra2 = &ten_thousand,
918 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700920 .procname = "printk_devkmsg",
921 .data = devkmsg_log_str,
922 .maxlen = DEVKMSG_STR_MAX_SIZE,
923 .mode = 0644,
924 .proc_handler = devkmsg_sysctl_set_loglvl,
925 },
926 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800927 .procname = "dmesg_restrict",
928 .data = &dmesg_restrict,
929 .maxlen = sizeof(int),
930 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700931 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800932 .extra1 = &zero,
933 .extra2 = &one,
934 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800935 {
936 .procname = "kptr_restrict",
937 .data = &kptr_restrict,
938 .maxlen = sizeof(int),
939 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700940 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800941 .extra1 = &zero,
942 .extra2 = &two,
943 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800944#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800945 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 .procname = "ngroups_max",
947 .data = &ngroups_max,
948 .maxlen = sizeof (int),
949 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800950 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 },
Dan Ballard73efc032011-10-31 17:11:20 -0700952 {
953 .procname = "cap_last_cap",
954 .data = (void *)&cap_last_cap,
955 .maxlen = sizeof(int),
956 .mode = 0444,
957 .proc_handler = proc_dointvec,
958 },
Don Zickus58687ac2010-05-07 17:11:44 -0400959#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500960 {
Don Zickus58687ac2010-05-07 17:11:44 -0400961 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200962 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500963 .maxlen = sizeof (int),
964 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700965 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700966 .extra1 = &zero,
967 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400968 },
969 {
970 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700971 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400972 .maxlen = sizeof(int),
973 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700974 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800975 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400976 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500977 },
Don Zickus2508ce12010-05-07 17:11:46 -0400978 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700979 .procname = "nmi_watchdog",
980 .data = &nmi_watchdog_enabled,
981 .maxlen = sizeof (int),
982 .mode = 0644,
983 .proc_handler = proc_nmi_watchdog,
984 .extra1 = &zero,
985#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
986 .extra2 = &one,
987#else
988 .extra2 = &zero,
989#endif
990 },
991 {
992 .procname = "soft_watchdog",
993 .data = &soft_watchdog_enabled,
994 .maxlen = sizeof (int),
995 .mode = 0644,
996 .proc_handler = proc_soft_watchdog,
997 .extra1 = &zero,
998 .extra2 = &one,
999 },
1000 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001001 .procname = "watchdog_cpumask",
1002 .data = &watchdog_cpumask_bits,
1003 .maxlen = NR_CPUS,
1004 .mode = 0644,
1005 .proc_handler = proc_watchdog_cpumask,
1006 },
1007 {
Don Zickus2508ce12010-05-07 17:11:46 -04001008 .procname = "softlockup_panic",
1009 .data = &softlockup_panic,
1010 .maxlen = sizeof(int),
1011 .mode = 0644,
1012 .proc_handler = proc_dointvec_minmax,
1013 .extra1 = &zero,
1014 .extra2 = &one,
1015 },
Don Zickusac1f5912015-11-05 18:44:44 -08001016#ifdef CONFIG_HARDLOCKUP_DETECTOR
1017 {
1018 .procname = "hardlockup_panic",
1019 .data = &hardlockup_panic,
1020 .maxlen = sizeof(int),
1021 .mode = 0644,
1022 .proc_handler = proc_dointvec_minmax,
1023 .extra1 = &zero,
1024 .extra2 = &one,
1025 },
1026#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001027#ifdef CONFIG_SMP
1028 {
1029 .procname = "softlockup_all_cpu_backtrace",
1030 .data = &sysctl_softlockup_all_cpu_backtrace,
1031 .maxlen = sizeof(int),
1032 .mode = 0644,
1033 .proc_handler = proc_dointvec_minmax,
1034 .extra1 = &zero,
1035 .extra2 = &one,
1036 },
Jiri Kosina55537872015-11-05 18:44:41 -08001037 {
1038 .procname = "hardlockup_all_cpu_backtrace",
1039 .data = &sysctl_hardlockup_all_cpu_backtrace,
1040 .maxlen = sizeof(int),
1041 .mode = 0644,
1042 .proc_handler = proc_dointvec_minmax,
1043 .extra1 = &zero,
1044 .extra2 = &one,
1045 },
Aaron Tomlined235872014-06-23 13:22:05 -07001046#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001047#endif
1048#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1049 {
1050 .procname = "unknown_nmi_panic",
1051 .data = &unknown_nmi_panic,
1052 .maxlen = sizeof (int),
1053 .mode = 0644,
1054 .proc_handler = proc_dointvec,
1055 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001056#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057#if defined(CONFIG_X86)
1058 {
Don Zickus8da5add2006-09-26 10:52:27 +02001059 .procname = "panic_on_unrecovered_nmi",
1060 .data = &panic_on_unrecovered_nmi,
1061 .maxlen = sizeof(int),
1062 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001063 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001064 },
1065 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001066 .procname = "panic_on_io_nmi",
1067 .data = &panic_on_io_nmi,
1068 .maxlen = sizeof(int),
1069 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001070 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001071 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001072#ifdef CONFIG_DEBUG_STACKOVERFLOW
1073 {
1074 .procname = "panic_on_stackoverflow",
1075 .data = &sysctl_panic_on_stackoverflow,
1076 .maxlen = sizeof(int),
1077 .mode = 0644,
1078 .proc_handler = proc_dointvec,
1079 },
1080#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001081 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 .procname = "bootloader_type",
1083 .data = &bootloader_type,
1084 .maxlen = sizeof (int),
1085 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001086 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001088 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001089 .procname = "bootloader_version",
1090 .data = &bootloader_version,
1091 .maxlen = sizeof (int),
1092 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001093 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001094 },
1095 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001096 .procname = "kstack_depth_to_print",
1097 .data = &kstack_depth_to_print,
1098 .maxlen = sizeof(int),
1099 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001100 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001101 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001102 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001103 .procname = "io_delay_type",
1104 .data = &io_delay_type,
1105 .maxlen = sizeof(int),
1106 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001107 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001108 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001110#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001111 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 .procname = "randomize_va_space",
1113 .data = &randomize_va_space,
1114 .maxlen = sizeof(int),
1115 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001116 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001118#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001119#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001120 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001121 .procname = "spin_retry",
1122 .data = &spin_retry,
1123 .maxlen = sizeof (int),
1124 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001125 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001126 },
1127#endif
Len Brown673d5b42007-07-28 03:33:16 -04001128#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001129 {
Pavel Machekc255d842006-02-20 18:27:58 -08001130 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001131 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001132 .maxlen = sizeof (unsigned long),
1133 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001134 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001135 },
1136#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301137#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001138 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001139 .procname = "ignore-unaligned-usertrap",
1140 .data = &no_unaligned_warning,
1141 .maxlen = sizeof (int),
1142 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001143 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001144 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301145#endif
1146#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001147 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001148 .procname = "unaligned-dump-stack",
1149 .data = &unaligned_dump_stack,
1150 .maxlen = sizeof (int),
1151 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001152 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001153 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001154#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001155#ifdef CONFIG_DETECT_HUNG_TASK
1156 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001157 .procname = "hung_task_panic",
1158 .data = &sysctl_hung_task_panic,
1159 .maxlen = sizeof(int),
1160 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001161 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001162 .extra1 = &zero,
1163 .extra2 = &one,
1164 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001165 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001166 .procname = "hung_task_check_count",
1167 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001168 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001169 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001170 .proc_handler = proc_dointvec_minmax,
1171 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001172 },
1173 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001174 .procname = "hung_task_timeout_secs",
1175 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001176 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001177 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001178 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001179 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001180 },
1181 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001182 .procname = "hung_task_warnings",
1183 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001184 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001185 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001186 .proc_handler = proc_dointvec_minmax,
1187 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001188 },
Imran Khana9788f42017-09-18 15:48:30 +05301189 {
1190 .procname = "hung_task_selective_monitoring",
1191 .data = &sysctl_hung_task_selective_monitoring,
1192 .maxlen = sizeof(int),
1193 .mode = 0644,
1194 .proc_handler = proc_dointvec_minmax,
1195 .extra1 = &zero,
1196 .extra2 = &one,
1197 },
1198
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001199#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001200#ifdef CONFIG_RT_MUTEXES
1201 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001202 .procname = "max_lock_depth",
1203 .data = &max_lock_depth,
1204 .maxlen = sizeof(int),
1205 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001206 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001207 },
1208#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001209 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001210 .procname = "poweroff_cmd",
1211 .data = &poweroff_cmd,
1212 .maxlen = POWEROFF_CMD_PATH_LEN,
1213 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001214 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001215 },
David Howells0b77f5b2008-04-29 01:01:32 -07001216#ifdef CONFIG_KEYS
1217 {
David Howells0b77f5b2008-04-29 01:01:32 -07001218 .procname = "keys",
1219 .mode = 0555,
1220 .child = key_sysctls,
1221 },
1222#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001223#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001224 /*
1225 * User-space scripts rely on the existence of this file
1226 * as a feature check for perf_events being enabled.
1227 *
1228 * So it's an ABI, do not remove!
1229 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001230 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001231 .procname = "perf_event_paranoid",
1232 .data = &sysctl_perf_event_paranoid,
1233 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001234 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001235 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001236 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001237 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001238 .procname = "perf_event_mlock_kb",
1239 .data = &sysctl_perf_event_mlock,
1240 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001241 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001242 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001243 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001244 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001245 .procname = "perf_event_max_sample_rate",
1246 .data = &sysctl_perf_event_sample_rate,
1247 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001248 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001249 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001250 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001251 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001252 {
1253 .procname = "perf_cpu_time_max_percent",
1254 .data = &sysctl_perf_cpu_time_max_percent,
1255 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1256 .mode = 0644,
1257 .proc_handler = perf_cpu_time_max_percent_handler,
1258 .extra1 = &zero,
1259 .extra2 = &one_hundred,
1260 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001261 {
1262 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001263 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001264 .maxlen = sizeof(sysctl_perf_event_max_stack),
1265 .mode = 0644,
1266 .proc_handler = perf_event_max_stack_handler,
1267 .extra1 = &zero,
1268 .extra2 = &six_hundred_forty_kb,
1269 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001270 {
1271 .procname = "perf_event_max_contexts_per_stack",
1272 .data = &sysctl_perf_event_max_contexts_per_stack,
1273 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1274 .mode = 0644,
1275 .proc_handler = perf_event_max_stack_handler,
1276 .extra1 = &zero,
1277 .extra2 = &one_thousand,
1278 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001279#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001280#ifdef CONFIG_KMEMCHECK
1281 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001282 .procname = "kmemcheck",
1283 .data = &kmemcheck_enabled,
1284 .maxlen = sizeof(int),
1285 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001286 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001287 },
1288#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001289 {
1290 .procname = "panic_on_warn",
1291 .data = &panic_on_warn,
1292 .maxlen = sizeof(int),
1293 .mode = 0644,
1294 .proc_handler = proc_dointvec_minmax,
1295 .extra1 = &zero,
1296 .extra2 = &one,
1297 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001298#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1299 {
1300 .procname = "timer_migration",
1301 .data = &sysctl_timer_migration,
1302 .maxlen = sizeof(unsigned int),
1303 .mode = 0644,
1304 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001305 .extra1 = &zero,
1306 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001307 },
1308#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001309#ifdef CONFIG_BPF_SYSCALL
1310 {
1311 .procname = "unprivileged_bpf_disabled",
1312 .data = &sysctl_unprivileged_bpf_disabled,
1313 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1314 .mode = 0644,
1315 /* only handle a transition from default "0" to "1" */
1316 .proc_handler = proc_dointvec_minmax,
1317 .extra1 = &one,
1318 .extra2 = &one,
1319 },
1320#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001321#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1322 {
1323 .procname = "panic_on_rcu_stall",
1324 .data = &sysctl_panic_on_rcu_stall,
1325 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1326 .mode = 0644,
1327 .proc_handler = proc_dointvec_minmax,
1328 .extra1 = &zero,
1329 .extra2 = &one,
1330 },
1331#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001332#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001333 {
1334 .procname = "boot_reason",
1335 .data = &boot_reason,
1336 .maxlen = sizeof(int),
1337 .mode = 0444,
1338 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001339 },
1340
1341 {
1342 .procname = "cold_boot",
1343 .data = &cold_boot,
1344 .maxlen = sizeof(int),
1345 .mode = 0444,
1346 .proc_handler = proc_dointvec,
1347 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001348#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001349 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350};
1351
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001352static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001354 .procname = "overcommit_memory",
1355 .data = &sysctl_overcommit_memory,
1356 .maxlen = sizeof(sysctl_overcommit_memory),
1357 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001358 .proc_handler = proc_dointvec_minmax,
1359 .extra1 = &zero,
1360 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 },
1362 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001363 .procname = "panic_on_oom",
1364 .data = &sysctl_panic_on_oom,
1365 .maxlen = sizeof(sysctl_panic_on_oom),
1366 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001367 .proc_handler = proc_dointvec_minmax,
1368 .extra1 = &zero,
1369 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001370 },
1371 {
David Rientjesfe071d72007-10-16 23:25:56 -07001372 .procname = "oom_kill_allocating_task",
1373 .data = &sysctl_oom_kill_allocating_task,
1374 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001376 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001377 },
1378 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001379 .procname = "oom_dump_tasks",
1380 .data = &sysctl_oom_dump_tasks,
1381 .maxlen = sizeof(sysctl_oom_dump_tasks),
1382 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001383 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001384 },
1385 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 .procname = "overcommit_ratio",
1387 .data = &sysctl_overcommit_ratio,
1388 .maxlen = sizeof(sysctl_overcommit_ratio),
1389 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001390 .proc_handler = overcommit_ratio_handler,
1391 },
1392 {
1393 .procname = "overcommit_kbytes",
1394 .data = &sysctl_overcommit_kbytes,
1395 .maxlen = sizeof(sysctl_overcommit_kbytes),
1396 .mode = 0644,
1397 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 },
1399 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400 .procname = "page-cluster",
1401 .data = &page_cluster,
1402 .maxlen = sizeof(int),
1403 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001404 .proc_handler = proc_dointvec_minmax,
1405 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 },
1407 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408 .procname = "dirty_background_ratio",
1409 .data = &dirty_background_ratio,
1410 .maxlen = sizeof(dirty_background_ratio),
1411 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001412 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 .extra1 = &zero,
1414 .extra2 = &one_hundred,
1415 },
1416 {
David Rientjes2da02992009-01-06 14:39:31 -08001417 .procname = "dirty_background_bytes",
1418 .data = &dirty_background_bytes,
1419 .maxlen = sizeof(dirty_background_bytes),
1420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001421 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001422 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001423 },
1424 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425 .procname = "dirty_ratio",
1426 .data = &vm_dirty_ratio,
1427 .maxlen = sizeof(vm_dirty_ratio),
1428 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001429 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 .extra1 = &zero,
1431 .extra2 = &one_hundred,
1432 },
1433 {
David Rientjes2da02992009-01-06 14:39:31 -08001434 .procname = "dirty_bytes",
1435 .data = &vm_dirty_bytes,
1436 .maxlen = sizeof(vm_dirty_bytes),
1437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001439 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001440 },
1441 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001443 .data = &dirty_writeback_interval,
1444 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001446 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 },
1448 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001450 .data = &dirty_expire_interval,
1451 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001453 .proc_handler = proc_dointvec_minmax,
1454 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 },
1456 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001457 .procname = "dirtytime_expire_seconds",
1458 .data = &dirtytime_expire_interval,
1459 .maxlen = sizeof(dirty_expire_interval),
1460 .mode = 0644,
1461 .proc_handler = dirtytime_interval_handler,
1462 .extra1 = &zero,
1463 },
1464 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001465 .procname = "nr_pdflush_threads",
1466 .mode = 0444 /* read-only */,
1467 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 },
1469 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 .procname = "swappiness",
1471 .data = &vm_swappiness,
1472 .maxlen = sizeof(vm_swappiness),
1473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001474 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475 .extra1 = &zero,
1476 .extra2 = &one_hundred,
1477 },
1478#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001481 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 .maxlen = sizeof(unsigned long),
1483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001484 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001485 },
1486#ifdef CONFIG_NUMA
1487 {
1488 .procname = "nr_hugepages_mempolicy",
1489 .data = NULL,
1490 .maxlen = sizeof(unsigned long),
1491 .mode = 0644,
1492 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001493 },
1494#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 .procname = "hugetlb_shm_group",
1497 .data = &sysctl_hugetlb_shm_group,
1498 .maxlen = sizeof(gid_t),
1499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001500 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 },
Mel Gorman396faf02007-07-17 04:03:13 -07001502 {
Mel Gorman396faf02007-07-17 04:03:13 -07001503 .procname = "hugepages_treat_as_movable",
1504 .data = &hugepages_treat_as_movable,
1505 .maxlen = sizeof(int),
1506 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001507 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001508 },
Adam Litke54f9f802007-10-16 01:26:20 -07001509 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001510 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001511 .data = NULL,
1512 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001514 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001515 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516#endif
1517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 .procname = "lowmem_reserve_ratio",
1519 .data = &sysctl_lowmem_reserve_ratio,
1520 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001522 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 },
1524 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001525 .procname = "drop_caches",
1526 .data = &sysctl_drop_caches,
1527 .maxlen = sizeof(int),
1528 .mode = 0644,
1529 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001530 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001531 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001532 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001533#ifdef CONFIG_COMPACTION
1534 {
1535 .procname = "compact_memory",
1536 .data = &sysctl_compact_memory,
1537 .maxlen = sizeof(int),
1538 .mode = 0200,
1539 .proc_handler = sysctl_compaction_handler,
1540 },
Mel Gorman5e771902010-05-24 14:32:31 -07001541 {
1542 .procname = "extfrag_threshold",
1543 .data = &sysctl_extfrag_threshold,
1544 .maxlen = sizeof(int),
1545 .mode = 0644,
1546 .proc_handler = sysctl_extfrag_handler,
1547 .extra1 = &min_extfrag_threshold,
1548 .extra2 = &max_extfrag_threshold,
1549 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001550 {
1551 .procname = "compact_unevictable_allowed",
1552 .data = &sysctl_compact_unevictable_allowed,
1553 .maxlen = sizeof(int),
1554 .mode = 0644,
1555 .proc_handler = proc_dointvec,
1556 .extra1 = &zero,
1557 .extra2 = &one,
1558 },
Mel Gorman5e771902010-05-24 14:32:31 -07001559
Mel Gorman76ab0f52010-05-24 14:32:28 -07001560#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001561 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 .procname = "min_free_kbytes",
1563 .data = &min_free_kbytes,
1564 .maxlen = sizeof(min_free_kbytes),
1565 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001566 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 .extra1 = &zero,
1568 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001569 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001570 .procname = "watermark_scale_factor",
1571 .data = &watermark_scale_factor,
1572 .maxlen = sizeof(watermark_scale_factor),
1573 .mode = 0644,
1574 .proc_handler = watermark_scale_factor_sysctl_handler,
1575 .extra1 = &one,
1576 .extra2 = &one_thousand,
1577 },
1578 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001579 .procname = "percpu_pagelist_fraction",
1580 .data = &percpu_pagelist_fraction,
1581 .maxlen = sizeof(percpu_pagelist_fraction),
1582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001583 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001584 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001585 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586#ifdef CONFIG_MMU
1587 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588 .procname = "max_map_count",
1589 .data = &sysctl_max_map_count,
1590 .maxlen = sizeof(sysctl_max_map_count),
1591 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001592 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001593 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001595#else
1596 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001597 .procname = "nr_trim_pages",
1598 .data = &sysctl_nr_trim_pages,
1599 .maxlen = sizeof(sysctl_nr_trim_pages),
1600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001601 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001602 .extra1 = &zero,
1603 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604#endif
1605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001606 .procname = "laptop_mode",
1607 .data = &laptop_mode,
1608 .maxlen = sizeof(laptop_mode),
1609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001610 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001611 },
1612 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001613 .procname = "block_dump",
1614 .data = &block_dump,
1615 .maxlen = sizeof(block_dump),
1616 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001617 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618 .extra1 = &zero,
1619 },
1620 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621 .procname = "vfs_cache_pressure",
1622 .data = &sysctl_vfs_cache_pressure,
1623 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1624 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001625 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001626 .extra1 = &zero,
1627 },
1628#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1629 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630 .procname = "legacy_va_layout",
1631 .data = &sysctl_legacy_va_layout,
1632 .maxlen = sizeof(sysctl_legacy_va_layout),
1633 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001634 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635 .extra1 = &zero,
1636 },
1637#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001638#ifdef CONFIG_NUMA
1639 {
Christoph Lameter17436602006-01-18 17:42:32 -08001640 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001641 .data = &node_reclaim_mode,
1642 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001643 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001644 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001645 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001646 },
Christoph Lameter96146342006-07-03 00:24:13 -07001647 {
Christoph Lameter96146342006-07-03 00:24:13 -07001648 .procname = "min_unmapped_ratio",
1649 .data = &sysctl_min_unmapped_ratio,
1650 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001652 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001653 .extra1 = &zero,
1654 .extra2 = &one_hundred,
1655 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001656 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001657 .procname = "min_slab_ratio",
1658 .data = &sysctl_min_slab_ratio,
1659 .maxlen = sizeof(sysctl_min_slab_ratio),
1660 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001661 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001662 .extra1 = &zero,
1663 .extra2 = &one_hundred,
1664 },
Christoph Lameter17436602006-01-18 17:42:32 -08001665#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001666#ifdef CONFIG_SMP
1667 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001668 .procname = "stat_interval",
1669 .data = &sysctl_stat_interval,
1670 .maxlen = sizeof(sysctl_stat_interval),
1671 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001672 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001673 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001674 {
1675 .procname = "stat_refresh",
1676 .data = NULL,
1677 .maxlen = 0,
1678 .mode = 0600,
1679 .proc_handler = vmstat_refresh,
1680 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001681#endif
David Howells6e141542009-12-15 19:27:45 +00001682#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001683 {
Eric Parised032182007-06-28 15:55:21 -04001684 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001685 .data = &dac_mmap_min_addr,
1686 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001687 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001688 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001689 },
David Howells6e141542009-12-15 19:27:45 +00001690#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001691#ifdef CONFIG_NUMA
1692 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001693 .procname = "numa_zonelist_order",
1694 .data = &numa_zonelist_order,
1695 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001697 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001698 },
1699#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001700#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001701 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001702 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001703 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001704#ifdef CONFIG_X86_32
1705 .data = &vdso32_enabled,
1706 .maxlen = sizeof(vdso32_enabled),
1707#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001708 .data = &vdso_enabled,
1709 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001710#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001711 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001712 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001713 .extra1 = &zero,
1714 },
1715#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001716#ifdef CONFIG_HIGHMEM
1717 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001718 .procname = "highmem_is_dirtyable",
1719 .data = &vm_highmem_is_dirtyable,
1720 .maxlen = sizeof(vm_highmem_is_dirtyable),
1721 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001722 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001723 .extra1 = &zero,
1724 .extra2 = &one,
1725 },
1726#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001727#ifdef CONFIG_MEMORY_FAILURE
1728 {
Andi Kleen6a460792009-09-16 11:50:15 +02001729 .procname = "memory_failure_early_kill",
1730 .data = &sysctl_memory_failure_early_kill,
1731 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1732 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001733 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001734 .extra1 = &zero,
1735 .extra2 = &one,
1736 },
1737 {
Andi Kleen6a460792009-09-16 11:50:15 +02001738 .procname = "memory_failure_recovery",
1739 .data = &sysctl_memory_failure_recovery,
1740 .maxlen = sizeof(sysctl_memory_failure_recovery),
1741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001742 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001743 .extra1 = &zero,
1744 .extra2 = &one,
1745 },
1746#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001747 {
1748 .procname = "user_reserve_kbytes",
1749 .data = &sysctl_user_reserve_kbytes,
1750 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1751 .mode = 0644,
1752 .proc_handler = proc_doulongvec_minmax,
1753 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001754 {
1755 .procname = "admin_reserve_kbytes",
1756 .data = &sysctl_admin_reserve_kbytes,
1757 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1758 .mode = 0644,
1759 .proc_handler = proc_doulongvec_minmax,
1760 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001761#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1762 {
1763 .procname = "mmap_rnd_bits",
1764 .data = &mmap_rnd_bits,
1765 .maxlen = sizeof(mmap_rnd_bits),
1766 .mode = 0600,
1767 .proc_handler = proc_dointvec_minmax,
1768 .extra1 = (void *)&mmap_rnd_bits_min,
1769 .extra2 = (void *)&mmap_rnd_bits_max,
1770 },
1771#endif
1772#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1773 {
1774 .procname = "mmap_rnd_compat_bits",
1775 .data = &mmap_rnd_compat_bits,
1776 .maxlen = sizeof(mmap_rnd_compat_bits),
1777 .mode = 0600,
1778 .proc_handler = proc_dointvec_minmax,
1779 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1780 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1781 },
1782#endif
Vinayak Menonc1c6a992015-12-21 13:00:58 +05301783#ifdef CONFIG_SWAP
1784 {
1785 .procname = "swap_ratio",
1786 .data = &sysctl_swap_ratio,
1787 .maxlen = sizeof(sysctl_swap_ratio),
1788 .mode = 0644,
1789 .proc_handler = proc_dointvec_minmax,
1790 },
1791 {
1792 .procname = "swap_ratio_enable",
1793 .data = &sysctl_swap_ratio_enable,
1794 .maxlen = sizeof(sysctl_swap_ratio_enable),
1795 .mode = 0644,
1796 .proc_handler = proc_dointvec_minmax,
1797 },
1798#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001799 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800};
1801
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001802static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001804 .procname = "inode-nr",
1805 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001806 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001807 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001808 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001809 },
1810 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001811 .procname = "inode-state",
1812 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001813 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001815 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816 },
1817 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818 .procname = "file-nr",
1819 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001820 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001821 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001822 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001823 },
1824 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825 .procname = "file-max",
1826 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001827 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001828 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001829 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830 },
1831 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001832 .procname = "nr_open",
1833 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001834 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001835 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001836 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001837 .extra1 = &sysctl_nr_open_min,
1838 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001839 },
1840 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841 .procname = "dentry-state",
1842 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001843 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001845 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 },
1847 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001848 .procname = "overflowuid",
1849 .data = &fs_overflowuid,
1850 .maxlen = sizeof(int),
1851 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001852 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001853 .extra1 = &minolduid,
1854 .extra2 = &maxolduid,
1855 },
1856 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857 .procname = "overflowgid",
1858 .data = &fs_overflowgid,
1859 .maxlen = sizeof(int),
1860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001861 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 .extra1 = &minolduid,
1863 .extra2 = &maxolduid,
1864 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001865#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001866 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 .procname = "leases-enable",
1868 .data = &leases_enable,
1869 .maxlen = sizeof(int),
1870 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001871 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001873#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874#ifdef CONFIG_DNOTIFY
1875 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 .procname = "dir-notify-enable",
1877 .data = &dir_notify_enable,
1878 .maxlen = sizeof(int),
1879 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001880 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 },
1882#endif
1883#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001884#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001885 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886 .procname = "lease-break-time",
1887 .data = &lease_break_time,
1888 .maxlen = sizeof(int),
1889 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001890 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001892#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001893#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 .procname = "aio-nr",
1896 .data = &aio_nr,
1897 .maxlen = sizeof(aio_nr),
1898 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001899 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001900 },
1901 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 .procname = "aio-max-nr",
1903 .data = &aio_max_nr,
1904 .maxlen = sizeof(aio_max_nr),
1905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001906 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001908#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001909#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001910 {
Robert Love0399cb02005-07-13 12:38:18 -04001911 .procname = "inotify",
1912 .mode = 0555,
1913 .child = inotify_table,
1914 },
1915#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001916#ifdef CONFIG_EPOLL
1917 {
1918 .procname = "epoll",
1919 .mode = 0555,
1920 .child = epoll_table,
1921 },
1922#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001924 {
Kees Cook800179c2012-07-25 17:29:07 -07001925 .procname = "protected_symlinks",
1926 .data = &sysctl_protected_symlinks,
1927 .maxlen = sizeof(int),
1928 .mode = 0600,
1929 .proc_handler = proc_dointvec_minmax,
1930 .extra1 = &zero,
1931 .extra2 = &one,
1932 },
1933 {
1934 .procname = "protected_hardlinks",
1935 .data = &sysctl_protected_hardlinks,
1936 .maxlen = sizeof(int),
1937 .mode = 0600,
1938 .proc_handler = proc_dointvec_minmax,
1939 .extra1 = &zero,
1940 .extra2 = &one,
1941 },
1942 {
Alan Coxd6e71142005-06-23 00:09:43 -07001943 .procname = "suid_dumpable",
1944 .data = &suid_dumpable,
1945 .maxlen = sizeof(int),
1946 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001947 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001948 .extra1 = &zero,
1949 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001950 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001951#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1952 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001953 .procname = "binfmt_misc",
1954 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001955 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001956 },
1957#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001958 {
Jens Axboeff9da692010-06-03 14:54:39 +02001959 .procname = "pipe-max-size",
1960 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001961 .maxlen = sizeof(int),
1962 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001963 .proc_handler = &pipe_proc_fn,
1964 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001965 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001966 {
1967 .procname = "pipe-user-pages-hard",
1968 .data = &pipe_user_pages_hard,
1969 .maxlen = sizeof(pipe_user_pages_hard),
1970 .mode = 0644,
1971 .proc_handler = proc_doulongvec_minmax,
1972 },
1973 {
1974 .procname = "pipe-user-pages-soft",
1975 .data = &pipe_user_pages_soft,
1976 .maxlen = sizeof(pipe_user_pages_soft),
1977 .mode = 0644,
1978 .proc_handler = proc_doulongvec_minmax,
1979 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001980 {
1981 .procname = "mount-max",
1982 .data = &sysctl_mount_max,
1983 .maxlen = sizeof(unsigned int),
1984 .mode = 0644,
1985 .proc_handler = proc_dointvec_minmax,
1986 .extra1 = &one,
1987 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001988 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001989};
1990
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001991static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001992#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001993 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001994 .procname = "exception-trace",
1995 .data = &show_unhandled_signals,
1996 .maxlen = sizeof(int),
1997 .mode = 0644,
1998 .proc_handler = proc_dointvec
1999 },
2000#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002001#if defined(CONFIG_OPTPROBES)
2002 {
2003 .procname = "kprobes-optimization",
2004 .data = &sysctl_kprobes_optimization,
2005 .maxlen = sizeof(int),
2006 .mode = 0644,
2007 .proc_handler = proc_kprobes_optimization_handler,
2008 .extra1 = &zero,
2009 .extra2 = &one,
2010 },
2011#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002012 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013};
2014
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002015static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002016 { }
Robert Love0eeca282005-07-12 17:06:03 -04002017};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002019int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002020{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002021 struct ctl_table_header *hdr;
2022
2023 hdr = register_sysctl_table(sysctl_base_table);
2024 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002025 return 0;
2026}
2027
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002028#endif /* CONFIG_SYSCTL */
2029
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030/*
2031 * /proc/sys support
2032 */
2033
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002034#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035
Kees Cookf8808302014-06-06 14:37:17 -07002036static int _proc_do_string(char *data, int maxlen, int write,
2037 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002038 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002039{
2040 size_t len;
2041 char __user *p;
2042 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002043
2044 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002045 *lenp = 0;
2046 return 0;
2047 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002048
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002049 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002050 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2051 /* Only continue writes not past the end of buffer. */
2052 len = strlen(data);
2053 if (len > maxlen - 1)
2054 len = maxlen - 1;
2055
2056 if (*ppos > len)
2057 return 0;
2058 len = *ppos;
2059 } else {
2060 /* Start writing from beginning of buffer. */
2061 len = 0;
2062 }
2063
Kees Cook2ca9bb42014-06-06 14:37:18 -07002064 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002065 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002066 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002067 if (get_user(c, p++))
2068 return -EFAULT;
2069 if (c == 0 || c == '\n')
2070 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002071 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002072 }
Kees Cookf8808302014-06-06 14:37:17 -07002073 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002074 } else {
2075 len = strlen(data);
2076 if (len > maxlen)
2077 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002078
2079 if (*ppos > len) {
2080 *lenp = 0;
2081 return 0;
2082 }
2083
2084 data += *ppos;
2085 len -= *ppos;
2086
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002087 if (len > *lenp)
2088 len = *lenp;
2089 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002090 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002091 return -EFAULT;
2092 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002093 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002094 return -EFAULT;
2095 len++;
2096 }
2097 *lenp = len;
2098 *ppos += len;
2099 }
2100 return 0;
2101}
2102
Kees Cookf4aacea2014-06-06 14:37:19 -07002103static void warn_sysctl_write(struct ctl_table *table)
2104{
2105 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2106 "This will not be supported in the future. To silence this\n"
2107 "warning, set kernel.sysctl_writes_strict = -1\n",
2108 current->comm, table->procname);
2109}
2110
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111/**
2112 * proc_dostring - read a string sysctl
2113 * @table: the sysctl table
2114 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002115 * @buffer: the user buffer
2116 * @lenp: the size of the user buffer
2117 * @ppos: file position
2118 *
2119 * Reads/writes a string from/to the user buffer. If the kernel
2120 * buffer provided is not large enough to hold the string, the
2121 * string is truncated. The copied string is %NULL-terminated.
2122 * If the string is being read by the user process, it is copied
2123 * and a newline '\n' is added. It is truncated if the buffer is
2124 * not large enough.
2125 *
2126 * Returns 0 on success.
2127 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002128int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129 void __user *buffer, size_t *lenp, loff_t *ppos)
2130{
Kees Cookf4aacea2014-06-06 14:37:19 -07002131 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2132 warn_sysctl_write(table);
2133
Kees Cookf8808302014-06-06 14:37:17 -07002134 return _proc_do_string((char *)(table->data), table->maxlen, write,
2135 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136}
2137
Amerigo Wang00b7c332010-05-05 00:26:45 +00002138static size_t proc_skip_spaces(char **buf)
2139{
2140 size_t ret;
2141 char *tmp = skip_spaces(*buf);
2142 ret = tmp - *buf;
2143 *buf = tmp;
2144 return ret;
2145}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002147static void proc_skip_char(char **buf, size_t *size, const char v)
2148{
2149 while (*size) {
2150 if (**buf != v)
2151 break;
2152 (*size)--;
2153 (*buf)++;
2154 }
2155}
2156
Amerigo Wang00b7c332010-05-05 00:26:45 +00002157#define TMPBUFLEN 22
2158/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002159 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002160 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002161 * @buf: a kernel buffer
2162 * @size: size of the kernel buffer
2163 * @val: this is where the number will be stored
2164 * @neg: set to %TRUE if number is negative
2165 * @perm_tr: a vector which contains the allowed trailers
2166 * @perm_tr_len: size of the perm_tr vector
2167 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002168 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002169 * In case of success %0 is returned and @buf and @size are updated with
2170 * the amount of bytes read. If @tr is non-NULL and a trailing
2171 * character exists (size is non-zero after returning from this
2172 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002173 */
2174static int proc_get_long(char **buf, size_t *size,
2175 unsigned long *val, bool *neg,
2176 const char *perm_tr, unsigned perm_tr_len, char *tr)
2177{
2178 int len;
2179 char *p, tmp[TMPBUFLEN];
2180
2181 if (!*size)
2182 return -EINVAL;
2183
2184 len = *size;
2185 if (len > TMPBUFLEN - 1)
2186 len = TMPBUFLEN - 1;
2187
2188 memcpy(tmp, *buf, len);
2189
2190 tmp[len] = 0;
2191 p = tmp;
2192 if (*p == '-' && *size > 1) {
2193 *neg = true;
2194 p++;
2195 } else
2196 *neg = false;
2197 if (!isdigit(*p))
2198 return -EINVAL;
2199
2200 *val = simple_strtoul(p, &p, 0);
2201
2202 len = p - tmp;
2203
2204 /* We don't know if the next char is whitespace thus we may accept
2205 * invalid integers (e.g. 1234...a) or two integers instead of one
2206 * (e.g. 123...1). So lets not allow such large numbers. */
2207 if (len == TMPBUFLEN - 1)
2208 return -EINVAL;
2209
2210 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2211 return -EINVAL;
2212
2213 if (tr && (len < *size))
2214 *tr = *p;
2215
2216 *buf += len;
2217 *size -= len;
2218
2219 return 0;
2220}
2221
2222/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002223 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002224 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002225 * @buf: the user buffer
2226 * @size: the size of the user buffer
2227 * @val: the integer to be converted
2228 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002229 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002230 * In case of success %0 is returned and @buf and @size are updated with
2231 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002232 */
2233static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2234 bool neg)
2235{
2236 int len;
2237 char tmp[TMPBUFLEN], *p = tmp;
2238
2239 sprintf(p, "%s%lu", neg ? "-" : "", val);
2240 len = strlen(tmp);
2241 if (len > *size)
2242 len = *size;
2243 if (copy_to_user(*buf, tmp, len))
2244 return -EFAULT;
2245 *size -= len;
2246 *buf += len;
2247 return 0;
2248}
2249#undef TMPBUFLEN
2250
2251static int proc_put_char(void __user **buf, size_t *size, char c)
2252{
2253 if (*size) {
2254 char __user **buffer = (char __user **)buf;
2255 if (put_user(c, *buffer))
2256 return -EFAULT;
2257 (*size)--, (*buffer)++;
2258 *buf = *buffer;
2259 }
2260 return 0;
2261}
2262
2263static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002264 int *valp,
2265 int write, void *data)
2266{
2267 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002268 if (*negp) {
2269 if (*lvalp > (unsigned long) INT_MAX + 1)
2270 return -EINVAL;
2271 *valp = -*lvalp;
2272 } else {
2273 if (*lvalp > (unsigned long) INT_MAX)
2274 return -EINVAL;
2275 *valp = *lvalp;
2276 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277 } else {
2278 int val = *valp;
2279 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002280 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002281 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002283 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284 *lvalp = (unsigned long)val;
2285 }
2286 }
2287 return 0;
2288}
2289
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002290static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2291 int *valp,
2292 int write, void *data)
2293{
2294 if (write) {
2295 if (*negp)
2296 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002297 if (*lvalp > UINT_MAX)
2298 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002299 *valp = *lvalp;
2300 } else {
2301 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002302 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002303 *lvalp = (unsigned long)val;
2304 }
2305 return 0;
2306}
2307
Amerigo Wang00b7c332010-05-05 00:26:45 +00002308static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2309
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002310static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002311 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002312 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002313 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 int write, void *data),
2315 void *data)
2316{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002317 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002318 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002319 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320
Amerigo Wang00b7c332010-05-05 00:26:45 +00002321 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 *lenp = 0;
2323 return 0;
2324 }
2325
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002326 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327 vleft = table->maxlen / sizeof(*i);
2328 left = *lenp;
2329
2330 if (!conv)
2331 conv = do_proc_dointvec_conv;
2332
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002334 if (*ppos) {
2335 switch (sysctl_writes_strict) {
2336 case SYSCTL_WRITES_STRICT:
2337 goto out;
2338 case SYSCTL_WRITES_WARN:
2339 warn_sysctl_write(table);
2340 break;
2341 default:
2342 break;
2343 }
2344 }
2345
Amerigo Wang00b7c332010-05-05 00:26:45 +00002346 if (left > PAGE_SIZE - 1)
2347 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002348 p = kbuf = memdup_user_nul(buffer, left);
2349 if (IS_ERR(kbuf))
2350 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002351 }
2352
2353 for (; left && vleft--; i++, first=0) {
2354 unsigned long lval;
2355 bool neg;
2356
2357 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002358 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002359
J. R. Okajima563b0462010-05-25 16:10:14 -07002360 if (!left)
2361 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002362 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002363 proc_wspace_sep,
2364 sizeof(proc_wspace_sep), NULL);
2365 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002367 if (conv(&neg, &lval, i, 1, data)) {
2368 err = -EINVAL;
2369 break;
2370 }
2371 } else {
2372 if (conv(&neg, &lval, i, 0, data)) {
2373 err = -EINVAL;
2374 break;
2375 }
2376 if (!first)
2377 err = proc_put_char(&buffer, &left, '\t');
2378 if (err)
2379 break;
2380 err = proc_put_long(&buffer, &left, lval, neg);
2381 if (err)
2382 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 }
2384 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002385
2386 if (!write && !first && left && !err)
2387 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002388 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002389 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002390 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002391 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002392 if (first)
2393 return err ? : -EINVAL;
2394 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002395 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002396out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002398 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399}
2400
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002401static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002402 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002403 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002404 int write, void *data),
2405 void *data)
2406{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002407 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002408 buffer, lenp, ppos, conv, data);
2409}
2410
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411/**
2412 * proc_dointvec - read a vector of integers
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 * Returns 0 on success.
2423 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002424int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 void __user *buffer, size_t *lenp, loff_t *ppos)
2426{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002427 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2428}
2429
2430/**
2431 * proc_douintvec - read a vector of unsigned integers
2432 * @table: the sysctl table
2433 * @write: %TRUE if this is a write to the sysctl file
2434 * @buffer: the user buffer
2435 * @lenp: the size of the user buffer
2436 * @ppos: file position
2437 *
2438 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2439 * values from/to the user buffer, treated as an ASCII string.
2440 *
2441 * Returns 0 on success.
2442 */
2443int proc_douintvec(struct ctl_table *table, int write,
2444 void __user *buffer, size_t *lenp, loff_t *ppos)
2445{
2446 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2447 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448}
2449
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002450/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002451 * Taint values can only be increased
2452 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002453 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002454static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002455 void __user *buffer, size_t *lenp, loff_t *ppos)
2456{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002457 struct ctl_table t;
2458 unsigned long tmptaint = get_taint();
2459 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002460
Bastian Blank91fcd412007-04-23 14:41:14 -07002461 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002462 return -EPERM;
2463
Andi Kleen25ddbb12008-10-15 22:01:41 -07002464 t = *table;
2465 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002466 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002467 if (err < 0)
2468 return err;
2469
2470 if (write) {
2471 /*
2472 * Poor man's atomic or. Not worth adding a primitive
2473 * to everyone's atomic.h for this
2474 */
2475 int i;
2476 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2477 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302478 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002479 }
2480 }
2481
2482 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002483}
2484
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002485#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002486static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002487 void __user *buffer, size_t *lenp, loff_t *ppos)
2488{
2489 if (write && !capable(CAP_SYS_ADMIN))
2490 return -EPERM;
2491
2492 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2493}
2494#endif
2495
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496struct do_proc_dointvec_minmax_conv_param {
2497 int *min;
2498 int *max;
2499};
2500
Amerigo Wang00b7c332010-05-05 00:26:45 +00002501static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2502 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 int write, void *data)
2504{
2505 struct do_proc_dointvec_minmax_conv_param *param = data;
2506 if (write) {
2507 int val = *negp ? -*lvalp : *lvalp;
2508 if ((param->min && *param->min > val) ||
2509 (param->max && *param->max < val))
2510 return -EINVAL;
2511 *valp = val;
2512 } else {
2513 int val = *valp;
2514 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002515 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002516 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002518 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519 *lvalp = (unsigned long)val;
2520 }
2521 }
2522 return 0;
2523}
2524
2525/**
2526 * proc_dointvec_minmax - read a vector of integers with min/max values
2527 * @table: the sysctl table
2528 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529 * @buffer: the user buffer
2530 * @lenp: the size of the user buffer
2531 * @ppos: file position
2532 *
2533 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2534 * values from/to the user buffer, treated as an ASCII string.
2535 *
2536 * This routine will ensure the values are within the range specified by
2537 * table->extra1 (min) and table->extra2 (max).
2538 *
2539 * Returns 0 on success.
2540 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002541int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542 void __user *buffer, size_t *lenp, loff_t *ppos)
2543{
2544 struct do_proc_dointvec_minmax_conv_param param = {
2545 .min = (int *) table->extra1,
2546 .max = (int *) table->extra2,
2547 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002548 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549 do_proc_dointvec_minmax_conv, &param);
2550}
2551
Kees Cook54b50192012-07-30 14:39:18 -07002552static void validate_coredump_safety(void)
2553{
Alex Kelly046d6622012-10-04 17:15:23 -07002554#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002555 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002556 core_pattern[0] != '/' && core_pattern[0] != '|') {
2557 printk(KERN_WARNING "Unsafe core_pattern used with "\
2558 "suid_dumpable=2. Pipe handler or fully qualified "\
2559 "core dump path required.\n");
2560 }
Alex Kelly046d6622012-10-04 17:15:23 -07002561#endif
Kees Cook54b50192012-07-30 14:39:18 -07002562}
2563
2564static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2565 void __user *buffer, size_t *lenp, loff_t *ppos)
2566{
2567 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2568 if (!error)
2569 validate_coredump_safety();
2570 return error;
2571}
2572
Alex Kelly046d6622012-10-04 17:15:23 -07002573#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002574static int proc_dostring_coredump(struct ctl_table *table, int write,
2575 void __user *buffer, size_t *lenp, loff_t *ppos)
2576{
2577 int error = proc_dostring(table, write, buffer, lenp, ppos);
2578 if (!error)
2579 validate_coredump_safety();
2580 return error;
2581}
Alex Kelly046d6622012-10-04 17:15:23 -07002582#endif
Kees Cook54b50192012-07-30 14:39:18 -07002583
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002584static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 void __user *buffer,
2586 size_t *lenp, loff_t *ppos,
2587 unsigned long convmul,
2588 unsigned long convdiv)
2589{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002590 unsigned long *i, *min, *max;
2591 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002592 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002593 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002594
2595 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 *lenp = 0;
2597 return 0;
2598 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002599
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002600 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601 min = (unsigned long *) table->extra1;
2602 max = (unsigned long *) table->extra2;
2603 vleft = table->maxlen / sizeof(unsigned long);
2604 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002605
2606 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002607 if (*ppos) {
2608 switch (sysctl_writes_strict) {
2609 case SYSCTL_WRITES_STRICT:
2610 goto out;
2611 case SYSCTL_WRITES_WARN:
2612 warn_sysctl_write(table);
2613 break;
2614 default:
2615 break;
2616 }
2617 }
2618
Amerigo Wang00b7c332010-05-05 00:26:45 +00002619 if (left > PAGE_SIZE - 1)
2620 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002621 p = kbuf = memdup_user_nul(buffer, left);
2622 if (IS_ERR(kbuf))
2623 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002624 }
2625
Eric Dumazet27b3d802010-10-07 12:59:29 -07002626 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002627 unsigned long val;
2628
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002630 bool neg;
2631
Al Viro70f6cbb2015-12-24 00:13:10 -05002632 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002633
Al Viro70f6cbb2015-12-24 00:13:10 -05002634 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002635 proc_wspace_sep,
2636 sizeof(proc_wspace_sep), NULL);
2637 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 break;
2639 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002641 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002642 if ((min && val < *min) || (max && val > *max))
2643 continue;
2644 *i = val;
2645 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002646 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002647 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002648 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002649 if (err)
2650 break;
2651 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002652 err = proc_put_long(&buffer, &left, val, false);
2653 if (err)
2654 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 }
2656 }
2657
Amerigo Wang00b7c332010-05-05 00:26:45 +00002658 if (!write && !first && left && !err)
2659 err = proc_put_char(&buffer, &left, '\n');
2660 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002661 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002663 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002664 if (first)
2665 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002668out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002669 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002670 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671}
2672
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002673static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002674 void __user *buffer,
2675 size_t *lenp, loff_t *ppos,
2676 unsigned long convmul,
2677 unsigned long convdiv)
2678{
2679 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002680 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002681}
2682
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683/**
2684 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2685 * @table: the sysctl table
2686 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002687 * @buffer: the user buffer
2688 * @lenp: the size of the user buffer
2689 * @ppos: file position
2690 *
2691 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2692 * values from/to the user buffer, treated as an ASCII string.
2693 *
2694 * This routine will ensure the values are within the range specified by
2695 * table->extra1 (min) and table->extra2 (max).
2696 *
2697 * Returns 0 on success.
2698 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002699int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002700 void __user *buffer, size_t *lenp, loff_t *ppos)
2701{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002702 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002703}
2704
2705/**
2706 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2707 * @table: the sysctl table
2708 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002709 * @buffer: the user buffer
2710 * @lenp: the size of the user buffer
2711 * @ppos: file position
2712 *
2713 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2714 * values from/to the user buffer, treated as an ASCII string. The values
2715 * are treated as milliseconds, and converted to jiffies when they are stored.
2716 *
2717 * This routine will ensure the values are within the range specified by
2718 * table->extra1 (min) and table->extra2 (max).
2719 *
2720 * Returns 0 on success.
2721 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002722int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002723 void __user *buffer,
2724 size_t *lenp, loff_t *ppos)
2725{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002726 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 lenp, ppos, HZ, 1000l);
2728}
2729
2730
Amerigo Wang00b7c332010-05-05 00:26:45 +00002731static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002732 int *valp,
2733 int write, void *data)
2734{
2735 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002736 if (*lvalp > LONG_MAX / HZ)
2737 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002738 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2739 } else {
2740 int val = *valp;
2741 unsigned long lval;
2742 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002743 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002744 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002746 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002747 lval = (unsigned long)val;
2748 }
2749 *lvalp = lval / HZ;
2750 }
2751 return 0;
2752}
2753
Amerigo Wang00b7c332010-05-05 00:26:45 +00002754static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 int *valp,
2756 int write, void *data)
2757{
2758 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002759 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2760 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002761 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2762 } else {
2763 int val = *valp;
2764 unsigned long lval;
2765 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002766 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002767 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002769 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002770 lval = (unsigned long)val;
2771 }
2772 *lvalp = jiffies_to_clock_t(lval);
2773 }
2774 return 0;
2775}
2776
Amerigo Wang00b7c332010-05-05 00:26:45 +00002777static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002778 int *valp,
2779 int write, void *data)
2780{
2781 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002782 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2783
2784 if (jif > INT_MAX)
2785 return 1;
2786 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002787 } else {
2788 int val = *valp;
2789 unsigned long lval;
2790 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002791 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002792 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002793 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002794 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002795 lval = (unsigned long)val;
2796 }
2797 *lvalp = jiffies_to_msecs(lval);
2798 }
2799 return 0;
2800}
2801
2802/**
2803 * proc_dointvec_jiffies - read a vector of integers as seconds
2804 * @table: the sysctl table
2805 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002806 * @buffer: the user buffer
2807 * @lenp: the size of the user buffer
2808 * @ppos: file position
2809 *
2810 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2811 * values from/to the user buffer, treated as an ASCII string.
2812 * The values read are assumed to be in seconds, and are converted into
2813 * jiffies.
2814 *
2815 * Returns 0 on success.
2816 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002817int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002818 void __user *buffer, size_t *lenp, loff_t *ppos)
2819{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002820 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002821 do_proc_dointvec_jiffies_conv,NULL);
2822}
2823
2824/**
2825 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2826 * @table: the sysctl table
2827 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002828 * @buffer: the user buffer
2829 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002830 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002831 *
2832 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2833 * values from/to the user buffer, treated as an ASCII string.
2834 * The values read are assumed to be in 1/USER_HZ seconds, and
2835 * are converted into jiffies.
2836 *
2837 * Returns 0 on success.
2838 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002839int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 void __user *buffer, size_t *lenp, loff_t *ppos)
2841{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002842 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002843 do_proc_dointvec_userhz_jiffies_conv,NULL);
2844}
2845
2846/**
2847 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2848 * @table: the sysctl table
2849 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002850 * @buffer: the user buffer
2851 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002852 * @ppos: file position
2853 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854 *
2855 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2856 * values from/to the user buffer, treated as an ASCII string.
2857 * The values read are assumed to be in 1/1000 seconds, and
2858 * are converted into jiffies.
2859 *
2860 * Returns 0 on success.
2861 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002862int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002863 void __user *buffer, size_t *lenp, loff_t *ppos)
2864{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002865 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002866 do_proc_dointvec_ms_jiffies_conv, NULL);
2867}
2868
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002869static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002870 void __user *buffer, size_t *lenp, loff_t *ppos)
2871{
2872 struct pid *new_pid;
2873 pid_t tmp;
2874 int r;
2875
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002876 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002877
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002878 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002879 lenp, ppos, NULL, NULL);
2880 if (r || !write)
2881 return r;
2882
2883 new_pid = find_get_pid(tmp);
2884 if (!new_pid)
2885 return -ESRCH;
2886
2887 put_pid(xchg(&cad_pid, new_pid));
2888 return 0;
2889}
2890
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002891/**
2892 * proc_do_large_bitmap - read/write from/to a large bitmap
2893 * @table: the sysctl table
2894 * @write: %TRUE if this is a write to the sysctl file
2895 * @buffer: the user buffer
2896 * @lenp: the size of the user buffer
2897 * @ppos: file position
2898 *
2899 * The bitmap is stored at table->data and the bitmap length (in bits)
2900 * in table->maxlen.
2901 *
2902 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2903 * large bitmaps may be represented in a compact manner. Writing into
2904 * the file will clear the bitmap then update it with the given input.
2905 *
2906 * Returns 0 on success.
2907 */
2908int proc_do_large_bitmap(struct ctl_table *table, int write,
2909 void __user *buffer, size_t *lenp, loff_t *ppos)
2910{
2911 int err = 0;
2912 bool first = 1;
2913 size_t left = *lenp;
2914 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002915 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002916 unsigned long *tmp_bitmap = NULL;
2917 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2918
WANG Cong122ff242014-05-12 16:04:53 -07002919 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002920 *lenp = 0;
2921 return 0;
2922 }
2923
2924 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002925 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002926
2927 if (left > PAGE_SIZE - 1)
2928 left = PAGE_SIZE - 1;
2929
Al Viro70f6cbb2015-12-24 00:13:10 -05002930 p = kbuf = memdup_user_nul(buffer, left);
2931 if (IS_ERR(kbuf))
2932 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002933
2934 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2935 GFP_KERNEL);
2936 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002937 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002938 return -ENOMEM;
2939 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002940 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002941 while (!err && left) {
2942 unsigned long val_a, val_b;
2943 bool neg;
2944
Al Viro70f6cbb2015-12-24 00:13:10 -05002945 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002946 sizeof(tr_a), &c);
2947 if (err)
2948 break;
2949 if (val_a >= bitmap_len || neg) {
2950 err = -EINVAL;
2951 break;
2952 }
2953
2954 val_b = val_a;
2955 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002956 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002957 left--;
2958 }
2959
2960 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002961 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002962 &neg, tr_b, sizeof(tr_b),
2963 &c);
2964 if (err)
2965 break;
2966 if (val_b >= bitmap_len || neg ||
2967 val_a > val_b) {
2968 err = -EINVAL;
2969 break;
2970 }
2971 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002972 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002973 left--;
2974 }
2975 }
2976
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002977 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002978 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002979 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002980 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002981 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002982 } else {
2983 unsigned long bit_a, bit_b = 0;
2984
2985 while (left) {
2986 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2987 if (bit_a >= bitmap_len)
2988 break;
2989 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2990 bit_a + 1) - 1;
2991
2992 if (!first) {
2993 err = proc_put_char(&buffer, &left, ',');
2994 if (err)
2995 break;
2996 }
2997 err = proc_put_long(&buffer, &left, bit_a, false);
2998 if (err)
2999 break;
3000 if (bit_a != bit_b) {
3001 err = proc_put_char(&buffer, &left, '-');
3002 if (err)
3003 break;
3004 err = proc_put_long(&buffer, &left, bit_b, false);
3005 if (err)
3006 break;
3007 }
3008
3009 first = 0; bit_b++;
3010 }
3011 if (!err)
3012 err = proc_put_char(&buffer, &left, '\n');
3013 }
3014
3015 if (!err) {
3016 if (write) {
3017 if (*ppos)
3018 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3019 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003020 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003021 }
3022 kfree(tmp_bitmap);
3023 *lenp -= left;
3024 *ppos += *lenp;
3025 return 0;
3026 } else {
3027 kfree(tmp_bitmap);
3028 return err;
3029 }
3030}
3031
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003032static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp,
3033 int *valp, int write, void *data)
3034{
3035 if (write) {
3036 if (*negp)
3037 return -EINVAL;
3038 *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp;
3039 } else {
3040 *negp = false;
3041 *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp;
3042 }
3043
3044 return 0;
3045}
3046
3047/**
3048 * proc_douintvec_capacity - read a vector of integers in percentage and convert
3049 * into sched capacity
3050 * @table: the sysctl table
3051 * @write: %TRUE if this is a write to the sysctl file
3052 * @buffer: the user buffer
3053 * @lenp: the size of the user buffer
3054 * @ppos: file position
3055 *
3056 * Returns 0 on success.
3057 */
3058int proc_douintvec_capacity(struct ctl_table *table, int write,
3059 void __user *buffer, size_t *lenp, loff_t *ppos)
3060{
3061 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3062 do_proc_douintvec_capacity_conv, NULL);
3063}
3064
Jovi Zhang55610502011-01-12 17:00:45 -08003065#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003066
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003067int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003068 void __user *buffer, size_t *lenp, loff_t *ppos)
3069{
3070 return -ENOSYS;
3071}
3072
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003073int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003074 void __user *buffer, size_t *lenp, loff_t *ppos)
3075{
3076 return -ENOSYS;
3077}
3078
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003079int proc_douintvec(struct ctl_table *table, int write,
3080 void __user *buffer, size_t *lenp, loff_t *ppos)
3081{
3082 return -ENOSYS;
3083}
3084
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003085int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003086 void __user *buffer, size_t *lenp, loff_t *ppos)
3087{
3088 return -ENOSYS;
3089}
3090
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003091int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003092 void __user *buffer, size_t *lenp, loff_t *ppos)
3093{
3094 return -ENOSYS;
3095}
3096
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003097int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003098 void __user *buffer, size_t *lenp, loff_t *ppos)
3099{
3100 return -ENOSYS;
3101}
3102
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003103int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104 void __user *buffer, size_t *lenp, loff_t *ppos)
3105{
3106 return -ENOSYS;
3107}
3108
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003109int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003110 void __user *buffer, size_t *lenp, loff_t *ppos)
3111{
3112 return -ENOSYS;
3113}
3114
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003115int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003116 void __user *buffer,
3117 size_t *lenp, loff_t *ppos)
3118{
3119 return -ENOSYS;
3120}
3121
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003122int proc_douintvec_capacity(struct ctl_table *table, int write,
3123 void __user *buffer, size_t *lenp, loff_t *ppos)
3124{
3125 return -ENOSYS;
3126}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003127
Jovi Zhang55610502011-01-12 17:00:45 -08003128#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003129
Linus Torvalds1da177e2005-04-16 15:20:36 -07003130/*
3131 * No sense putting this after each symbol definition, twice,
3132 * exception granted :-)
3133 */
3134EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003135EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003136EXPORT_SYMBOL(proc_dointvec_jiffies);
3137EXPORT_SYMBOL(proc_dointvec_minmax);
3138EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3139EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3140EXPORT_SYMBOL(proc_dostring);
3141EXPORT_SYMBOL(proc_doulongvec_minmax);
3142EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);