blob: f3a22c903ddbf432145e70b52a9c6ea0a93cdcda [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;
Will Deacon3141fcc2019-04-05 18:39:38 -0700128static unsigned long zero_ul;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800129static unsigned long one_ul = 1;
Christian Brauner6b65c262019-03-07 16:29:43 -0800130static unsigned long long_max = LONG_MAX;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700131static int one_hundred = 100;
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700132static int __maybe_unused one_thousand = 1000;
Satya Durga Srinivasu Prabhalac18b4032018-04-17 11:21:23 -0700133#ifdef CONFIG_SCHED_WALT
134static int two_million = 2000000;
135#endif
Dave Youngaf913222009-09-22 16:43:33 -0700136#ifdef CONFIG_PRINTK
137static int ten_thousand = 10000;
138#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300139#ifdef CONFIG_PERF_EVENTS
140static int six_hundred_forty_kb = 640 * 1024;
141#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700142
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700143/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
144static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
147static int maxolduid = 65535;
148static int minolduid;
149
150static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700151static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
Liu Hua80df2842014-04-07 15:38:57 -0700153/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
154#ifdef CONFIG_DETECT_HUNG_TASK
155static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
156#endif
157
Dave Youngd14f1722010-02-25 20:28:57 -0500158#ifdef CONFIG_INOTIFY_USER
159#include <linux/inotify.h>
160#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700161#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162#endif
163
164#ifdef __hppa__
165extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530166#endif
167
168#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169extern int unaligned_enabled;
170#endif
171
Jes Sorensend2b176e2006-02-28 09:42:23 -0800172#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800173extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800174#endif
175
Vineet Guptab6fca722013-01-09 20:06:28 +0530176#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
177extern int no_unaligned_warning;
178#endif
179
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700180#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700181
182#define SYSCTL_WRITES_LEGACY -1
183#define SYSCTL_WRITES_WARN 0
184#define SYSCTL_WRITES_STRICT 1
185
Kees Cook41662f52016-01-20 15:00:45 -0800186static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700187
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700188static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700189 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700190static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800191 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700192#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700193
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700194#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700195static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700196 void __user *buffer, size_t *lenp, loff_t *ppos);
197#endif
198
Kees Cook54b50192012-07-30 14:39:18 -0700199static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
200 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700201#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700202static int proc_dostring_coredump(struct ctl_table *table, int write,
203 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700204#endif
Kees Cook54b50192012-07-30 14:39:18 -0700205
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700206#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800207/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100208static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700209
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700210static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700211 void __user *buffer, size_t *lenp,
212 loff_t *ppos)
213{
214 int error;
215
216 error = proc_dointvec(table, write, buffer, lenp, ppos);
217 if (error)
218 return error;
219
220 if (write)
221 sysrq_toggle_support(__sysrq_enabled);
222
223 return 0;
224}
225
226#endif
227
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700228static struct ctl_table kern_table[];
229static struct ctl_table vm_table[];
230static struct ctl_table fs_table[];
231static struct ctl_table debug_table[];
232static struct ctl_table dev_table[];
233extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800234#ifdef CONFIG_EPOLL
235extern struct ctl_table epoll_table[];
236#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
239int sysctl_legacy_va_layout;
240#endif
241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242/* The default sysctl tables: */
243
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800244static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .procname = "kernel",
247 .mode = 0555,
248 .child = kern_table,
249 },
250 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 .procname = "vm",
252 .mode = 0555,
253 .child = vm_table,
254 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 .procname = "fs",
257 .mode = 0555,
258 .child = fs_table,
259 },
260 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 .procname = "debug",
262 .mode = 0555,
263 .child = debug_table,
264 },
265 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 .procname = "dev",
267 .mode = 0555,
268 .child = dev_table,
269 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700270 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271};
272
Ingo Molnar77e54a12007-07-09 18:52:00 +0200273#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100274static int min_sched_granularity_ns = 100000; /* 100 usecs */
275static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
276static int min_wakeup_granularity_ns; /* 0 usecs */
277static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200278#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100279static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
280static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200281#endif /* CONFIG_SMP */
282#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200283
Mel Gorman5e771902010-05-24 14:32:31 -0700284#ifdef CONFIG_COMPACTION
285static int min_extfrag_threshold;
286static int max_extfrag_threshold = 1000;
287#endif
288
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700289static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200290 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200291 .procname = "sched_child_runs_first",
292 .data = &sysctl_sched_child_runs_first,
293 .maxlen = sizeof(unsigned int),
294 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800295 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200296 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530297#if defined(CONFIG_PREEMPT_TRACER) || defined(CONFIG_IRQSOFF_TRACER)
298 {
299 .procname = "preemptoff_tracing_threshold_ns",
300 .data = &sysctl_preemptoff_tracing_threshold_ns,
301 .maxlen = sizeof(unsigned int),
302 .mode = 0644,
303 .proc_handler = proc_dointvec,
304 },
Pavankumar Kondeti0d2621b2018-03-26 15:56:26 +0530305 {
306 .procname = "irqsoff_tracing_threshold_ns",
307 .data = &sysctl_irqsoff_tracing_threshold_ns,
308 .maxlen = sizeof(unsigned int),
309 .mode = 0644,
310 .proc_handler = proc_dointvec,
311 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530312#endif
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800313#ifdef CONFIG_SCHED_WALT
314 {
315 .procname = "sched_cpu_high_irqload",
316 .data = &sysctl_sched_cpu_high_irqload,
317 .maxlen = sizeof(unsigned int),
318 .mode = 0644,
319 .proc_handler = proc_dointvec,
320 },
Joonwoo Park6f188472017-06-16 11:32:17 -0700321 {
322 .procname = "sched_group_upmigrate",
323 .data = &sysctl_sched_group_upmigrate_pct,
324 .maxlen = sizeof(unsigned int),
325 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700326 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700327 .extra1 = &sysctl_sched_group_downmigrate_pct,
328 },
329 {
330 .procname = "sched_group_downmigrate",
331 .data = &sysctl_sched_group_downmigrate_pct,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700334 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700335 .extra1 = &zero,
336 .extra2 = &sysctl_sched_group_upmigrate_pct,
337 },
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530338 {
339 .procname = "sched_boost",
340 .data = &sysctl_sched_boost,
341 .maxlen = sizeof(unsigned int),
342 .mode = 0644,
343 .proc_handler = sched_boost_handler,
344 .extra1 = &zero,
345 .extra2 = &three,
346 },
Pavankumar Kondeti4e13d112018-01-25 01:12:08 +0530347 {
348 .procname = "sched_walt_rotate_big_tasks",
349 .data = &sysctl_sched_walt_rotate_big_tasks,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
352 .proc_handler = proc_dointvec_minmax,
353 .extra1 = &zero,
354 .extra2 = &one,
355 },
Lingutla Chandrasekhar57eb0712018-03-12 10:20:08 +0530356 {
357 .procname = "sched_initial_task_util",
358 .data = &sysctl_sched_init_task_load_pct,
359 .maxlen = sizeof(unsigned int),
360 .mode = 0644,
361 .proc_handler = proc_dointvec,
362 },
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700363 {
364 .procname = "sched_min_task_util_for_boost_colocation",
365 .data = &sysctl_sched_min_task_util_for_boost_colocation,
366 .maxlen = sizeof(unsigned int),
367 .mode = 0644,
368 .proc_handler = proc_dointvec_minmax,
369 .extra1 = &zero,
370 .extra2 = &one_thousand,
371 },
Satya Durga Srinivasu Prabhalac18b4032018-04-17 11:21:23 -0700372 {
373 .procname = "sched_little_cluster_coloc_fmin_khz",
374 .data = &sysctl_sched_little_cluster_coloc_fmin_khz,
375 .maxlen = sizeof(unsigned int),
376 .mode = 0644,
377 .proc_handler = sched_little_cluster_coloc_fmin_khz_handler,
378 .extra1 = &zero,
379 .extra2 = &two_million,
380 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800381#endif
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530382 {
383 .procname = "sched_upmigrate",
384 .data = &sysctl_sched_capacity_margin,
385 .maxlen = sizeof(unsigned int),
386 .mode = 0644,
387 .proc_handler = sched_updown_migrate_handler,
388 },
389 {
390 .procname = "sched_downmigrate",
391 .data = &sysctl_sched_capacity_margin_down,
392 .maxlen = sizeof(unsigned int),
393 .mode = 0644,
394 .proc_handler = sched_updown_migrate_handler,
395 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200396#ifdef CONFIG_SCHED_DEBUG
397 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100398 .procname = "sched_min_granularity_ns",
399 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800402 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100403 .extra1 = &min_sched_granularity_ns,
404 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200405 },
406 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200407 .procname = "sched_latency_ns",
408 .data = &sysctl_sched_latency,
409 .maxlen = sizeof(unsigned int),
410 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800411 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200412 .extra1 = &min_sched_granularity_ns,
413 .extra2 = &max_sched_granularity_ns,
414 },
415 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000416 .procname = "sched_sync_hint_enable",
417 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100418 .maxlen = sizeof(unsigned int),
419 .mode = 0644,
420 .proc_handler = proc_dointvec,
421 },
422 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100423 .procname = "sched_cstate_aware",
424 .data = &sysctl_sched_cstate_aware,
425 .maxlen = sizeof(unsigned int),
426 .mode = 0644,
427 .proc_handler = proc_dointvec,
428 },
429 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200430 .procname = "sched_wakeup_granularity_ns",
431 .data = &sysctl_sched_wakeup_granularity,
432 .maxlen = sizeof(unsigned int),
433 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800434 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200435 .extra1 = &min_wakeup_granularity_ns,
436 .extra2 = &max_wakeup_granularity_ns,
437 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200438#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200439 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100440 .procname = "sched_tunable_scaling",
441 .data = &sysctl_sched_tunable_scaling,
442 .maxlen = sizeof(enum sched_tunable_scaling),
443 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800444 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100445 .extra1 = &min_sched_tunable_scaling,
446 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200447 },
448 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900449 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200450 .data = &sysctl_sched_migration_cost,
451 .maxlen = sizeof(unsigned int),
452 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800453 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200454 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100455 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100456 .procname = "sched_nr_migrate",
457 .data = &sysctl_sched_nr_migrate,
458 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800460 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100461 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530462 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900463 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200464 .data = &sysctl_sched_time_avg,
465 .maxlen = sizeof(unsigned int),
466 .mode = 0644,
Pavankumar Kondeti12939492017-02-02 14:24:34 +0530467 .proc_handler = proc_dointvec_minmax,
468 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200469 },
470 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900471 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800472 .data = &sysctl_sched_shares_window,
473 .maxlen = sizeof(unsigned int),
474 .mode = 0644,
475 .proc_handler = proc_dointvec,
476 },
Mel Gormancb251762016-02-05 09:08:36 +0000477#ifdef CONFIG_SCHEDSTATS
478 {
479 .procname = "sched_schedstats",
480 .data = NULL,
481 .maxlen = sizeof(unsigned int),
482 .mode = 0644,
483 .proc_handler = sysctl_schedstats,
484 .extra1 = &zero,
485 .extra2 = &one,
486 },
487#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200488#endif /* CONFIG_SMP */
489#ifdef CONFIG_NUMA_BALANCING
490 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200491 .procname = "numa_balancing_scan_delay_ms",
492 .data = &sysctl_numa_balancing_scan_delay,
493 .maxlen = sizeof(unsigned int),
494 .mode = 0644,
495 .proc_handler = proc_dointvec,
496 },
497 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200498 .procname = "numa_balancing_scan_period_min_ms",
499 .data = &sysctl_numa_balancing_scan_period_min,
500 .maxlen = sizeof(unsigned int),
501 .mode = 0644,
502 .proc_handler = proc_dointvec,
503 },
504 {
505 .procname = "numa_balancing_scan_period_max_ms",
506 .data = &sysctl_numa_balancing_scan_period_max,
507 .maxlen = sizeof(unsigned int),
508 .mode = 0644,
509 .proc_handler = proc_dointvec,
510 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200511 {
512 .procname = "numa_balancing_scan_size_mb",
513 .data = &sysctl_numa_balancing_scan_size,
514 .maxlen = sizeof(unsigned int),
515 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400516 .proc_handler = proc_dointvec_minmax,
517 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200518 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100519 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800520 .procname = "numa_balancing",
521 .data = NULL, /* filled in by handler */
522 .maxlen = sizeof(unsigned int),
523 .mode = 0644,
524 .proc_handler = sysctl_numa_balancing,
525 .extra1 = &zero,
526 .extra2 = &one,
527 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200528#endif /* CONFIG_NUMA_BALANCING */
529#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200530 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100531 .procname = "sched_rt_period_us",
532 .data = &sysctl_sched_rt_period,
533 .maxlen = sizeof(unsigned int),
534 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800535 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100536 },
537 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100538 .procname = "sched_rt_runtime_us",
539 .data = &sysctl_sched_rt_runtime,
540 .maxlen = sizeof(int),
541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800542 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100543 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600544 {
545 .procname = "sched_rr_timeslice_ms",
546 .data = &sched_rr_timeslice,
547 .maxlen = sizeof(int),
548 .mode = 0644,
549 .proc_handler = sched_rr_handler,
550 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100551#ifdef CONFIG_SCHED_AUTOGROUP
552 {
553 .procname = "sched_autogroup_enabled",
554 .data = &sysctl_sched_autogroup_enabled,
555 .maxlen = sizeof(unsigned int),
556 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800557 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100558 .extra1 = &zero,
559 .extra2 = &one,
560 },
561#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700562#ifdef CONFIG_CFS_BANDWIDTH
563 {
564 .procname = "sched_cfs_bandwidth_slice_us",
565 .data = &sysctl_sched_cfs_bandwidth_slice,
566 .maxlen = sizeof(unsigned int),
567 .mode = 0644,
568 .proc_handler = proc_dointvec_minmax,
569 .extra1 = &one,
570 },
571#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100572#ifdef CONFIG_SCHED_TUNE
573 {
574 .procname = "sched_cfs_boost",
575 .data = &sysctl_sched_cfs_boost,
576 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100577#ifdef CONFIG_CGROUP_SCHEDTUNE
578 .mode = 0444,
579#else
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100580 .mode = 0644,
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100581#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100582 .proc_handler = &sysctl_sched_cfs_boost_handler,
583 .extra1 = &zero,
584 .extra2 = &one_hundred,
585 },
586#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700587#ifdef CONFIG_PROVE_LOCKING
588 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700589 .procname = "prove_locking",
590 .data = &prove_locking,
591 .maxlen = sizeof(int),
592 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800593 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700594 },
595#endif
596#ifdef CONFIG_LOCK_STAT
597 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700598 .procname = "lock_stat",
599 .data = &lock_stat,
600 .maxlen = sizeof(int),
601 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800602 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700603 },
604#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 .procname = "panic",
607 .data = &panic_timeout,
608 .maxlen = sizeof(int),
609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 },
Alex Kelly046d6622012-10-04 17:15:23 -0700612#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .procname = "core_uses_pid",
615 .data = &core_uses_pid,
616 .maxlen = sizeof(int),
617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 },
620 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 .procname = "core_pattern",
622 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700623 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700625 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 },
Neil Hormana2939802009-09-23 15:56:56 -0700627 {
Neil Hormana2939802009-09-23 15:56:56 -0700628 .procname = "core_pipe_limit",
629 .data = &core_pipe_limit,
630 .maxlen = sizeof(unsigned int),
631 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800632 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700633 },
Alex Kelly046d6622012-10-04 17:15:23 -0700634#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800635#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700638 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800639 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800640 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700642 {
643 .procname = "sysctl_writes_strict",
644 .data = &sysctl_writes_strict,
645 .maxlen = sizeof(int),
646 .mode = 0644,
647 .proc_handler = proc_dointvec_minmax,
648 .extra1 = &neg_one,
649 .extra2 = &one,
650 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800651#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100652#ifdef CONFIG_LATENCYTOP
653 {
654 .procname = "latencytop",
655 .data = &latencytop_enabled,
656 .maxlen = sizeof(int),
657 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000658 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100659 },
660#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661#ifdef CONFIG_BLK_DEV_INITRD
662 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .procname = "real-root-dev",
664 .data = &real_root_dev,
665 .maxlen = sizeof(int),
666 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800667 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 },
669#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700670 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700671 .procname = "print-fatal-signals",
672 .data = &print_fatal_signals,
673 .maxlen = sizeof(int),
674 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800675 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700676 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700677#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .procname = "reboot-cmd",
680 .data = reboot_command,
681 .maxlen = 256,
682 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 },
685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "stop-a",
687 .data = &stop_a_enabled,
688 .maxlen = sizeof (int),
689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 },
692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "scons-poweroff",
694 .data = &scons_pwroff,
695 .maxlen = sizeof (int),
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
699#endif
David S. Miller08714202008-11-16 23:49:24 -0800700#ifdef CONFIG_SPARC64
701 {
David S. Miller08714202008-11-16 23:49:24 -0800702 .procname = "tsb-ratio",
703 .data = &sysctl_tsb_ratio,
704 .maxlen = sizeof (int),
705 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800706 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800707 },
708#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709#ifdef __hppa__
710 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .procname = "soft-power",
712 .data = &pwrsw_enabled,
713 .maxlen = sizeof (int),
714 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800715 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530717#endif
718#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .procname = "unaligned-trap",
721 .data = &unaligned_enabled,
722 .maxlen = sizeof (int),
723 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800724 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 },
726#endif
727 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 .procname = "ctrl-alt-del",
729 .data = &C_A_D,
730 .maxlen = sizeof(int),
731 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800732 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400734#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200735 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200736 .procname = "ftrace_enabled",
737 .data = &ftrace_enabled,
738 .maxlen = sizeof(int),
739 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800740 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200741 },
742#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500743#ifdef CONFIG_STACK_TRACER
744 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500745 .procname = "stack_tracer_enabled",
746 .data = &stack_tracer_enabled,
747 .maxlen = sizeof(int),
748 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500750 },
751#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400752#ifdef CONFIG_TRACING
753 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100754 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400755 .data = &ftrace_dump_on_oops,
756 .maxlen = sizeof(int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400759 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400760 {
761 .procname = "traceoff_on_warning",
762 .data = &__disable_trace_on_warning,
763 .maxlen = sizeof(__disable_trace_on_warning),
764 .mode = 0644,
765 .proc_handler = proc_dointvec,
766 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500767 {
768 .procname = "tracepoint_printk",
769 .data = &tracepoint_printk,
770 .maxlen = sizeof(tracepoint_printk),
771 .mode = 0644,
772 .proc_handler = proc_dointvec,
773 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400774#endif
Dave Young2965faa2015-09-09 15:38:55 -0700775#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800776 {
777 .procname = "kexec_load_disabled",
778 .data = &kexec_load_disabled,
779 .maxlen = sizeof(int),
780 .mode = 0644,
781 /* only handle a transition from default "0" to "1" */
782 .proc_handler = proc_dointvec_minmax,
783 .extra1 = &one,
784 .extra2 = &one,
785 },
786#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200787#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 .procname = "modprobe",
790 .data = &modprobe_path,
791 .maxlen = KMOD_PATH_LEN,
792 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800793 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 },
Kees Cook3d433212009-04-02 15:49:29 -0700795 {
Kees Cook3d433212009-04-02 15:49:29 -0700796 .procname = "modules_disabled",
797 .data = &modules_disabled,
798 .maxlen = sizeof(int),
799 .mode = 0644,
800 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800801 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700802 .extra1 = &one,
803 .extra2 = &one,
804 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700806#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100809 .data = &uevent_helper,
810 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800812 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 },
Michael Marineau86d56132014-04-10 14:09:31 -0700814#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815#ifdef CONFIG_CHR_DEV_SG
816 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 .procname = "sg-big-buff",
818 .data = &sg_big_buff,
819 .maxlen = sizeof (int),
820 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800821 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 },
823#endif
824#ifdef CONFIG_BSD_PROCESS_ACCT
825 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 .procname = "acct",
827 .data = &acct_parm,
828 .maxlen = 3*sizeof(int),
829 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800830 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 },
832#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833#ifdef CONFIG_MAGIC_SYSRQ
834 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800836 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 .maxlen = sizeof (int),
838 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700839 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 },
841#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700842#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700845 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 .maxlen = sizeof (int),
847 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800848 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700850#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700853 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 .maxlen = sizeof(int),
855 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700856 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 },
858 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 .procname = "random",
860 .mode = 0555,
861 .child = random_table,
862 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863 {
Eric Paris17f60a72011-04-01 17:07:50 -0400864 .procname = "usermodehelper",
865 .mode = 0555,
866 .child = usermodehelper_table,
867 },
868 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 .procname = "overflowuid",
870 .data = &overflowuid,
871 .maxlen = sizeof(int),
872 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800873 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874 .extra1 = &minolduid,
875 .extra2 = &maxolduid,
876 },
877 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 .procname = "overflowgid",
879 .data = &overflowgid,
880 .maxlen = sizeof(int),
881 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800882 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 .extra1 = &minolduid,
884 .extra2 = &maxolduid,
885 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800886#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887#ifdef CONFIG_MATHEMU
888 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 .procname = "ieee_emulation_warnings",
890 .data = &sysctl_ieee_emulation_warnings,
891 .maxlen = sizeof(int),
892 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800893 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 },
895#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200898 .data = &show_unhandled_signals,
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,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 },
903#endif
904 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 .procname = "pid_max",
906 .data = &pid_max,
907 .maxlen = sizeof (int),
908 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800909 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 .extra1 = &pid_max_min,
911 .extra2 = &pid_max_max,
912 },
913 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 .procname = "panic_on_oops",
915 .data = &panic_on_oops,
916 .maxlen = sizeof(int),
917 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800918 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800920#if defined CONFIG_PRINTK
921 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800922 .procname = "printk",
923 .data = &console_loglevel,
924 .maxlen = 4*sizeof(int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800927 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700930 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 .maxlen = sizeof(int),
932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800933 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 },
935 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700937 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 .maxlen = sizeof(int),
939 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800940 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 },
Dave Youngaf913222009-09-22 16:43:33 -0700942 {
Dave Youngaf913222009-09-22 16:43:33 -0700943 .procname = "printk_delay",
944 .data = &printk_delay_msec,
945 .maxlen = sizeof(int),
946 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800947 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700948 .extra1 = &zero,
949 .extra2 = &ten_thousand,
950 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700952 .procname = "printk_devkmsg",
953 .data = devkmsg_log_str,
954 .maxlen = DEVKMSG_STR_MAX_SIZE,
955 .mode = 0644,
956 .proc_handler = devkmsg_sysctl_set_loglvl,
957 },
958 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800959 .procname = "dmesg_restrict",
960 .data = &dmesg_restrict,
961 .maxlen = sizeof(int),
962 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700963 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800964 .extra1 = &zero,
965 .extra2 = &one,
966 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800967 {
968 .procname = "kptr_restrict",
969 .data = &kptr_restrict,
970 .maxlen = sizeof(int),
971 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700972 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800973 .extra1 = &zero,
974 .extra2 = &two,
975 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800976#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800977 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 .procname = "ngroups_max",
979 .data = &ngroups_max,
980 .maxlen = sizeof (int),
981 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800982 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983 },
Dan Ballard73efc032011-10-31 17:11:20 -0700984 {
985 .procname = "cap_last_cap",
986 .data = (void *)&cap_last_cap,
987 .maxlen = sizeof(int),
988 .mode = 0444,
989 .proc_handler = proc_dointvec,
990 },
Don Zickus58687ac2010-05-07 17:11:44 -0400991#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500992 {
Don Zickus58687ac2010-05-07 17:11:44 -0400993 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200994 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500995 .maxlen = sizeof (int),
996 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700997 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700998 .extra1 = &zero,
999 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -04001000 },
1001 {
1002 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001003 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -04001004 .maxlen = sizeof(int),
1005 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001006 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +08001007 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -04001008 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -05001009 },
Don Zickus2508ce12010-05-07 17:11:46 -04001010 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001011 .procname = "nmi_watchdog",
1012 .data = &nmi_watchdog_enabled,
1013 .maxlen = sizeof (int),
1014 .mode = 0644,
1015 .proc_handler = proc_nmi_watchdog,
1016 .extra1 = &zero,
1017#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
1018 .extra2 = &one,
1019#else
1020 .extra2 = &zero,
1021#endif
1022 },
1023 {
1024 .procname = "soft_watchdog",
1025 .data = &soft_watchdog_enabled,
1026 .maxlen = sizeof (int),
1027 .mode = 0644,
1028 .proc_handler = proc_soft_watchdog,
1029 .extra1 = &zero,
1030 .extra2 = &one,
1031 },
1032 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001033 .procname = "watchdog_cpumask",
1034 .data = &watchdog_cpumask_bits,
1035 .maxlen = NR_CPUS,
1036 .mode = 0644,
1037 .proc_handler = proc_watchdog_cpumask,
1038 },
1039 {
Don Zickus2508ce12010-05-07 17:11:46 -04001040 .procname = "softlockup_panic",
1041 .data = &softlockup_panic,
1042 .maxlen = sizeof(int),
1043 .mode = 0644,
1044 .proc_handler = proc_dointvec_minmax,
1045 .extra1 = &zero,
1046 .extra2 = &one,
1047 },
Don Zickusac1f5912015-11-05 18:44:44 -08001048#ifdef CONFIG_HARDLOCKUP_DETECTOR
1049 {
1050 .procname = "hardlockup_panic",
1051 .data = &hardlockup_panic,
1052 .maxlen = sizeof(int),
1053 .mode = 0644,
1054 .proc_handler = proc_dointvec_minmax,
1055 .extra1 = &zero,
1056 .extra2 = &one,
1057 },
1058#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001059#ifdef CONFIG_SMP
1060 {
1061 .procname = "softlockup_all_cpu_backtrace",
1062 .data = &sysctl_softlockup_all_cpu_backtrace,
1063 .maxlen = sizeof(int),
1064 .mode = 0644,
1065 .proc_handler = proc_dointvec_minmax,
1066 .extra1 = &zero,
1067 .extra2 = &one,
1068 },
Jiri Kosina55537872015-11-05 18:44:41 -08001069 {
1070 .procname = "hardlockup_all_cpu_backtrace",
1071 .data = &sysctl_hardlockup_all_cpu_backtrace,
1072 .maxlen = sizeof(int),
1073 .mode = 0644,
1074 .proc_handler = proc_dointvec_minmax,
1075 .extra1 = &zero,
1076 .extra2 = &one,
1077 },
Aaron Tomlined235872014-06-23 13:22:05 -07001078#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001079#endif
1080#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1081 {
1082 .procname = "unknown_nmi_panic",
1083 .data = &unknown_nmi_panic,
1084 .maxlen = sizeof (int),
1085 .mode = 0644,
1086 .proc_handler = proc_dointvec,
1087 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001088#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089#if defined(CONFIG_X86)
1090 {
Don Zickus8da5add2006-09-26 10:52:27 +02001091 .procname = "panic_on_unrecovered_nmi",
1092 .data = &panic_on_unrecovered_nmi,
1093 .maxlen = sizeof(int),
1094 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001095 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001096 },
1097 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001098 .procname = "panic_on_io_nmi",
1099 .data = &panic_on_io_nmi,
1100 .maxlen = sizeof(int),
1101 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001102 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001103 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001104#ifdef CONFIG_DEBUG_STACKOVERFLOW
1105 {
1106 .procname = "panic_on_stackoverflow",
1107 .data = &sysctl_panic_on_stackoverflow,
1108 .maxlen = sizeof(int),
1109 .mode = 0644,
1110 .proc_handler = proc_dointvec,
1111 },
1112#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001113 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 .procname = "bootloader_type",
1115 .data = &bootloader_type,
1116 .maxlen = sizeof (int),
1117 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001120 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001121 .procname = "bootloader_version",
1122 .data = &bootloader_version,
1123 .maxlen = sizeof (int),
1124 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001125 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001126 },
1127 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001128 .procname = "kstack_depth_to_print",
1129 .data = &kstack_depth_to_print,
1130 .maxlen = sizeof(int),
1131 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001132 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001133 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001134 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001135 .procname = "io_delay_type",
1136 .data = &io_delay_type,
1137 .maxlen = sizeof(int),
1138 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001139 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001140 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001142#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 .procname = "randomize_va_space",
1145 .data = &randomize_va_space,
1146 .maxlen = sizeof(int),
1147 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001148 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001150#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001151#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001152 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001153 .procname = "spin_retry",
1154 .data = &spin_retry,
1155 .maxlen = sizeof (int),
1156 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001157 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001158 },
1159#endif
Len Brown673d5b42007-07-28 03:33:16 -04001160#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001161 {
Pavel Machekc255d842006-02-20 18:27:58 -08001162 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001163 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001164 .maxlen = sizeof (unsigned long),
1165 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001166 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001167 },
1168#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301169#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001170 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001171 .procname = "ignore-unaligned-usertrap",
1172 .data = &no_unaligned_warning,
1173 .maxlen = sizeof (int),
1174 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001175 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001176 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301177#endif
1178#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001179 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001180 .procname = "unaligned-dump-stack",
1181 .data = &unaligned_dump_stack,
1182 .maxlen = sizeof (int),
1183 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001184 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001185 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001186#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001187#ifdef CONFIG_DETECT_HUNG_TASK
1188 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001189 .procname = "hung_task_panic",
1190 .data = &sysctl_hung_task_panic,
1191 .maxlen = sizeof(int),
1192 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001193 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001194 .extra1 = &zero,
1195 .extra2 = &one,
1196 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001197 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001198 .procname = "hung_task_check_count",
1199 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001200 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001201 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001202 .proc_handler = proc_dointvec_minmax,
1203 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001204 },
1205 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001206 .procname = "hung_task_timeout_secs",
1207 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001208 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001209 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001210 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001211 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001212 },
1213 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001214 .procname = "hung_task_warnings",
1215 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001216 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001217 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001218 .proc_handler = proc_dointvec_minmax,
1219 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001220 },
Imran Khana9788f42017-09-18 15:48:30 +05301221 {
1222 .procname = "hung_task_selective_monitoring",
1223 .data = &sysctl_hung_task_selective_monitoring,
1224 .maxlen = sizeof(int),
1225 .mode = 0644,
1226 .proc_handler = proc_dointvec_minmax,
1227 .extra1 = &zero,
1228 .extra2 = &one,
1229 },
1230
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001231#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001232#ifdef CONFIG_RT_MUTEXES
1233 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001234 .procname = "max_lock_depth",
1235 .data = &max_lock_depth,
1236 .maxlen = sizeof(int),
1237 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001238 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001239 },
1240#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001241 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001242 .procname = "poweroff_cmd",
1243 .data = &poweroff_cmd,
1244 .maxlen = POWEROFF_CMD_PATH_LEN,
1245 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001246 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001247 },
David Howells0b77f5b2008-04-29 01:01:32 -07001248#ifdef CONFIG_KEYS
1249 {
David Howells0b77f5b2008-04-29 01:01:32 -07001250 .procname = "keys",
1251 .mode = 0555,
1252 .child = key_sysctls,
1253 },
1254#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001255#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001256 /*
1257 * User-space scripts rely on the existence of this file
1258 * as a feature check for perf_events being enabled.
1259 *
1260 * So it's an ABI, do not remove!
1261 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001262 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001263 .procname = "perf_event_paranoid",
1264 .data = &sysctl_perf_event_paranoid,
1265 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001266 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001267 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001268 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001269 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001270 .procname = "perf_event_mlock_kb",
1271 .data = &sysctl_perf_event_mlock,
1272 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001273 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001274 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001275 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001276 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001277 .procname = "perf_event_max_sample_rate",
1278 .data = &sysctl_perf_event_sample_rate,
1279 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001280 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001281 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001282 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001283 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001284 {
1285 .procname = "perf_cpu_time_max_percent",
1286 .data = &sysctl_perf_cpu_time_max_percent,
1287 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1288 .mode = 0644,
1289 .proc_handler = perf_cpu_time_max_percent_handler,
1290 .extra1 = &zero,
1291 .extra2 = &one_hundred,
1292 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001293 {
1294 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001295 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001296 .maxlen = sizeof(sysctl_perf_event_max_stack),
1297 .mode = 0644,
1298 .proc_handler = perf_event_max_stack_handler,
1299 .extra1 = &zero,
1300 .extra2 = &six_hundred_forty_kb,
1301 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001302 {
1303 .procname = "perf_event_max_contexts_per_stack",
1304 .data = &sysctl_perf_event_max_contexts_per_stack,
1305 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1306 .mode = 0644,
1307 .proc_handler = perf_event_max_stack_handler,
1308 .extra1 = &zero,
1309 .extra2 = &one_thousand,
1310 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001311#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001312#ifdef CONFIG_KMEMCHECK
1313 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001314 .procname = "kmemcheck",
1315 .data = &kmemcheck_enabled,
1316 .maxlen = sizeof(int),
1317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001319 },
1320#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001321 {
1322 .procname = "panic_on_warn",
1323 .data = &panic_on_warn,
1324 .maxlen = sizeof(int),
1325 .mode = 0644,
1326 .proc_handler = proc_dointvec_minmax,
1327 .extra1 = &zero,
1328 .extra2 = &one,
1329 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001330#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1331 {
1332 .procname = "timer_migration",
1333 .data = &sysctl_timer_migration,
1334 .maxlen = sizeof(unsigned int),
1335 .mode = 0644,
1336 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001337 .extra1 = &zero,
1338 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001339 },
1340#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001341#ifdef CONFIG_BPF_SYSCALL
1342 {
1343 .procname = "unprivileged_bpf_disabled",
1344 .data = &sysctl_unprivileged_bpf_disabled,
1345 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1346 .mode = 0644,
1347 /* only handle a transition from default "0" to "1" */
1348 .proc_handler = proc_dointvec_minmax,
1349 .extra1 = &one,
1350 .extra2 = &one,
1351 },
1352#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001353#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1354 {
1355 .procname = "panic_on_rcu_stall",
1356 .data = &sysctl_panic_on_rcu_stall,
1357 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1358 .mode = 0644,
1359 .proc_handler = proc_dointvec_minmax,
1360 .extra1 = &zero,
1361 .extra2 = &one,
1362 },
1363#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001364#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001365 {
1366 .procname = "boot_reason",
1367 .data = &boot_reason,
1368 .maxlen = sizeof(int),
1369 .mode = 0444,
1370 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001371 },
1372
1373 {
1374 .procname = "cold_boot",
1375 .data = &cold_boot,
1376 .maxlen = sizeof(int),
1377 .mode = 0444,
1378 .proc_handler = proc_dointvec,
1379 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001380#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001381 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382};
1383
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001384static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 .procname = "overcommit_memory",
1387 .data = &sysctl_overcommit_memory,
1388 .maxlen = sizeof(sysctl_overcommit_memory),
1389 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001390 .proc_handler = proc_dointvec_minmax,
1391 .extra1 = &zero,
1392 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 },
1394 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001395 .procname = "panic_on_oom",
1396 .data = &sysctl_panic_on_oom,
1397 .maxlen = sizeof(sysctl_panic_on_oom),
1398 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001399 .proc_handler = proc_dointvec_minmax,
1400 .extra1 = &zero,
1401 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001402 },
1403 {
David Rientjesfe071d72007-10-16 23:25:56 -07001404 .procname = "oom_kill_allocating_task",
1405 .data = &sysctl_oom_kill_allocating_task,
1406 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001408 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001409 },
1410 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001411 .procname = "oom_dump_tasks",
1412 .data = &sysctl_oom_dump_tasks,
1413 .maxlen = sizeof(sysctl_oom_dump_tasks),
1414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001415 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001416 },
1417 {
Charan Teja Reddyf9920cf2018-05-01 20:20:20 +05301418 .procname = "reap_mem_on_sigkill",
1419 .data = &sysctl_reap_mem_on_sigkill,
1420 .maxlen = sizeof(sysctl_reap_mem_on_sigkill),
1421 .mode = 0644,
1422 .proc_handler = proc_dointvec,
1423 },
1424 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425 .procname = "overcommit_ratio",
1426 .data = &sysctl_overcommit_ratio,
1427 .maxlen = sizeof(sysctl_overcommit_ratio),
1428 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001429 .proc_handler = overcommit_ratio_handler,
1430 },
1431 {
1432 .procname = "overcommit_kbytes",
1433 .data = &sysctl_overcommit_kbytes,
1434 .maxlen = sizeof(sysctl_overcommit_kbytes),
1435 .mode = 0644,
1436 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 },
1438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 .procname = "page-cluster",
1440 .data = &page_cluster,
1441 .maxlen = sizeof(int),
1442 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001443 .proc_handler = proc_dointvec_minmax,
1444 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 },
1446 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 .procname = "dirty_background_ratio",
1448 .data = &dirty_background_ratio,
1449 .maxlen = sizeof(dirty_background_ratio),
1450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001451 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 .extra1 = &zero,
1453 .extra2 = &one_hundred,
1454 },
1455 {
David Rientjes2da02992009-01-06 14:39:31 -08001456 .procname = "dirty_background_bytes",
1457 .data = &dirty_background_bytes,
1458 .maxlen = sizeof(dirty_background_bytes),
1459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001460 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001461 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001462 },
1463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .procname = "dirty_ratio",
1465 .data = &vm_dirty_ratio,
1466 .maxlen = sizeof(vm_dirty_ratio),
1467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001468 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 .extra1 = &zero,
1470 .extra2 = &one_hundred,
1471 },
1472 {
David Rientjes2da02992009-01-06 14:39:31 -08001473 .procname = "dirty_bytes",
1474 .data = &vm_dirty_bytes,
1475 .maxlen = sizeof(vm_dirty_bytes),
1476 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001477 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001478 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001479 },
1480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001482 .data = &dirty_writeback_interval,
1483 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001485 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 },
1487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001489 .data = &dirty_expire_interval,
1490 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001492 .proc_handler = proc_dointvec_minmax,
1493 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 },
1495 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001496 .procname = "dirtytime_expire_seconds",
1497 .data = &dirtytime_expire_interval,
1498 .maxlen = sizeof(dirty_expire_interval),
1499 .mode = 0644,
1500 .proc_handler = dirtytime_interval_handler,
1501 .extra1 = &zero,
1502 },
1503 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001504 .procname = "nr_pdflush_threads",
1505 .mode = 0444 /* read-only */,
1506 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 },
1508 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 .procname = "swappiness",
1510 .data = &vm_swappiness,
1511 .maxlen = sizeof(vm_swappiness),
1512 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001513 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .extra1 = &zero,
1515 .extra2 = &one_hundred,
1516 },
Vinayak Menonb9e4cc2b2018-06-11 18:58:39 +05301517 {
1518 .procname = "want_old_faultaround_pte",
1519 .data = &want_old_faultaround_pte,
1520 .maxlen = sizeof(want_old_faultaround_pte),
1521 .mode = 0644,
1522 .proc_handler = proc_dointvec_minmax,
1523 .extra1 = &zero,
1524 .extra2 = &one,
1525 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001529 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .maxlen = sizeof(unsigned long),
1531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001532 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001533 },
1534#ifdef CONFIG_NUMA
1535 {
1536 .procname = "nr_hugepages_mempolicy",
1537 .data = NULL,
1538 .maxlen = sizeof(unsigned long),
1539 .mode = 0644,
1540 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001541 },
1542#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 .procname = "hugetlb_shm_group",
1545 .data = &sysctl_hugetlb_shm_group,
1546 .maxlen = sizeof(gid_t),
1547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001548 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 },
Mel Gorman396faf02007-07-17 04:03:13 -07001550 {
Mel Gorman396faf02007-07-17 04:03:13 -07001551 .procname = "hugepages_treat_as_movable",
1552 .data = &hugepages_treat_as_movable,
1553 .maxlen = sizeof(int),
1554 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001555 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001556 },
Adam Litke54f9f802007-10-16 01:26:20 -07001557 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001558 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001559 .data = NULL,
1560 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001561 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001562 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001563 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564#endif
1565 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001566 .procname = "lowmem_reserve_ratio",
1567 .data = &sysctl_lowmem_reserve_ratio,
1568 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1569 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001570 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001571 },
1572 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001573 .procname = "drop_caches",
1574 .data = &sysctl_drop_caches,
1575 .maxlen = sizeof(int),
Johannes Weinerb231f9d2019-11-30 17:56:08 -08001576 .mode = 0200,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001577 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001578 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001579 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001580 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001581#ifdef CONFIG_COMPACTION
1582 {
1583 .procname = "compact_memory",
1584 .data = &sysctl_compact_memory,
1585 .maxlen = sizeof(int),
1586 .mode = 0200,
1587 .proc_handler = sysctl_compaction_handler,
1588 },
Mel Gorman5e771902010-05-24 14:32:31 -07001589 {
1590 .procname = "extfrag_threshold",
1591 .data = &sysctl_extfrag_threshold,
1592 .maxlen = sizeof(int),
1593 .mode = 0644,
1594 .proc_handler = sysctl_extfrag_handler,
1595 .extra1 = &min_extfrag_threshold,
1596 .extra2 = &max_extfrag_threshold,
1597 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001598 {
1599 .procname = "compact_unevictable_allowed",
1600 .data = &sysctl_compact_unevictable_allowed,
1601 .maxlen = sizeof(int),
1602 .mode = 0644,
1603 .proc_handler = proc_dointvec,
1604 .extra1 = &zero,
1605 .extra2 = &one,
1606 },
Mel Gorman5e771902010-05-24 14:32:31 -07001607
Mel Gorman76ab0f52010-05-24 14:32:28 -07001608#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001609 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610 .procname = "min_free_kbytes",
1611 .data = &min_free_kbytes,
1612 .maxlen = sizeof(min_free_kbytes),
1613 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001614 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615 .extra1 = &zero,
1616 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001617 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001618 .procname = "watermark_scale_factor",
1619 .data = &watermark_scale_factor,
1620 .maxlen = sizeof(watermark_scale_factor),
1621 .mode = 0644,
1622 .proc_handler = watermark_scale_factor_sysctl_handler,
Rik van Riel12462752011-09-01 15:26:50 -04001623 .extra1 = &zero,
1624 .extra2 = &zero,
1625 },
1626 {
1627 .procname = "extra_free_kbytes",
1628 .data = &extra_free_kbytes,
1629 .maxlen = sizeof(extra_free_kbytes),
1630 .mode = 0644,
1631 .proc_handler = min_free_kbytes_sysctl_handler,
1632 .extra1 = &zero,
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001633 },
1634 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001635 .procname = "percpu_pagelist_fraction",
1636 .data = &percpu_pagelist_fraction,
1637 .maxlen = sizeof(percpu_pagelist_fraction),
1638 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001639 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001640 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001641 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642#ifdef CONFIG_MMU
1643 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644 .procname = "max_map_count",
1645 .data = &sysctl_max_map_count,
1646 .maxlen = sizeof(sysctl_max_map_count),
1647 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001648 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001649 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001651#else
1652 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001653 .procname = "nr_trim_pages",
1654 .data = &sysctl_nr_trim_pages,
1655 .maxlen = sizeof(sysctl_nr_trim_pages),
1656 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001657 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001658 .extra1 = &zero,
1659 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660#endif
1661 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662 .procname = "laptop_mode",
1663 .data = &laptop_mode,
1664 .maxlen = sizeof(laptop_mode),
1665 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001666 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667 },
1668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669 .procname = "block_dump",
1670 .data = &block_dump,
1671 .maxlen = sizeof(block_dump),
1672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001673 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674 .extra1 = &zero,
1675 },
1676 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 .procname = "vfs_cache_pressure",
1678 .data = &sysctl_vfs_cache_pressure,
1679 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1680 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001681 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682 .extra1 = &zero,
1683 },
1684#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001686 .procname = "legacy_va_layout",
1687 .data = &sysctl_legacy_va_layout,
1688 .maxlen = sizeof(sysctl_legacy_va_layout),
1689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001690 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691 .extra1 = &zero,
1692 },
1693#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001694#ifdef CONFIG_NUMA
1695 {
Christoph Lameter17436602006-01-18 17:42:32 -08001696 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001697 .data = &node_reclaim_mode,
1698 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001699 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001700 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001701 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001702 },
Christoph Lameter96146342006-07-03 00:24:13 -07001703 {
Christoph Lameter96146342006-07-03 00:24:13 -07001704 .procname = "min_unmapped_ratio",
1705 .data = &sysctl_min_unmapped_ratio,
1706 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001708 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001709 .extra1 = &zero,
1710 .extra2 = &one_hundred,
1711 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001712 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001713 .procname = "min_slab_ratio",
1714 .data = &sysctl_min_slab_ratio,
1715 .maxlen = sizeof(sysctl_min_slab_ratio),
1716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001717 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001718 .extra1 = &zero,
1719 .extra2 = &one_hundred,
1720 },
Christoph Lameter17436602006-01-18 17:42:32 -08001721#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001722#ifdef CONFIG_SMP
1723 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001724 .procname = "stat_interval",
1725 .data = &sysctl_stat_interval,
1726 .maxlen = sizeof(sysctl_stat_interval),
1727 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001728 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001729 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001730 {
1731 .procname = "stat_refresh",
1732 .data = NULL,
1733 .maxlen = 0,
1734 .mode = 0600,
1735 .proc_handler = vmstat_refresh,
1736 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001737#endif
David Howells6e141542009-12-15 19:27:45 +00001738#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001739 {
Eric Parised032182007-06-28 15:55:21 -04001740 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001741 .data = &dac_mmap_min_addr,
1742 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001743 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001744 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001745 },
David Howells6e141542009-12-15 19:27:45 +00001746#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001747#ifdef CONFIG_NUMA
1748 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001749 .procname = "numa_zonelist_order",
1750 .data = &numa_zonelist_order,
1751 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1752 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001753 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001754 },
1755#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001756#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001757 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001758 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001759 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001760#ifdef CONFIG_X86_32
1761 .data = &vdso32_enabled,
1762 .maxlen = sizeof(vdso32_enabled),
1763#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001764 .data = &vdso_enabled,
1765 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001766#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001767 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001768 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001769 .extra1 = &zero,
1770 },
1771#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001772#ifdef CONFIG_HIGHMEM
1773 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001774 .procname = "highmem_is_dirtyable",
1775 .data = &vm_highmem_is_dirtyable,
1776 .maxlen = sizeof(vm_highmem_is_dirtyable),
1777 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001778 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001779 .extra1 = &zero,
1780 .extra2 = &one,
1781 },
1782#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001783#ifdef CONFIG_MEMORY_FAILURE
1784 {
Andi Kleen6a460792009-09-16 11:50:15 +02001785 .procname = "memory_failure_early_kill",
1786 .data = &sysctl_memory_failure_early_kill,
1787 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1788 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001789 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001790 .extra1 = &zero,
1791 .extra2 = &one,
1792 },
1793 {
Andi Kleen6a460792009-09-16 11:50:15 +02001794 .procname = "memory_failure_recovery",
1795 .data = &sysctl_memory_failure_recovery,
1796 .maxlen = sizeof(sysctl_memory_failure_recovery),
1797 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001798 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001799 .extra1 = &zero,
1800 .extra2 = &one,
1801 },
1802#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001803 {
1804 .procname = "user_reserve_kbytes",
1805 .data = &sysctl_user_reserve_kbytes,
1806 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1807 .mode = 0644,
1808 .proc_handler = proc_doulongvec_minmax,
1809 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001810 {
1811 .procname = "admin_reserve_kbytes",
1812 .data = &sysctl_admin_reserve_kbytes,
1813 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1814 .mode = 0644,
1815 .proc_handler = proc_doulongvec_minmax,
1816 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001817#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1818 {
1819 .procname = "mmap_rnd_bits",
1820 .data = &mmap_rnd_bits,
1821 .maxlen = sizeof(mmap_rnd_bits),
1822 .mode = 0600,
1823 .proc_handler = proc_dointvec_minmax,
1824 .extra1 = (void *)&mmap_rnd_bits_min,
1825 .extra2 = (void *)&mmap_rnd_bits_max,
1826 },
1827#endif
1828#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1829 {
1830 .procname = "mmap_rnd_compat_bits",
1831 .data = &mmap_rnd_compat_bits,
1832 .maxlen = sizeof(mmap_rnd_compat_bits),
1833 .mode = 0600,
1834 .proc_handler = proc_dointvec_minmax,
1835 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1836 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1837 },
1838#endif
Vinayak Menonc1c6a992015-12-21 13:00:58 +05301839#ifdef CONFIG_SWAP
1840 {
1841 .procname = "swap_ratio",
1842 .data = &sysctl_swap_ratio,
1843 .maxlen = sizeof(sysctl_swap_ratio),
1844 .mode = 0644,
1845 .proc_handler = proc_dointvec_minmax,
1846 },
1847 {
1848 .procname = "swap_ratio_enable",
1849 .data = &sysctl_swap_ratio_enable,
1850 .maxlen = sizeof(sysctl_swap_ratio_enable),
1851 .mode = 0644,
1852 .proc_handler = proc_dointvec_minmax,
1853 },
1854#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001855 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001856};
1857
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001858static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 .procname = "inode-nr",
1861 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001862 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001864 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865 },
1866 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 .procname = "inode-state",
1868 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001869 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001871 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872 },
1873 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874 .procname = "file-nr",
1875 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001876 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001878 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879 },
1880 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 .procname = "file-max",
1882 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001883 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001884 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001885 .proc_handler = proc_doulongvec_minmax,
Will Deacon3141fcc2019-04-05 18:39:38 -07001886 .extra1 = &zero_ul,
Christian Brauner6b65c262019-03-07 16:29:43 -08001887 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 },
1889 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001890 .procname = "nr_open",
1891 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001892 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001893 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001894 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001895 .extra1 = &sysctl_nr_open_min,
1896 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001897 },
1898 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 .procname = "dentry-state",
1900 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001901 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001903 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904 },
1905 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 .procname = "overflowuid",
1907 .data = &fs_overflowuid,
1908 .maxlen = sizeof(int),
1909 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001910 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911 .extra1 = &minolduid,
1912 .extra2 = &maxolduid,
1913 },
1914 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001915 .procname = "overflowgid",
1916 .data = &fs_overflowgid,
1917 .maxlen = sizeof(int),
1918 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001919 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 .extra1 = &minolduid,
1921 .extra2 = &maxolduid,
1922 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001923#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925 .procname = "leases-enable",
1926 .data = &leases_enable,
1927 .maxlen = sizeof(int),
1928 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001929 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001930 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001931#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001932#ifdef CONFIG_DNOTIFY
1933 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934 .procname = "dir-notify-enable",
1935 .data = &dir_notify_enable,
1936 .maxlen = sizeof(int),
1937 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001938 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939 },
1940#endif
1941#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001942#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001943 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944 .procname = "lease-break-time",
1945 .data = &lease_break_time,
1946 .maxlen = sizeof(int),
1947 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001948 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001949 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001950#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001951#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001953 .procname = "aio-nr",
1954 .data = &aio_nr,
1955 .maxlen = sizeof(aio_nr),
1956 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001957 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958 },
1959 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001960 .procname = "aio-max-nr",
1961 .data = &aio_max_nr,
1962 .maxlen = sizeof(aio_max_nr),
1963 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001964 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001965 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001966#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001967#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001968 {
Robert Love0399cb02005-07-13 12:38:18 -04001969 .procname = "inotify",
1970 .mode = 0555,
1971 .child = inotify_table,
1972 },
1973#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001974#ifdef CONFIG_EPOLL
1975 {
1976 .procname = "epoll",
1977 .mode = 0555,
1978 .child = epoll_table,
1979 },
1980#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001981#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001982 {
Kees Cook800179c2012-07-25 17:29:07 -07001983 .procname = "protected_symlinks",
1984 .data = &sysctl_protected_symlinks,
1985 .maxlen = sizeof(int),
1986 .mode = 0600,
1987 .proc_handler = proc_dointvec_minmax,
1988 .extra1 = &zero,
1989 .extra2 = &one,
1990 },
1991 {
1992 .procname = "protected_hardlinks",
1993 .data = &sysctl_protected_hardlinks,
1994 .maxlen = sizeof(int),
1995 .mode = 0600,
1996 .proc_handler = proc_dointvec_minmax,
1997 .extra1 = &zero,
1998 .extra2 = &one,
1999 },
2000 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07002001 .procname = "protected_fifos",
2002 .data = &sysctl_protected_fifos,
2003 .maxlen = sizeof(int),
2004 .mode = 0600,
2005 .proc_handler = proc_dointvec_minmax,
2006 .extra1 = &zero,
2007 .extra2 = &two,
2008 },
2009 {
2010 .procname = "protected_regular",
2011 .data = &sysctl_protected_regular,
2012 .maxlen = sizeof(int),
2013 .mode = 0600,
2014 .proc_handler = proc_dointvec_minmax,
2015 .extra1 = &zero,
2016 .extra2 = &two,
2017 },
2018 {
Alan Coxd6e71142005-06-23 00:09:43 -07002019 .procname = "suid_dumpable",
2020 .data = &suid_dumpable,
2021 .maxlen = sizeof(int),
2022 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07002023 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07002024 .extra1 = &zero,
2025 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07002026 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002027#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
2028 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002029 .procname = "binfmt_misc",
2030 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05002031 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002032 },
2033#endif
Jens Axboeb492e952010-05-19 21:03:16 +02002034 {
Jens Axboeff9da692010-06-03 14:54:39 +02002035 .procname = "pipe-max-size",
2036 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002037 .maxlen = sizeof(int),
2038 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02002039 .proc_handler = &pipe_proc_fn,
2040 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002041 },
Willy Tarreau759c0112016-01-18 16:36:09 +01002042 {
2043 .procname = "pipe-user-pages-hard",
2044 .data = &pipe_user_pages_hard,
2045 .maxlen = sizeof(pipe_user_pages_hard),
2046 .mode = 0644,
2047 .proc_handler = proc_doulongvec_minmax,
2048 },
2049 {
2050 .procname = "pipe-user-pages-soft",
2051 .data = &pipe_user_pages_soft,
2052 .maxlen = sizeof(pipe_user_pages_soft),
2053 .mode = 0644,
2054 .proc_handler = proc_doulongvec_minmax,
2055 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05002056 {
2057 .procname = "mount-max",
2058 .data = &sysctl_mount_max,
2059 .maxlen = sizeof(unsigned int),
2060 .mode = 0644,
2061 .proc_handler = proc_dointvec_minmax,
2062 .extra1 = &one,
2063 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002064 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065};
2066
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002067static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07002068#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002069 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002070 .procname = "exception-trace",
2071 .data = &show_unhandled_signals,
2072 .maxlen = sizeof(int),
2073 .mode = 0644,
2074 .proc_handler = proc_dointvec
2075 },
2076#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002077#if defined(CONFIG_OPTPROBES)
2078 {
2079 .procname = "kprobes-optimization",
2080 .data = &sysctl_kprobes_optimization,
2081 .maxlen = sizeof(int),
2082 .mode = 0644,
2083 .proc_handler = proc_kprobes_optimization_handler,
2084 .extra1 = &zero,
2085 .extra2 = &one,
2086 },
2087#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002088 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089};
2090
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002091static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002092 { }
Robert Love0eeca282005-07-12 17:06:03 -04002093};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002094
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002095int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002096{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002097 struct ctl_table_header *hdr;
2098
2099 hdr = register_sysctl_table(sysctl_base_table);
2100 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002101 return 0;
2102}
2103
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002104#endif /* CONFIG_SYSCTL */
2105
Linus Torvalds1da177e2005-04-16 15:20:36 -07002106/*
2107 * /proc/sys support
2108 */
2109
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002110#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111
Kees Cookf8808302014-06-06 14:37:17 -07002112static int _proc_do_string(char *data, int maxlen, int write,
2113 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002114 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002115{
2116 size_t len;
2117 char __user *p;
2118 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002119
2120 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002121 *lenp = 0;
2122 return 0;
2123 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002124
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002125 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002126 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2127 /* Only continue writes not past the end of buffer. */
2128 len = strlen(data);
2129 if (len > maxlen - 1)
2130 len = maxlen - 1;
2131
2132 if (*ppos > len)
2133 return 0;
2134 len = *ppos;
2135 } else {
2136 /* Start writing from beginning of buffer. */
2137 len = 0;
2138 }
2139
Kees Cook2ca9bb42014-06-06 14:37:18 -07002140 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002141 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002142 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002143 if (get_user(c, p++))
2144 return -EFAULT;
2145 if (c == 0 || c == '\n')
2146 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002147 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002148 }
Kees Cookf8808302014-06-06 14:37:17 -07002149 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002150 } else {
2151 len = strlen(data);
2152 if (len > maxlen)
2153 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002154
2155 if (*ppos > len) {
2156 *lenp = 0;
2157 return 0;
2158 }
2159
2160 data += *ppos;
2161 len -= *ppos;
2162
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002163 if (len > *lenp)
2164 len = *lenp;
2165 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002166 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002167 return -EFAULT;
2168 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002169 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002170 return -EFAULT;
2171 len++;
2172 }
2173 *lenp = len;
2174 *ppos += len;
2175 }
2176 return 0;
2177}
2178
Kees Cookf4aacea2014-06-06 14:37:19 -07002179static void warn_sysctl_write(struct ctl_table *table)
2180{
2181 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2182 "This will not be supported in the future. To silence this\n"
2183 "warning, set kernel.sysctl_writes_strict = -1\n",
2184 current->comm, table->procname);
2185}
2186
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187/**
2188 * proc_dostring - read a string sysctl
2189 * @table: the sysctl table
2190 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 * @buffer: the user buffer
2192 * @lenp: the size of the user buffer
2193 * @ppos: file position
2194 *
2195 * Reads/writes a string from/to the user buffer. If the kernel
2196 * buffer provided is not large enough to hold the string, the
2197 * string is truncated. The copied string is %NULL-terminated.
2198 * If the string is being read by the user process, it is copied
2199 * and a newline '\n' is added. It is truncated if the buffer is
2200 * not large enough.
2201 *
2202 * Returns 0 on success.
2203 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002204int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 void __user *buffer, size_t *lenp, loff_t *ppos)
2206{
Kees Cookf4aacea2014-06-06 14:37:19 -07002207 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2208 warn_sysctl_write(table);
2209
Kees Cookf8808302014-06-06 14:37:17 -07002210 return _proc_do_string((char *)(table->data), table->maxlen, write,
2211 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002212}
2213
Amerigo Wang00b7c332010-05-05 00:26:45 +00002214static size_t proc_skip_spaces(char **buf)
2215{
2216 size_t ret;
2217 char *tmp = skip_spaces(*buf);
2218 ret = tmp - *buf;
2219 *buf = tmp;
2220 return ret;
2221}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002223static void proc_skip_char(char **buf, size_t *size, const char v)
2224{
2225 while (*size) {
2226 if (**buf != v)
2227 break;
2228 (*size)--;
2229 (*buf)++;
2230 }
2231}
2232
Amerigo Wang00b7c332010-05-05 00:26:45 +00002233#define TMPBUFLEN 22
2234/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002235 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002237 * @buf: a kernel buffer
2238 * @size: size of the kernel buffer
2239 * @val: this is where the number will be stored
2240 * @neg: set to %TRUE if number is negative
2241 * @perm_tr: a vector which contains the allowed trailers
2242 * @perm_tr_len: size of the perm_tr vector
2243 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002244 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002245 * In case of success %0 is returned and @buf and @size are updated with
2246 * the amount of bytes read. If @tr is non-NULL and a trailing
2247 * character exists (size is non-zero after returning from this
2248 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002249 */
2250static int proc_get_long(char **buf, size_t *size,
2251 unsigned long *val, bool *neg,
2252 const char *perm_tr, unsigned perm_tr_len, char *tr)
2253{
2254 int len;
2255 char *p, tmp[TMPBUFLEN];
2256
2257 if (!*size)
2258 return -EINVAL;
2259
2260 len = *size;
2261 if (len > TMPBUFLEN - 1)
2262 len = TMPBUFLEN - 1;
2263
2264 memcpy(tmp, *buf, len);
2265
2266 tmp[len] = 0;
2267 p = tmp;
2268 if (*p == '-' && *size > 1) {
2269 *neg = true;
2270 p++;
2271 } else
2272 *neg = false;
2273 if (!isdigit(*p))
2274 return -EINVAL;
2275
2276 *val = simple_strtoul(p, &p, 0);
2277
2278 len = p - tmp;
2279
2280 /* We don't know if the next char is whitespace thus we may accept
2281 * invalid integers (e.g. 1234...a) or two integers instead of one
2282 * (e.g. 123...1). So lets not allow such large numbers. */
2283 if (len == TMPBUFLEN - 1)
2284 return -EINVAL;
2285
2286 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2287 return -EINVAL;
2288
2289 if (tr && (len < *size))
2290 *tr = *p;
2291
2292 *buf += len;
2293 *size -= len;
2294
2295 return 0;
2296}
2297
2298/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002299 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002300 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002301 * @buf: the user buffer
2302 * @size: the size of the user buffer
2303 * @val: the integer to be converted
2304 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002305 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002306 * In case of success %0 is returned and @buf and @size are updated with
2307 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002308 */
2309static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2310 bool neg)
2311{
2312 int len;
2313 char tmp[TMPBUFLEN], *p = tmp;
2314
2315 sprintf(p, "%s%lu", neg ? "-" : "", val);
2316 len = strlen(tmp);
2317 if (len > *size)
2318 len = *size;
2319 if (copy_to_user(*buf, tmp, len))
2320 return -EFAULT;
2321 *size -= len;
2322 *buf += len;
2323 return 0;
2324}
2325#undef TMPBUFLEN
2326
2327static int proc_put_char(void __user **buf, size_t *size, char c)
2328{
2329 if (*size) {
2330 char __user **buffer = (char __user **)buf;
2331 if (put_user(c, *buffer))
2332 return -EFAULT;
2333 (*size)--, (*buffer)++;
2334 *buf = *buffer;
2335 }
2336 return 0;
2337}
2338
2339static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 int *valp,
2341 int write, void *data)
2342{
2343 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002344 if (*negp) {
2345 if (*lvalp > (unsigned long) INT_MAX + 1)
2346 return -EINVAL;
2347 *valp = -*lvalp;
2348 } else {
2349 if (*lvalp > (unsigned long) INT_MAX)
2350 return -EINVAL;
2351 *valp = *lvalp;
2352 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 } else {
2354 int val = *valp;
2355 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002356 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002357 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002359 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 *lvalp = (unsigned long)val;
2361 }
2362 }
2363 return 0;
2364}
2365
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002366static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2367 int *valp,
2368 int write, void *data)
2369{
2370 if (write) {
2371 if (*negp)
2372 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002373 if (*lvalp > UINT_MAX)
2374 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002375 *valp = *lvalp;
2376 } else {
2377 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002378 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002379 *lvalp = (unsigned long)val;
2380 }
2381 return 0;
2382}
2383
Amerigo Wang00b7c332010-05-05 00:26:45 +00002384static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2385
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002386static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002387 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002388 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002389 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 int write, void *data),
2391 void *data)
2392{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002393 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002394 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002395 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396
Amerigo Wang00b7c332010-05-05 00:26:45 +00002397 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398 *lenp = 0;
2399 return 0;
2400 }
2401
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002402 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 vleft = table->maxlen / sizeof(*i);
2404 left = *lenp;
2405
2406 if (!conv)
2407 conv = do_proc_dointvec_conv;
2408
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002410 if (*ppos) {
2411 switch (sysctl_writes_strict) {
2412 case SYSCTL_WRITES_STRICT:
2413 goto out;
2414 case SYSCTL_WRITES_WARN:
2415 warn_sysctl_write(table);
2416 break;
2417 default:
2418 break;
2419 }
2420 }
2421
Amerigo Wang00b7c332010-05-05 00:26:45 +00002422 if (left > PAGE_SIZE - 1)
2423 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002424 p = kbuf = memdup_user_nul(buffer, left);
2425 if (IS_ERR(kbuf))
2426 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002427 }
2428
2429 for (; left && vleft--; i++, first=0) {
2430 unsigned long lval;
2431 bool neg;
2432
2433 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002434 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002435
J. R. Okajima563b0462010-05-25 16:10:14 -07002436 if (!left)
2437 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002438 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002439 proc_wspace_sep,
2440 sizeof(proc_wspace_sep), NULL);
2441 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002443 if (conv(&neg, &lval, i, 1, data)) {
2444 err = -EINVAL;
2445 break;
2446 }
2447 } else {
2448 if (conv(&neg, &lval, i, 0, data)) {
2449 err = -EINVAL;
2450 break;
2451 }
2452 if (!first)
2453 err = proc_put_char(&buffer, &left, '\t');
2454 if (err)
2455 break;
2456 err = proc_put_long(&buffer, &left, lval, neg);
2457 if (err)
2458 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002459 }
2460 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002461
2462 if (!write && !first && left && !err)
2463 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002464 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002465 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002466 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002467 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002468 if (first)
2469 return err ? : -EINVAL;
2470 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002472out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002474 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475}
2476
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002477static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002478 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002479 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002480 int write, void *data),
2481 void *data)
2482{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002483 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002484 buffer, lenp, ppos, conv, data);
2485}
2486
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487/**
2488 * proc_dointvec - read a vector of integers
2489 * @table: the sysctl table
2490 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491 * @buffer: the user buffer
2492 * @lenp: the size of the user buffer
2493 * @ppos: file position
2494 *
2495 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2496 * values from/to the user buffer, treated as an ASCII string.
2497 *
2498 * Returns 0 on success.
2499 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002500int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 void __user *buffer, size_t *lenp, loff_t *ppos)
2502{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002503 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2504}
2505
2506/**
2507 * proc_douintvec - read a vector of unsigned integers
2508 * @table: the sysctl table
2509 * @write: %TRUE if this is a write to the sysctl file
2510 * @buffer: the user buffer
2511 * @lenp: the size of the user buffer
2512 * @ppos: file position
2513 *
2514 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2515 * values from/to the user buffer, treated as an ASCII string.
2516 *
2517 * Returns 0 on success.
2518 */
2519int proc_douintvec(struct ctl_table *table, int write,
2520 void __user *buffer, size_t *lenp, loff_t *ppos)
2521{
2522 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2523 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524}
2525
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002526/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002527 * Taint values can only be increased
2528 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002529 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002530static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002531 void __user *buffer, size_t *lenp, loff_t *ppos)
2532{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002533 struct ctl_table t;
2534 unsigned long tmptaint = get_taint();
2535 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002536
Bastian Blank91fcd412007-04-23 14:41:14 -07002537 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002538 return -EPERM;
2539
Andi Kleen25ddbb12008-10-15 22:01:41 -07002540 t = *table;
2541 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002542 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002543 if (err < 0)
2544 return err;
2545
2546 if (write) {
2547 /*
2548 * Poor man's atomic or. Not worth adding a primitive
2549 * to everyone's atomic.h for this
2550 */
2551 int i;
2552 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2553 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302554 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002555 }
2556 }
2557
2558 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002559}
2560
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002561#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002562static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002563 void __user *buffer, size_t *lenp, loff_t *ppos)
2564{
2565 if (write && !capable(CAP_SYS_ADMIN))
2566 return -EPERM;
2567
2568 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2569}
2570#endif
2571
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572struct do_proc_dointvec_minmax_conv_param {
2573 int *min;
2574 int *max;
2575};
2576
Amerigo Wang00b7c332010-05-05 00:26:45 +00002577static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2578 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579 int write, void *data)
2580{
2581 struct do_proc_dointvec_minmax_conv_param *param = data;
2582 if (write) {
Zev Weiss45a67f12019-03-11 23:28:02 -07002583 int val;
2584 if (*negp) {
2585 if (*lvalp > (unsigned long) INT_MAX + 1)
2586 return -EINVAL;
2587 val = -*lvalp;
2588 } else {
2589 if (*lvalp > (unsigned long) INT_MAX)
2590 return -EINVAL;
2591 val = *lvalp;
2592 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 if ((param->min && *param->min > val) ||
2594 (param->max && *param->max < val))
2595 return -EINVAL;
2596 *valp = val;
2597 } else {
2598 int val = *valp;
2599 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002600 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002601 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002603 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002604 *lvalp = (unsigned long)val;
2605 }
2606 }
2607 return 0;
2608}
2609
2610/**
2611 * proc_dointvec_minmax - read a vector of integers with min/max values
2612 * @table: the sysctl table
2613 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614 * @buffer: the user buffer
2615 * @lenp: the size of the user buffer
2616 * @ppos: file position
2617 *
2618 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2619 * values from/to the user buffer, treated as an ASCII string.
2620 *
2621 * This routine will ensure the values are within the range specified by
2622 * table->extra1 (min) and table->extra2 (max).
2623 *
2624 * Returns 0 on success.
2625 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002626int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627 void __user *buffer, size_t *lenp, loff_t *ppos)
2628{
2629 struct do_proc_dointvec_minmax_conv_param param = {
2630 .min = (int *) table->extra1,
2631 .max = (int *) table->extra2,
2632 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002633 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 do_proc_dointvec_minmax_conv, &param);
2635}
2636
Kees Cook54b50192012-07-30 14:39:18 -07002637static void validate_coredump_safety(void)
2638{
Alex Kelly046d6622012-10-04 17:15:23 -07002639#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002640 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002641 core_pattern[0] != '/' && core_pattern[0] != '|') {
2642 printk(KERN_WARNING "Unsafe core_pattern used with "\
2643 "suid_dumpable=2. Pipe handler or fully qualified "\
2644 "core dump path required.\n");
2645 }
Alex Kelly046d6622012-10-04 17:15:23 -07002646#endif
Kees Cook54b50192012-07-30 14:39:18 -07002647}
2648
2649static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2650 void __user *buffer, size_t *lenp, loff_t *ppos)
2651{
2652 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2653 if (!error)
2654 validate_coredump_safety();
2655 return error;
2656}
2657
Alex Kelly046d6622012-10-04 17:15:23 -07002658#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002659static int proc_dostring_coredump(struct ctl_table *table, int write,
2660 void __user *buffer, size_t *lenp, loff_t *ppos)
2661{
2662 int error = proc_dostring(table, write, buffer, lenp, ppos);
2663 if (!error)
2664 validate_coredump_safety();
2665 return error;
2666}
Alex Kelly046d6622012-10-04 17:15:23 -07002667#endif
Kees Cook54b50192012-07-30 14:39:18 -07002668
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002669static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 void __user *buffer,
2671 size_t *lenp, loff_t *ppos,
2672 unsigned long convmul,
2673 unsigned long convdiv)
2674{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002675 unsigned long *i, *min, *max;
2676 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002677 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002678 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002679
2680 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681 *lenp = 0;
2682 return 0;
2683 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002684
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002685 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 min = (unsigned long *) table->extra1;
2687 max = (unsigned long *) table->extra2;
2688 vleft = table->maxlen / sizeof(unsigned long);
2689 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002690
2691 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002692 if (*ppos) {
2693 switch (sysctl_writes_strict) {
2694 case SYSCTL_WRITES_STRICT:
2695 goto out;
2696 case SYSCTL_WRITES_WARN:
2697 warn_sysctl_write(table);
2698 break;
2699 default:
2700 break;
2701 }
2702 }
2703
Amerigo Wang00b7c332010-05-05 00:26:45 +00002704 if (left > PAGE_SIZE - 1)
2705 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002706 p = kbuf = memdup_user_nul(buffer, left);
2707 if (IS_ERR(kbuf))
2708 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002709 }
2710
Eric Dumazet27b3d802010-10-07 12:59:29 -07002711 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002712 unsigned long val;
2713
Linus Torvalds1da177e2005-04-16 15:20:36 -07002714 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002715 bool neg;
2716
Al Viro70f6cbb2015-12-24 00:13:10 -05002717 left -= proc_skip_spaces(&p);
Cheng Lin0e5c7502019-01-03 15:26:13 -08002718 if (!left)
2719 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002720
Al Viro70f6cbb2015-12-24 00:13:10 -05002721 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002722 proc_wspace_sep,
2723 sizeof(proc_wspace_sep), NULL);
2724 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002725 break;
2726 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002728 val = convmul * val / convdiv;
Christian Brauner726f69d2019-05-14 15:44:55 -07002729 if ((min && val < *min) || (max && val > *max)) {
2730 err = -EINVAL;
2731 break;
2732 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733 *i = val;
2734 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002735 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002736 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002737 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002738 if (err)
2739 break;
2740 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002741 err = proc_put_long(&buffer, &left, val, false);
2742 if (err)
2743 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002744 }
2745 }
2746
Amerigo Wang00b7c332010-05-05 00:26:45 +00002747 if (!write && !first && left && !err)
2748 err = proc_put_char(&buffer, &left, '\n');
2749 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002750 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002752 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002753 if (first)
2754 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002756 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002757out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002758 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002759 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002760}
2761
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002762static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002763 void __user *buffer,
2764 size_t *lenp, loff_t *ppos,
2765 unsigned long convmul,
2766 unsigned long convdiv)
2767{
2768 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002769 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002770}
2771
Linus Torvalds1da177e2005-04-16 15:20:36 -07002772/**
2773 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2774 * @table: the sysctl table
2775 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002776 * @buffer: the user buffer
2777 * @lenp: the size of the user buffer
2778 * @ppos: file position
2779 *
2780 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2781 * values from/to the user buffer, treated as an ASCII string.
2782 *
2783 * This routine will ensure the values are within the range specified by
2784 * table->extra1 (min) and table->extra2 (max).
2785 *
2786 * Returns 0 on success.
2787 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002788int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002789 void __user *buffer, size_t *lenp, loff_t *ppos)
2790{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002791 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002792}
2793
2794/**
2795 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2796 * @table: the sysctl table
2797 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002798 * @buffer: the user buffer
2799 * @lenp: the size of the user buffer
2800 * @ppos: file position
2801 *
2802 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2803 * values from/to the user buffer, treated as an ASCII string. The values
2804 * are treated as milliseconds, and converted to jiffies when they are stored.
2805 *
2806 * This routine will ensure the values are within the range specified by
2807 * table->extra1 (min) and table->extra2 (max).
2808 *
2809 * Returns 0 on success.
2810 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002811int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002812 void __user *buffer,
2813 size_t *lenp, loff_t *ppos)
2814{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002815 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002816 lenp, ppos, HZ, 1000l);
2817}
2818
2819
Amerigo Wang00b7c332010-05-05 00:26:45 +00002820static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002821 int *valp,
2822 int write, void *data)
2823{
2824 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002825 if (*lvalp > LONG_MAX / HZ)
2826 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002827 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2828 } else {
2829 int val = *valp;
2830 unsigned long lval;
2831 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002832 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002833 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002834 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002835 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002836 lval = (unsigned long)val;
2837 }
2838 *lvalp = lval / HZ;
2839 }
2840 return 0;
2841}
2842
Amerigo Wang00b7c332010-05-05 00:26:45 +00002843static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002844 int *valp,
2845 int write, void *data)
2846{
2847 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002848 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2849 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002850 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2851 } else {
2852 int val = *valp;
2853 unsigned long lval;
2854 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002855 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002856 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002858 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002859 lval = (unsigned long)val;
2860 }
2861 *lvalp = jiffies_to_clock_t(lval);
2862 }
2863 return 0;
2864}
2865
Amerigo Wang00b7c332010-05-05 00:26:45 +00002866static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002867 int *valp,
2868 int write, void *data)
2869{
2870 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002871 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2872
2873 if (jif > INT_MAX)
2874 return 1;
2875 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002876 } else {
2877 int val = *valp;
2878 unsigned long lval;
2879 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002880 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002881 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002882 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002883 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884 lval = (unsigned long)val;
2885 }
2886 *lvalp = jiffies_to_msecs(lval);
2887 }
2888 return 0;
2889}
2890
2891/**
2892 * proc_dointvec_jiffies - read a vector of integers as seconds
2893 * @table: the sysctl table
2894 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002895 * @buffer: the user buffer
2896 * @lenp: the size of the user buffer
2897 * @ppos: file position
2898 *
2899 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2900 * values from/to the user buffer, treated as an ASCII string.
2901 * The values read are assumed to be in seconds, and are converted into
2902 * jiffies.
2903 *
2904 * Returns 0 on success.
2905 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002906int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907 void __user *buffer, size_t *lenp, loff_t *ppos)
2908{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002909 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002910 do_proc_dointvec_jiffies_conv,NULL);
2911}
2912
2913/**
2914 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2915 * @table: the sysctl table
2916 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002917 * @buffer: the user buffer
2918 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002919 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920 *
2921 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2922 * values from/to the user buffer, treated as an ASCII string.
2923 * The values read are assumed to be in 1/USER_HZ seconds, and
2924 * are converted into jiffies.
2925 *
2926 * Returns 0 on success.
2927 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002928int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002929 void __user *buffer, size_t *lenp, loff_t *ppos)
2930{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002931 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932 do_proc_dointvec_userhz_jiffies_conv,NULL);
2933}
2934
2935/**
2936 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2937 * @table: the sysctl table
2938 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002939 * @buffer: the user buffer
2940 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002941 * @ppos: file position
2942 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 *
2944 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2945 * values from/to the user buffer, treated as an ASCII string.
2946 * The values read are assumed to be in 1/1000 seconds, and
2947 * are converted into jiffies.
2948 *
2949 * Returns 0 on success.
2950 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002951int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952 void __user *buffer, size_t *lenp, loff_t *ppos)
2953{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002954 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955 do_proc_dointvec_ms_jiffies_conv, NULL);
2956}
2957
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002958static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002959 void __user *buffer, size_t *lenp, loff_t *ppos)
2960{
2961 struct pid *new_pid;
2962 pid_t tmp;
2963 int r;
2964
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002965 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002966
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002967 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002968 lenp, ppos, NULL, NULL);
2969 if (r || !write)
2970 return r;
2971
2972 new_pid = find_get_pid(tmp);
2973 if (!new_pid)
2974 return -ESRCH;
2975
2976 put_pid(xchg(&cad_pid, new_pid));
2977 return 0;
2978}
2979
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002980/**
2981 * proc_do_large_bitmap - read/write from/to a large bitmap
2982 * @table: the sysctl table
2983 * @write: %TRUE if this is a write to the sysctl file
2984 * @buffer: the user buffer
2985 * @lenp: the size of the user buffer
2986 * @ppos: file position
2987 *
2988 * The bitmap is stored at table->data and the bitmap length (in bits)
2989 * in table->maxlen.
2990 *
2991 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2992 * large bitmaps may be represented in a compact manner. Writing into
2993 * the file will clear the bitmap then update it with the given input.
2994 *
2995 * Returns 0 on success.
2996 */
2997int proc_do_large_bitmap(struct ctl_table *table, int write,
2998 void __user *buffer, size_t *lenp, loff_t *ppos)
2999{
3000 int err = 0;
3001 bool first = 1;
3002 size_t left = *lenp;
3003 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07003004 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003005 unsigned long *tmp_bitmap = NULL;
3006 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3007
WANG Cong122ff242014-05-12 16:04:53 -07003008 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003009 *lenp = 0;
3010 return 0;
3011 }
3012
3013 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003014 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003015
3016 if (left > PAGE_SIZE - 1)
3017 left = PAGE_SIZE - 1;
3018
Al Viro70f6cbb2015-12-24 00:13:10 -05003019 p = kbuf = memdup_user_nul(buffer, left);
3020 if (IS_ERR(kbuf))
3021 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003022
3023 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
3024 GFP_KERNEL);
3025 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003026 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003027 return -ENOMEM;
3028 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003029 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003030 while (!err && left) {
3031 unsigned long val_a, val_b;
3032 bool neg;
3033
Al Viro70f6cbb2015-12-24 00:13:10 -05003034 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003035 sizeof(tr_a), &c);
3036 if (err)
3037 break;
3038 if (val_a >= bitmap_len || neg) {
3039 err = -EINVAL;
3040 break;
3041 }
3042
3043 val_b = val_a;
3044 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003045 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003046 left--;
3047 }
3048
3049 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05003050 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003051 &neg, tr_b, sizeof(tr_b),
3052 &c);
3053 if (err)
3054 break;
3055 if (val_b >= bitmap_len || neg ||
3056 val_a > val_b) {
3057 err = -EINVAL;
3058 break;
3059 }
3060 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003061 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003062 left--;
3063 }
3064 }
3065
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003066 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003067 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003068 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003069 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003070 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003071 } else {
3072 unsigned long bit_a, bit_b = 0;
3073
3074 while (left) {
3075 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3076 if (bit_a >= bitmap_len)
3077 break;
3078 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3079 bit_a + 1) - 1;
3080
3081 if (!first) {
3082 err = proc_put_char(&buffer, &left, ',');
3083 if (err)
3084 break;
3085 }
3086 err = proc_put_long(&buffer, &left, bit_a, false);
3087 if (err)
3088 break;
3089 if (bit_a != bit_b) {
3090 err = proc_put_char(&buffer, &left, '-');
3091 if (err)
3092 break;
3093 err = proc_put_long(&buffer, &left, bit_b, false);
3094 if (err)
3095 break;
3096 }
3097
3098 first = 0; bit_b++;
3099 }
3100 if (!err)
3101 err = proc_put_char(&buffer, &left, '\n');
3102 }
3103
3104 if (!err) {
3105 if (write) {
3106 if (*ppos)
3107 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3108 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003109 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003110 }
3111 kfree(tmp_bitmap);
3112 *lenp -= left;
3113 *ppos += *lenp;
3114 return 0;
3115 } else {
3116 kfree(tmp_bitmap);
3117 return err;
3118 }
3119}
3120
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003121static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp,
3122 int *valp, int write, void *data)
3123{
3124 if (write) {
Satya Durga Srinivasu Prabhala3929bf02018-08-24 12:23:08 -07003125 if (*negp || *lvalp == 0)
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003126 return -EINVAL;
3127 *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp;
3128 } else {
3129 *negp = false;
3130 *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp;
3131 }
3132
3133 return 0;
3134}
3135
3136/**
3137 * proc_douintvec_capacity - read a vector of integers in percentage and convert
3138 * into sched capacity
3139 * @table: the sysctl table
3140 * @write: %TRUE if this is a write to the sysctl file
3141 * @buffer: the user buffer
3142 * @lenp: the size of the user buffer
3143 * @ppos: file position
3144 *
3145 * Returns 0 on success.
3146 */
3147int proc_douintvec_capacity(struct ctl_table *table, int write,
3148 void __user *buffer, size_t *lenp, loff_t *ppos)
3149{
3150 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3151 do_proc_douintvec_capacity_conv, NULL);
3152}
3153
Jovi Zhang55610502011-01-12 17:00:45 -08003154#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003155
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003156int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157 void __user *buffer, size_t *lenp, loff_t *ppos)
3158{
3159 return -ENOSYS;
3160}
3161
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003162int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003163 void __user *buffer, size_t *lenp, loff_t *ppos)
3164{
3165 return -ENOSYS;
3166}
3167
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003168int proc_douintvec(struct ctl_table *table, int write,
3169 void __user *buffer, size_t *lenp, loff_t *ppos)
3170{
3171 return -ENOSYS;
3172}
3173
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003174int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003175 void __user *buffer, size_t *lenp, loff_t *ppos)
3176{
3177 return -ENOSYS;
3178}
3179
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003180int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003181 void __user *buffer, size_t *lenp, loff_t *ppos)
3182{
3183 return -ENOSYS;
3184}
3185
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003186int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003187 void __user *buffer, size_t *lenp, loff_t *ppos)
3188{
3189 return -ENOSYS;
3190}
3191
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003192int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003193 void __user *buffer, size_t *lenp, loff_t *ppos)
3194{
3195 return -ENOSYS;
3196}
3197
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003198int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003199 void __user *buffer, size_t *lenp, loff_t *ppos)
3200{
3201 return -ENOSYS;
3202}
3203
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003204int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205 void __user *buffer,
3206 size_t *lenp, loff_t *ppos)
3207{
3208 return -ENOSYS;
3209}
3210
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003211int proc_douintvec_capacity(struct ctl_table *table, int write,
3212 void __user *buffer, size_t *lenp, loff_t *ppos)
3213{
3214 return -ENOSYS;
3215}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003216
Jovi Zhang55610502011-01-12 17:00:45 -08003217#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003218
Linus Torvalds1da177e2005-04-16 15:20:36 -07003219/*
3220 * No sense putting this after each symbol definition, twice,
3221 * exception granted :-)
3222 */
3223EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003224EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003225EXPORT_SYMBOL(proc_dointvec_jiffies);
3226EXPORT_SYMBOL(proc_dointvec_minmax);
3227EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3228EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3229EXPORT_SYMBOL(proc_dostring);
3230EXPORT_SYMBOL(proc_doulongvec_minmax);
3231EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);