blob: 47f88bb5b3cfce74a52d80cf846570c30970428e [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>
tracychui2f9f3682020-06-12 17:46:51 +080069#include <soc/qcom/smem.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71#include <asm/uaccess.h>
72#include <asm/processor.h>
73
Andi Kleen29cbc782006-09-30 01:47:55 +020074#ifdef CONFIG_X86
75#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010076#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010077#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020078#endif
David Howellsd550bbd2012-03-28 18:30:03 +010079#ifdef CONFIG_SPARC
80#include <asm/setup.h>
81#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080082#ifdef CONFIG_BSD_PROCESS_ACCT
83#include <linux/acct.h>
84#endif
Dave Young4f0e0562010-03-10 15:24:09 -080085#ifdef CONFIG_RT_MUTEXES
86#include <linux/rtmutex.h>
87#endif
Dave Young2edf5e42010-03-10 15:24:10 -080088#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
89#include <linux/lockdep.h>
90#endif
Dave Young15485a42010-03-10 15:24:07 -080091#ifdef CONFIG_CHR_DEV_SG
92#include <scsi/sg.h>
93#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020094
Don Zickus58687ac2010-05-07 17:11:44 -040095#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050096#include <linux/nmi.h>
97#endif
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#if defined(CONFIG_SYSCTL)
100
101/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700102extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700103#ifdef CONFIG_COREDUMP
104extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700106extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700107#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800110extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100111extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300112extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000113#ifndef CONFIG_MMU
114extern int sysctl_nr_trim_pages;
115#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400118#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119static int sixty = 60;
120#endif
121
Aaron Tomlin270750db2014-01-20 17:34:13 +0000122static int __maybe_unused neg_one = -1;
123
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700125static int __maybe_unused one = 1;
126static int __maybe_unused two = 2;
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700127static int __maybe_unused three = 3;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700128static int __maybe_unused four = 4;
Will Deacon3141fcc2019-04-05 18:39:38 -0700129static unsigned long zero_ul;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800130static unsigned long one_ul = 1;
Christian Brauner6b65c262019-03-07 16:29:43 -0800131static unsigned long long_max = LONG_MAX;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132static int one_hundred = 100;
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700133static int __maybe_unused one_thousand = 1000;
Satya Durga Srinivasu Prabhalac18b4032018-04-17 11:21:23 -0700134#ifdef CONFIG_SCHED_WALT
135static int two_million = 2000000;
136#endif
Dave Youngaf913222009-09-22 16:43:33 -0700137#ifdef CONFIG_PRINTK
138static int ten_thousand = 10000;
139#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300140#ifdef CONFIG_PERF_EVENTS
141static int six_hundred_forty_kb = 640 * 1024;
142#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700143
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700144/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
145static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
148static int maxolduid = 65535;
149static int minolduid;
150
151static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700152static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Liu Hua80df2842014-04-07 15:38:57 -0700154/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
155#ifdef CONFIG_DETECT_HUNG_TASK
156static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
157#endif
158
Dave Youngd14f1722010-02-25 20:28:57 -0500159#ifdef CONFIG_INOTIFY_USER
160#include <linux/inotify.h>
161#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700162#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163#endif
164
165#ifdef __hppa__
166extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530167#endif
168
169#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170extern int unaligned_enabled;
171#endif
172
Jes Sorensend2b176e2006-02-28 09:42:23 -0800173#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800174extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800175#endif
176
Vineet Guptab6fca722013-01-09 20:06:28 +0530177#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
178extern int no_unaligned_warning;
179#endif
180
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700181#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700182
183#define SYSCTL_WRITES_LEGACY -1
184#define SYSCTL_WRITES_WARN 0
185#define SYSCTL_WRITES_STRICT 1
186
Kees Cook41662f52016-01-20 15:00:45 -0800187static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700188
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700189static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700190 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700191static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800192 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700193#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700194
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700195#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700196static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700197 void __user *buffer, size_t *lenp, loff_t *ppos);
198#endif
199
Kees Cook54b50192012-07-30 14:39:18 -0700200static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
201 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700202#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700203static int proc_dostring_coredump(struct ctl_table *table, int write,
204 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700205#endif
Kees Cook54b50192012-07-30 14:39:18 -0700206
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700207#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800208/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100209static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700210
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700211static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700212 void __user *buffer, size_t *lenp,
213 loff_t *ppos)
214{
215 int error;
216
217 error = proc_dointvec(table, write, buffer, lenp, ppos);
218 if (error)
219 return error;
220
221 if (write)
222 sysrq_toggle_support(__sysrq_enabled);
223
224 return 0;
225}
226
227#endif
228
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700229static struct ctl_table kern_table[];
230static struct ctl_table vm_table[];
231static struct ctl_table fs_table[];
232static struct ctl_table debug_table[];
233static struct ctl_table dev_table[];
tracychui2f9f3682020-06-12 17:46:51 +0800234static struct ctl_table qpnp_power_on_table[];
235static struct ctl_table ddr_table[];
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700236extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800237#ifdef CONFIG_EPOLL
238extern struct ctl_table epoll_table[];
239#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
241#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
242int sysctl_legacy_va_layout;
243#endif
244
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245/* The default sysctl tables: */
246
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800247static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .procname = "kernel",
250 .mode = 0555,
251 .child = kern_table,
252 },
253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 .procname = "vm",
255 .mode = 0555,
256 .child = vm_table,
257 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 .procname = "fs",
260 .mode = 0555,
261 .child = fs_table,
262 },
263 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 .procname = "debug",
265 .mode = 0555,
266 .child = debug_table,
267 },
268 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 .procname = "dev",
270 .mode = 0555,
271 .child = dev_table,
272 },
tracychui2f9f3682020-06-12 17:46:51 +0800273 {
274 .procname = "qpnp-power-on",
275 .mode = 0555,
276 .child = qpnp_power_on_table,
277 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700278 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279};
280
Ingo Molnar77e54a12007-07-09 18:52:00 +0200281#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100282static int min_sched_granularity_ns = 100000; /* 100 usecs */
283static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
284static int min_wakeup_granularity_ns; /* 0 usecs */
285static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200286#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100287static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
288static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200289#endif /* CONFIG_SMP */
290#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200291
Mel Gorman5e771902010-05-24 14:32:31 -0700292#ifdef CONFIG_COMPACTION
293static int min_extfrag_threshold;
294static int max_extfrag_threshold = 1000;
295#endif
296
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700297static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200298 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200299 .procname = "sched_child_runs_first",
300 .data = &sysctl_sched_child_runs_first,
301 .maxlen = sizeof(unsigned int),
302 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800303 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200304 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530305#if defined(CONFIG_PREEMPT_TRACER) || defined(CONFIG_IRQSOFF_TRACER)
306 {
307 .procname = "preemptoff_tracing_threshold_ns",
308 .data = &sysctl_preemptoff_tracing_threshold_ns,
309 .maxlen = sizeof(unsigned int),
310 .mode = 0644,
311 .proc_handler = proc_dointvec,
312 },
Pavankumar Kondeti0d2621b2018-03-26 15:56:26 +0530313 {
314 .procname = "irqsoff_tracing_threshold_ns",
315 .data = &sysctl_irqsoff_tracing_threshold_ns,
316 .maxlen = sizeof(unsigned int),
317 .mode = 0644,
318 .proc_handler = proc_dointvec,
319 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530320#endif
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800321#ifdef CONFIG_SCHED_WALT
322 {
323 .procname = "sched_cpu_high_irqload",
324 .data = &sysctl_sched_cpu_high_irqload,
325 .maxlen = sizeof(unsigned int),
326 .mode = 0644,
327 .proc_handler = proc_dointvec,
328 },
Joonwoo Park6f188472017-06-16 11:32:17 -0700329 {
330 .procname = "sched_group_upmigrate",
331 .data = &sysctl_sched_group_upmigrate_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 = &sysctl_sched_group_downmigrate_pct,
336 },
337 {
338 .procname = "sched_group_downmigrate",
339 .data = &sysctl_sched_group_downmigrate_pct,
340 .maxlen = sizeof(unsigned int),
341 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700342 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700343 .extra1 = &zero,
344 .extra2 = &sysctl_sched_group_upmigrate_pct,
345 },
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530346 {
347 .procname = "sched_boost",
348 .data = &sysctl_sched_boost,
349 .maxlen = sizeof(unsigned int),
350 .mode = 0644,
351 .proc_handler = sched_boost_handler,
352 .extra1 = &zero,
353 .extra2 = &three,
354 },
Pavankumar Kondeti4e13d112018-01-25 01:12:08 +0530355 {
356 .procname = "sched_walt_rotate_big_tasks",
357 .data = &sysctl_sched_walt_rotate_big_tasks,
358 .maxlen = sizeof(unsigned int),
359 .mode = 0644,
360 .proc_handler = proc_dointvec_minmax,
361 .extra1 = &zero,
362 .extra2 = &one,
363 },
Lingutla Chandrasekhar57eb0712018-03-12 10:20:08 +0530364 {
365 .procname = "sched_initial_task_util",
366 .data = &sysctl_sched_init_task_load_pct,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
369 .proc_handler = proc_dointvec,
370 },
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700371 {
372 .procname = "sched_min_task_util_for_boost_colocation",
373 .data = &sysctl_sched_min_task_util_for_boost_colocation,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec_minmax,
377 .extra1 = &zero,
378 .extra2 = &one_thousand,
379 },
Satya Durga Srinivasu Prabhalac18b4032018-04-17 11:21:23 -0700380 {
381 .procname = "sched_little_cluster_coloc_fmin_khz",
382 .data = &sysctl_sched_little_cluster_coloc_fmin_khz,
383 .maxlen = sizeof(unsigned int),
384 .mode = 0644,
385 .proc_handler = sched_little_cluster_coloc_fmin_khz_handler,
386 .extra1 = &zero,
387 .extra2 = &two_million,
388 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800389#endif
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530390 {
391 .procname = "sched_upmigrate",
392 .data = &sysctl_sched_capacity_margin,
393 .maxlen = sizeof(unsigned int),
394 .mode = 0644,
395 .proc_handler = sched_updown_migrate_handler,
396 },
397 {
398 .procname = "sched_downmigrate",
399 .data = &sysctl_sched_capacity_margin_down,
400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
402 .proc_handler = sched_updown_migrate_handler,
403 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200404#ifdef CONFIG_SCHED_DEBUG
405 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100406 .procname = "sched_min_granularity_ns",
407 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200408 .maxlen = sizeof(unsigned int),
409 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800410 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100411 .extra1 = &min_sched_granularity_ns,
412 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200413 },
414 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200415 .procname = "sched_latency_ns",
416 .data = &sysctl_sched_latency,
417 .maxlen = sizeof(unsigned int),
418 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800419 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200420 .extra1 = &min_sched_granularity_ns,
421 .extra2 = &max_sched_granularity_ns,
422 },
423 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000424 .procname = "sched_sync_hint_enable",
425 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100426 .maxlen = sizeof(unsigned int),
427 .mode = 0644,
428 .proc_handler = proc_dointvec,
429 },
430 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100431 .procname = "sched_cstate_aware",
432 .data = &sysctl_sched_cstate_aware,
433 .maxlen = sizeof(unsigned int),
434 .mode = 0644,
435 .proc_handler = proc_dointvec,
436 },
437 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200438 .procname = "sched_wakeup_granularity_ns",
439 .data = &sysctl_sched_wakeup_granularity,
440 .maxlen = sizeof(unsigned int),
441 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800442 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200443 .extra1 = &min_wakeup_granularity_ns,
444 .extra2 = &max_wakeup_granularity_ns,
445 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200446#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200447 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100448 .procname = "sched_tunable_scaling",
449 .data = &sysctl_sched_tunable_scaling,
450 .maxlen = sizeof(enum sched_tunable_scaling),
451 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800452 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100453 .extra1 = &min_sched_tunable_scaling,
454 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200455 },
456 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900457 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200458 .data = &sysctl_sched_migration_cost,
459 .maxlen = sizeof(unsigned int),
460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800461 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200462 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100463 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100464 .procname = "sched_nr_migrate",
465 .data = &sysctl_sched_nr_migrate,
466 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100469 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530470 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900471 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200472 .data = &sysctl_sched_time_avg,
473 .maxlen = sizeof(unsigned int),
474 .mode = 0644,
Pavankumar Kondeti12939492017-02-02 14:24:34 +0530475 .proc_handler = proc_dointvec_minmax,
476 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200477 },
478 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900479 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800480 .data = &sysctl_sched_shares_window,
481 .maxlen = sizeof(unsigned int),
482 .mode = 0644,
483 .proc_handler = proc_dointvec,
484 },
Mel Gormancb251762016-02-05 09:08:36 +0000485#ifdef CONFIG_SCHEDSTATS
486 {
487 .procname = "sched_schedstats",
488 .data = NULL,
489 .maxlen = sizeof(unsigned int),
490 .mode = 0644,
491 .proc_handler = sysctl_schedstats,
492 .extra1 = &zero,
493 .extra2 = &one,
494 },
495#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200496#endif /* CONFIG_SMP */
497#ifdef CONFIG_NUMA_BALANCING
498 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200499 .procname = "numa_balancing_scan_delay_ms",
500 .data = &sysctl_numa_balancing_scan_delay,
501 .maxlen = sizeof(unsigned int),
502 .mode = 0644,
503 .proc_handler = proc_dointvec,
504 },
505 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200506 .procname = "numa_balancing_scan_period_min_ms",
507 .data = &sysctl_numa_balancing_scan_period_min,
508 .maxlen = sizeof(unsigned int),
509 .mode = 0644,
510 .proc_handler = proc_dointvec,
511 },
512 {
513 .procname = "numa_balancing_scan_period_max_ms",
514 .data = &sysctl_numa_balancing_scan_period_max,
515 .maxlen = sizeof(unsigned int),
516 .mode = 0644,
517 .proc_handler = proc_dointvec,
518 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200519 {
520 .procname = "numa_balancing_scan_size_mb",
521 .data = &sysctl_numa_balancing_scan_size,
522 .maxlen = sizeof(unsigned int),
523 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400524 .proc_handler = proc_dointvec_minmax,
525 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200526 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100527 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800528 .procname = "numa_balancing",
529 .data = NULL, /* filled in by handler */
530 .maxlen = sizeof(unsigned int),
531 .mode = 0644,
532 .proc_handler = sysctl_numa_balancing,
533 .extra1 = &zero,
534 .extra2 = &one,
535 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200536#endif /* CONFIG_NUMA_BALANCING */
537#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200538 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100539 .procname = "sched_rt_period_us",
540 .data = &sysctl_sched_rt_period,
541 .maxlen = sizeof(unsigned int),
542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800543 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100544 },
545 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100546 .procname = "sched_rt_runtime_us",
547 .data = &sysctl_sched_rt_runtime,
548 .maxlen = sizeof(int),
549 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800550 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100551 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600552 {
553 .procname = "sched_rr_timeslice_ms",
554 .data = &sched_rr_timeslice,
555 .maxlen = sizeof(int),
556 .mode = 0644,
557 .proc_handler = sched_rr_handler,
558 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100559#ifdef CONFIG_SCHED_AUTOGROUP
560 {
561 .procname = "sched_autogroup_enabled",
562 .data = &sysctl_sched_autogroup_enabled,
563 .maxlen = sizeof(unsigned int),
564 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800565 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100566 .extra1 = &zero,
567 .extra2 = &one,
568 },
569#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700570#ifdef CONFIG_CFS_BANDWIDTH
571 {
572 .procname = "sched_cfs_bandwidth_slice_us",
573 .data = &sysctl_sched_cfs_bandwidth_slice,
574 .maxlen = sizeof(unsigned int),
575 .mode = 0644,
576 .proc_handler = proc_dointvec_minmax,
577 .extra1 = &one,
578 },
579#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100580#ifdef CONFIG_SCHED_TUNE
581 {
582 .procname = "sched_cfs_boost",
583 .data = &sysctl_sched_cfs_boost,
584 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100585#ifdef CONFIG_CGROUP_SCHEDTUNE
586 .mode = 0444,
587#else
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100588 .mode = 0644,
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100589#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100590 .proc_handler = &sysctl_sched_cfs_boost_handler,
591 .extra1 = &zero,
592 .extra2 = &one_hundred,
593 },
594#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700595#ifdef CONFIG_PROVE_LOCKING
596 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700597 .procname = "prove_locking",
598 .data = &prove_locking,
599 .maxlen = sizeof(int),
600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700602 },
603#endif
604#ifdef CONFIG_LOCK_STAT
605 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700606 .procname = "lock_stat",
607 .data = &lock_stat,
608 .maxlen = sizeof(int),
609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700611 },
612#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200613 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .procname = "panic",
615 .data = &panic_timeout,
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 },
Alex Kelly046d6622012-10-04 17:15:23 -0700620#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 .procname = "core_uses_pid",
623 .data = &core_uses_pid,
624 .maxlen = sizeof(int),
625 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800626 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 },
628 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 .procname = "core_pattern",
630 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700631 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700633 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 },
Neil Hormana2939802009-09-23 15:56:56 -0700635 {
Neil Hormana2939802009-09-23 15:56:56 -0700636 .procname = "core_pipe_limit",
637 .data = &core_pipe_limit,
638 .maxlen = sizeof(unsigned int),
639 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800640 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700641 },
Alex Kelly046d6622012-10-04 17:15:23 -0700642#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800643#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700646 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800647 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800648 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700650 {
651 .procname = "sysctl_writes_strict",
652 .data = &sysctl_writes_strict,
653 .maxlen = sizeof(int),
654 .mode = 0644,
655 .proc_handler = proc_dointvec_minmax,
656 .extra1 = &neg_one,
657 .extra2 = &one,
658 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800659#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100660#ifdef CONFIG_LATENCYTOP
661 {
662 .procname = "latencytop",
663 .data = &latencytop_enabled,
664 .maxlen = sizeof(int),
665 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000666 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100667 },
668#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669#ifdef CONFIG_BLK_DEV_INITRD
670 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .procname = "real-root-dev",
672 .data = &real_root_dev,
673 .maxlen = sizeof(int),
674 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800675 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 },
677#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700678 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700679 .procname = "print-fatal-signals",
680 .data = &print_fatal_signals,
681 .maxlen = sizeof(int),
682 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700684 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700685#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .procname = "reboot-cmd",
688 .data = reboot_command,
689 .maxlen = 256,
690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800691 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 },
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "stop-a",
695 .data = &stop_a_enabled,
696 .maxlen = sizeof (int),
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 },
700 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 .procname = "scons-poweroff",
702 .data = &scons_pwroff,
703 .maxlen = sizeof (int),
704 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800705 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 },
707#endif
David S. Miller08714202008-11-16 23:49:24 -0800708#ifdef CONFIG_SPARC64
709 {
David S. Miller08714202008-11-16 23:49:24 -0800710 .procname = "tsb-ratio",
711 .data = &sysctl_tsb_ratio,
712 .maxlen = sizeof (int),
713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800715 },
716#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717#ifdef __hppa__
718 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .procname = "soft-power",
720 .data = &pwrsw_enabled,
721 .maxlen = sizeof (int),
722 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800723 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530725#endif
726#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 .procname = "unaligned-trap",
729 .data = &unaligned_enabled,
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 },
734#endif
735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 .procname = "ctrl-alt-del",
737 .data = &C_A_D,
738 .maxlen = sizeof(int),
739 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800740 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400742#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200743 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200744 .procname = "ftrace_enabled",
745 .data = &ftrace_enabled,
746 .maxlen = sizeof(int),
747 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800748 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200749 },
750#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500751#ifdef CONFIG_STACK_TRACER
752 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500753 .procname = "stack_tracer_enabled",
754 .data = &stack_tracer_enabled,
755 .maxlen = sizeof(int),
756 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800757 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500758 },
759#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400760#ifdef CONFIG_TRACING
761 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100762 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400763 .data = &ftrace_dump_on_oops,
764 .maxlen = sizeof(int),
765 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800766 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400767 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400768 {
769 .procname = "traceoff_on_warning",
770 .data = &__disable_trace_on_warning,
771 .maxlen = sizeof(__disable_trace_on_warning),
772 .mode = 0644,
773 .proc_handler = proc_dointvec,
774 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500775 {
776 .procname = "tracepoint_printk",
777 .data = &tracepoint_printk,
778 .maxlen = sizeof(tracepoint_printk),
779 .mode = 0644,
780 .proc_handler = proc_dointvec,
781 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400782#endif
Dave Young2965faa2015-09-09 15:38:55 -0700783#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800784 {
785 .procname = "kexec_load_disabled",
786 .data = &kexec_load_disabled,
787 .maxlen = sizeof(int),
788 .mode = 0644,
789 /* only handle a transition from default "0" to "1" */
790 .proc_handler = proc_dointvec_minmax,
791 .extra1 = &one,
792 .extra2 = &one,
793 },
794#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200795#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 .procname = "modprobe",
798 .data = &modprobe_path,
799 .maxlen = KMOD_PATH_LEN,
800 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800801 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 },
Kees Cook3d433212009-04-02 15:49:29 -0700803 {
Kees Cook3d433212009-04-02 15:49:29 -0700804 .procname = "modules_disabled",
805 .data = &modules_disabled,
806 .maxlen = sizeof(int),
807 .mode = 0644,
808 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800809 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700810 .extra1 = &one,
811 .extra2 = &one,
812 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700814#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100817 .data = &uevent_helper,
818 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800820 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 },
Michael Marineau86d56132014-04-10 14:09:31 -0700822#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823#ifdef CONFIG_CHR_DEV_SG
824 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 .procname = "sg-big-buff",
826 .data = &sg_big_buff,
827 .maxlen = sizeof (int),
828 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800829 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 },
831#endif
832#ifdef CONFIG_BSD_PROCESS_ACCT
833 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 .procname = "acct",
835 .data = &acct_parm,
836 .maxlen = 3*sizeof(int),
837 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800838 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 },
840#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841#ifdef CONFIG_MAGIC_SYSRQ
842 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800844 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 .maxlen = sizeof (int),
846 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700847 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 },
849#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700850#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700853 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 .maxlen = sizeof (int),
855 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800856 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700858#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700861 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 .maxlen = sizeof(int),
863 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700864 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 },
866 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 .procname = "random",
868 .mode = 0555,
869 .child = random_table,
870 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 {
Eric Paris17f60a72011-04-01 17:07:50 -0400872 .procname = "usermodehelper",
873 .mode = 0555,
874 .child = usermodehelper_table,
875 },
876 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 .procname = "overflowuid",
878 .data = &overflowuid,
879 .maxlen = sizeof(int),
880 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800881 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 .extra1 = &minolduid,
883 .extra2 = &maxolduid,
884 },
885 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 .procname = "overflowgid",
887 .data = &overflowgid,
888 .maxlen = sizeof(int),
889 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800890 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 .extra1 = &minolduid,
892 .extra2 = &maxolduid,
893 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800894#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895#ifdef CONFIG_MATHEMU
896 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 .procname = "ieee_emulation_warnings",
898 .data = &sysctl_ieee_emulation_warnings,
899 .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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200906 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 .maxlen = sizeof(int),
908 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800909 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 },
911#endif
912 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 .procname = "pid_max",
914 .data = &pid_max,
915 .maxlen = sizeof (int),
916 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800917 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 .extra1 = &pid_max_min,
919 .extra2 = &pid_max_max,
920 },
921 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922 .procname = "panic_on_oops",
923 .data = &panic_on_oops,
924 .maxlen = sizeof(int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800928#if defined CONFIG_PRINTK
929 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800930 .procname = "printk",
931 .data = &console_loglevel,
932 .maxlen = 4*sizeof(int),
933 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800934 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800935 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700938 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 .maxlen = sizeof(int),
940 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800941 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942 },
943 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700945 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 .maxlen = sizeof(int),
947 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800948 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 },
Dave Youngaf913222009-09-22 16:43:33 -0700950 {
Dave Youngaf913222009-09-22 16:43:33 -0700951 .procname = "printk_delay",
952 .data = &printk_delay_msec,
953 .maxlen = sizeof(int),
954 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800955 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700956 .extra1 = &zero,
957 .extra2 = &ten_thousand,
958 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700960 .procname = "printk_devkmsg",
961 .data = devkmsg_log_str,
962 .maxlen = DEVKMSG_STR_MAX_SIZE,
963 .mode = 0644,
964 .proc_handler = devkmsg_sysctl_set_loglvl,
965 },
966 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800967 .procname = "dmesg_restrict",
968 .data = &dmesg_restrict,
969 .maxlen = sizeof(int),
970 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700971 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800972 .extra1 = &zero,
973 .extra2 = &one,
974 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800975 {
976 .procname = "kptr_restrict",
977 .data = &kptr_restrict,
978 .maxlen = sizeof(int),
979 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700980 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800981 .extra1 = &zero,
982 .extra2 = &two,
983 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800984#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800985 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986 .procname = "ngroups_max",
987 .data = &ngroups_max,
988 .maxlen = sizeof (int),
989 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800990 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991 },
Dan Ballard73efc032011-10-31 17:11:20 -0700992 {
993 .procname = "cap_last_cap",
994 .data = (void *)&cap_last_cap,
995 .maxlen = sizeof(int),
996 .mode = 0444,
997 .proc_handler = proc_dointvec,
998 },
Don Zickus58687ac2010-05-07 17:11:44 -0400999#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -05001000 {
Don Zickus58687ac2010-05-07 17:11:44 -04001001 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +02001002 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -05001003 .maxlen = sizeof (int),
1004 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001005 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001006 .extra1 = &zero,
1007 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -04001008 },
1009 {
1010 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001011 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -04001012 .maxlen = sizeof(int),
1013 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001014 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +08001015 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -04001016 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -05001017 },
Don Zickus2508ce12010-05-07 17:11:46 -04001018 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001019 .procname = "nmi_watchdog",
1020 .data = &nmi_watchdog_enabled,
1021 .maxlen = sizeof (int),
1022 .mode = 0644,
1023 .proc_handler = proc_nmi_watchdog,
1024 .extra1 = &zero,
1025#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
1026 .extra2 = &one,
1027#else
1028 .extra2 = &zero,
1029#endif
1030 },
1031 {
1032 .procname = "soft_watchdog",
1033 .data = &soft_watchdog_enabled,
1034 .maxlen = sizeof (int),
1035 .mode = 0644,
1036 .proc_handler = proc_soft_watchdog,
1037 .extra1 = &zero,
1038 .extra2 = &one,
1039 },
1040 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001041 .procname = "watchdog_cpumask",
1042 .data = &watchdog_cpumask_bits,
1043 .maxlen = NR_CPUS,
1044 .mode = 0644,
1045 .proc_handler = proc_watchdog_cpumask,
1046 },
1047 {
Don Zickus2508ce12010-05-07 17:11:46 -04001048 .procname = "softlockup_panic",
1049 .data = &softlockup_panic,
1050 .maxlen = sizeof(int),
1051 .mode = 0644,
1052 .proc_handler = proc_dointvec_minmax,
1053 .extra1 = &zero,
1054 .extra2 = &one,
1055 },
Don Zickusac1f5912015-11-05 18:44:44 -08001056#ifdef CONFIG_HARDLOCKUP_DETECTOR
1057 {
1058 .procname = "hardlockup_panic",
1059 .data = &hardlockup_panic,
1060 .maxlen = sizeof(int),
1061 .mode = 0644,
1062 .proc_handler = proc_dointvec_minmax,
1063 .extra1 = &zero,
1064 .extra2 = &one,
1065 },
1066#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001067#ifdef CONFIG_SMP
1068 {
1069 .procname = "softlockup_all_cpu_backtrace",
1070 .data = &sysctl_softlockup_all_cpu_backtrace,
1071 .maxlen = sizeof(int),
1072 .mode = 0644,
1073 .proc_handler = proc_dointvec_minmax,
1074 .extra1 = &zero,
1075 .extra2 = &one,
1076 },
Jiri Kosina55537872015-11-05 18:44:41 -08001077 {
1078 .procname = "hardlockup_all_cpu_backtrace",
1079 .data = &sysctl_hardlockup_all_cpu_backtrace,
1080 .maxlen = sizeof(int),
1081 .mode = 0644,
1082 .proc_handler = proc_dointvec_minmax,
1083 .extra1 = &zero,
1084 .extra2 = &one,
1085 },
Aaron Tomlined235872014-06-23 13:22:05 -07001086#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001087#endif
1088#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1089 {
1090 .procname = "unknown_nmi_panic",
1091 .data = &unknown_nmi_panic,
1092 .maxlen = sizeof (int),
1093 .mode = 0644,
1094 .proc_handler = proc_dointvec,
1095 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001096#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097#if defined(CONFIG_X86)
1098 {
Don Zickus8da5add2006-09-26 10:52:27 +02001099 .procname = "panic_on_unrecovered_nmi",
1100 .data = &panic_on_unrecovered_nmi,
1101 .maxlen = sizeof(int),
1102 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001103 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001104 },
1105 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001106 .procname = "panic_on_io_nmi",
1107 .data = &panic_on_io_nmi,
1108 .maxlen = sizeof(int),
1109 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001110 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001111 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001112#ifdef CONFIG_DEBUG_STACKOVERFLOW
1113 {
1114 .procname = "panic_on_stackoverflow",
1115 .data = &sysctl_panic_on_stackoverflow,
1116 .maxlen = sizeof(int),
1117 .mode = 0644,
1118 .proc_handler = proc_dointvec,
1119 },
1120#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001121 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 .procname = "bootloader_type",
1123 .data = &bootloader_type,
1124 .maxlen = sizeof (int),
1125 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001126 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001128 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001129 .procname = "bootloader_version",
1130 .data = &bootloader_version,
1131 .maxlen = sizeof (int),
1132 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001133 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001134 },
1135 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001136 .procname = "kstack_depth_to_print",
1137 .data = &kstack_depth_to_print,
1138 .maxlen = sizeof(int),
1139 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001140 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001141 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001142 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001143 .procname = "io_delay_type",
1144 .data = &io_delay_type,
1145 .maxlen = sizeof(int),
1146 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001147 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001148 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001150#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 .procname = "randomize_va_space",
1153 .data = &randomize_va_space,
1154 .maxlen = sizeof(int),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001158#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001159#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001160 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001161 .procname = "spin_retry",
1162 .data = &spin_retry,
1163 .maxlen = sizeof (int),
1164 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001165 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001166 },
1167#endif
Len Brown673d5b42007-07-28 03:33:16 -04001168#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001169 {
Pavel Machekc255d842006-02-20 18:27:58 -08001170 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001171 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001172 .maxlen = sizeof (unsigned long),
1173 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001174 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001175 },
1176#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301177#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001178 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001179 .procname = "ignore-unaligned-usertrap",
1180 .data = &no_unaligned_warning,
1181 .maxlen = sizeof (int),
1182 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001183 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001184 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301185#endif
1186#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001187 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001188 .procname = "unaligned-dump-stack",
1189 .data = &unaligned_dump_stack,
1190 .maxlen = sizeof (int),
1191 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001192 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001193 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001194#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001195#ifdef CONFIG_DETECT_HUNG_TASK
1196 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001197 .procname = "hung_task_panic",
1198 .data = &sysctl_hung_task_panic,
1199 .maxlen = sizeof(int),
1200 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001201 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001202 .extra1 = &zero,
1203 .extra2 = &one,
1204 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001205 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001206 .procname = "hung_task_check_count",
1207 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001208 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001209 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001210 .proc_handler = proc_dointvec_minmax,
1211 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001212 },
1213 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001214 .procname = "hung_task_timeout_secs",
1215 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001216 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001217 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001218 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001219 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001220 },
1221 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001222 .procname = "hung_task_warnings",
1223 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001224 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001225 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001226 .proc_handler = proc_dointvec_minmax,
1227 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001228 },
Imran Khana9788f42017-09-18 15:48:30 +05301229 {
1230 .procname = "hung_task_selective_monitoring",
1231 .data = &sysctl_hung_task_selective_monitoring,
1232 .maxlen = sizeof(int),
1233 .mode = 0644,
1234 .proc_handler = proc_dointvec_minmax,
1235 .extra1 = &zero,
1236 .extra2 = &one,
1237 },
1238
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001239#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001240#ifdef CONFIG_RT_MUTEXES
1241 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001242 .procname = "max_lock_depth",
1243 .data = &max_lock_depth,
1244 .maxlen = sizeof(int),
1245 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001246 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001247 },
1248#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001249 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001250 .procname = "poweroff_cmd",
1251 .data = &poweroff_cmd,
1252 .maxlen = POWEROFF_CMD_PATH_LEN,
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001255 },
David Howells0b77f5b2008-04-29 01:01:32 -07001256#ifdef CONFIG_KEYS
1257 {
David Howells0b77f5b2008-04-29 01:01:32 -07001258 .procname = "keys",
1259 .mode = 0555,
1260 .child = key_sysctls,
1261 },
1262#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001263#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001264 /*
1265 * User-space scripts rely on the existence of this file
1266 * as a feature check for perf_events being enabled.
1267 *
1268 * So it's an ABI, do not remove!
1269 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001270 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001271 .procname = "perf_event_paranoid",
1272 .data = &sysctl_perf_event_paranoid,
1273 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001274 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001275 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001276 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001277 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001278 .procname = "perf_event_mlock_kb",
1279 .data = &sysctl_perf_event_mlock,
1280 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001281 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001282 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001283 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001284 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001285 .procname = "perf_event_max_sample_rate",
1286 .data = &sysctl_perf_event_sample_rate,
1287 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001288 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001289 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001290 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001291 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001292 {
1293 .procname = "perf_cpu_time_max_percent",
1294 .data = &sysctl_perf_cpu_time_max_percent,
1295 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1296 .mode = 0644,
1297 .proc_handler = perf_cpu_time_max_percent_handler,
1298 .extra1 = &zero,
1299 .extra2 = &one_hundred,
1300 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001301 {
1302 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001303 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001304 .maxlen = sizeof(sysctl_perf_event_max_stack),
1305 .mode = 0644,
1306 .proc_handler = perf_event_max_stack_handler,
1307 .extra1 = &zero,
1308 .extra2 = &six_hundred_forty_kb,
1309 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001310 {
1311 .procname = "perf_event_max_contexts_per_stack",
1312 .data = &sysctl_perf_event_max_contexts_per_stack,
1313 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1314 .mode = 0644,
1315 .proc_handler = perf_event_max_stack_handler,
1316 .extra1 = &zero,
1317 .extra2 = &one_thousand,
1318 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001319#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001320#ifdef CONFIG_KMEMCHECK
1321 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001322 .procname = "kmemcheck",
1323 .data = &kmemcheck_enabled,
1324 .maxlen = sizeof(int),
1325 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001326 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001327 },
1328#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001329 {
1330 .procname = "panic_on_warn",
1331 .data = &panic_on_warn,
1332 .maxlen = sizeof(int),
1333 .mode = 0644,
1334 .proc_handler = proc_dointvec_minmax,
1335 .extra1 = &zero,
1336 .extra2 = &one,
1337 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001338#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1339 {
1340 .procname = "timer_migration",
1341 .data = &sysctl_timer_migration,
1342 .maxlen = sizeof(unsigned int),
1343 .mode = 0644,
1344 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001345 .extra1 = &zero,
1346 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001347 },
1348#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001349#ifdef CONFIG_BPF_SYSCALL
1350 {
1351 .procname = "unprivileged_bpf_disabled",
1352 .data = &sysctl_unprivileged_bpf_disabled,
1353 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1354 .mode = 0644,
1355 /* only handle a transition from default "0" to "1" */
1356 .proc_handler = proc_dointvec_minmax,
1357 .extra1 = &one,
1358 .extra2 = &one,
1359 },
1360#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001361#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1362 {
1363 .procname = "panic_on_rcu_stall",
1364 .data = &sysctl_panic_on_rcu_stall,
1365 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1366 .mode = 0644,
1367 .proc_handler = proc_dointvec_minmax,
1368 .extra1 = &zero,
1369 .extra2 = &one,
1370 },
1371#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001372#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001373 {
1374 .procname = "boot_reason",
1375 .data = &boot_reason,
1376 .maxlen = sizeof(int),
1377 .mode = 0444,
1378 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001379 },
1380
1381 {
1382 .procname = "cold_boot",
1383 .data = &cold_boot,
1384 .maxlen = sizeof(int),
1385 .mode = 0444,
1386 .proc_handler = proc_dointvec,
1387 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001388#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001389 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390};
1391
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001392static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 .procname = "overcommit_memory",
1395 .data = &sysctl_overcommit_memory,
1396 .maxlen = sizeof(sysctl_overcommit_memory),
1397 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001398 .proc_handler = proc_dointvec_minmax,
1399 .extra1 = &zero,
1400 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 },
1402 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001403 .procname = "panic_on_oom",
1404 .data = &sysctl_panic_on_oom,
1405 .maxlen = sizeof(sysctl_panic_on_oom),
1406 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001407 .proc_handler = proc_dointvec_minmax,
1408 .extra1 = &zero,
1409 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001410 },
1411 {
David Rientjesfe071d72007-10-16 23:25:56 -07001412 .procname = "oom_kill_allocating_task",
1413 .data = &sysctl_oom_kill_allocating_task,
1414 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001416 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001417 },
1418 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001419 .procname = "oom_dump_tasks",
1420 .data = &sysctl_oom_dump_tasks,
1421 .maxlen = sizeof(sysctl_oom_dump_tasks),
1422 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001423 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001424 },
1425 {
Charan Teja Reddyf9920cf2018-05-01 20:20:20 +05301426 .procname = "reap_mem_on_sigkill",
1427 .data = &sysctl_reap_mem_on_sigkill,
1428 .maxlen = sizeof(sysctl_reap_mem_on_sigkill),
1429 .mode = 0644,
1430 .proc_handler = proc_dointvec,
1431 },
1432 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 .procname = "overcommit_ratio",
1434 .data = &sysctl_overcommit_ratio,
1435 .maxlen = sizeof(sysctl_overcommit_ratio),
1436 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001437 .proc_handler = overcommit_ratio_handler,
1438 },
1439 {
1440 .procname = "overcommit_kbytes",
1441 .data = &sysctl_overcommit_kbytes,
1442 .maxlen = sizeof(sysctl_overcommit_kbytes),
1443 .mode = 0644,
1444 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 },
1446 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 .procname = "page-cluster",
1448 .data = &page_cluster,
1449 .maxlen = sizeof(int),
1450 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001451 .proc_handler = proc_dointvec_minmax,
1452 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 },
1454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 .procname = "dirty_background_ratio",
1456 .data = &dirty_background_ratio,
1457 .maxlen = sizeof(dirty_background_ratio),
1458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001459 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 .extra1 = &zero,
1461 .extra2 = &one_hundred,
1462 },
1463 {
David Rientjes2da02992009-01-06 14:39:31 -08001464 .procname = "dirty_background_bytes",
1465 .data = &dirty_background_bytes,
1466 .maxlen = sizeof(dirty_background_bytes),
1467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001468 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001469 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001470 },
1471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472 .procname = "dirty_ratio",
1473 .data = &vm_dirty_ratio,
1474 .maxlen = sizeof(vm_dirty_ratio),
1475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001476 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .extra1 = &zero,
1478 .extra2 = &one_hundred,
1479 },
1480 {
David Rientjes2da02992009-01-06 14:39:31 -08001481 .procname = "dirty_bytes",
1482 .data = &vm_dirty_bytes,
1483 .maxlen = sizeof(vm_dirty_bytes),
1484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001485 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001486 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001487 },
1488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001490 .data = &dirty_writeback_interval,
1491 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001493 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 },
1495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001497 .data = &dirty_expire_interval,
1498 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001500 .proc_handler = proc_dointvec_minmax,
1501 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 },
1503 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001504 .procname = "dirtytime_expire_seconds",
1505 .data = &dirtytime_expire_interval,
1506 .maxlen = sizeof(dirty_expire_interval),
1507 .mode = 0644,
1508 .proc_handler = dirtytime_interval_handler,
1509 .extra1 = &zero,
1510 },
1511 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001512 .procname = "nr_pdflush_threads",
1513 .mode = 0444 /* read-only */,
1514 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 },
1516 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 .procname = "swappiness",
1518 .data = &vm_swappiness,
1519 .maxlen = sizeof(vm_swappiness),
1520 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001521 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 .extra1 = &zero,
1523 .extra2 = &one_hundred,
1524 },
Vinayak Menonb9e4cc2b2018-06-11 18:58:39 +05301525 {
1526 .procname = "want_old_faultaround_pte",
1527 .data = &want_old_faultaround_pte,
1528 .maxlen = sizeof(want_old_faultaround_pte),
1529 .mode = 0644,
1530 .proc_handler = proc_dointvec_minmax,
1531 .extra1 = &zero,
1532 .extra2 = &one,
1533 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001535 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001536 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001537 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 .maxlen = sizeof(unsigned long),
1539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001540 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001541 },
1542#ifdef CONFIG_NUMA
1543 {
1544 .procname = "nr_hugepages_mempolicy",
1545 .data = NULL,
1546 .maxlen = sizeof(unsigned long),
1547 .mode = 0644,
1548 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001549 },
1550#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552 .procname = "hugetlb_shm_group",
1553 .data = &sysctl_hugetlb_shm_group,
1554 .maxlen = sizeof(gid_t),
1555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001556 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 },
Mel Gorman396faf02007-07-17 04:03:13 -07001558 {
Mel Gorman396faf02007-07-17 04:03:13 -07001559 .procname = "hugepages_treat_as_movable",
1560 .data = &hugepages_treat_as_movable,
1561 .maxlen = sizeof(int),
1562 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001563 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001564 },
Adam Litke54f9f802007-10-16 01:26:20 -07001565 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001566 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001567 .data = NULL,
1568 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001569 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001570 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001571 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572#endif
1573 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001574 .procname = "lowmem_reserve_ratio",
1575 .data = &sysctl_lowmem_reserve_ratio,
1576 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1577 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001578 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001579 },
1580 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001581 .procname = "drop_caches",
1582 .data = &sysctl_drop_caches,
1583 .maxlen = sizeof(int),
Johannes Weinerb231f9d2019-11-30 17:56:08 -08001584 .mode = 0200,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001585 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001586 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001587 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001588 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001589#ifdef CONFIG_COMPACTION
1590 {
1591 .procname = "compact_memory",
1592 .data = &sysctl_compact_memory,
1593 .maxlen = sizeof(int),
1594 .mode = 0200,
1595 .proc_handler = sysctl_compaction_handler,
1596 },
Mel Gorman5e771902010-05-24 14:32:31 -07001597 {
1598 .procname = "extfrag_threshold",
1599 .data = &sysctl_extfrag_threshold,
1600 .maxlen = sizeof(int),
1601 .mode = 0644,
1602 .proc_handler = sysctl_extfrag_handler,
1603 .extra1 = &min_extfrag_threshold,
1604 .extra2 = &max_extfrag_threshold,
1605 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001606 {
1607 .procname = "compact_unevictable_allowed",
1608 .data = &sysctl_compact_unevictable_allowed,
1609 .maxlen = sizeof(int),
1610 .mode = 0644,
1611 .proc_handler = proc_dointvec,
1612 .extra1 = &zero,
1613 .extra2 = &one,
1614 },
Mel Gorman5e771902010-05-24 14:32:31 -07001615
Mel Gorman76ab0f52010-05-24 14:32:28 -07001616#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001617 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618 .procname = "min_free_kbytes",
1619 .data = &min_free_kbytes,
1620 .maxlen = sizeof(min_free_kbytes),
1621 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001622 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 .extra1 = &zero,
1624 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001625 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001626 .procname = "watermark_scale_factor",
1627 .data = &watermark_scale_factor,
1628 .maxlen = sizeof(watermark_scale_factor),
1629 .mode = 0644,
1630 .proc_handler = watermark_scale_factor_sysctl_handler,
Rik van Riel12462752011-09-01 15:26:50 -04001631 .extra1 = &zero,
1632 .extra2 = &zero,
1633 },
1634 {
1635 .procname = "extra_free_kbytes",
1636 .data = &extra_free_kbytes,
1637 .maxlen = sizeof(extra_free_kbytes),
1638 .mode = 0644,
1639 .proc_handler = min_free_kbytes_sysctl_handler,
1640 .extra1 = &zero,
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001641 },
1642 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001643 .procname = "percpu_pagelist_fraction",
1644 .data = &percpu_pagelist_fraction,
1645 .maxlen = sizeof(percpu_pagelist_fraction),
1646 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001647 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001648 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001649 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650#ifdef CONFIG_MMU
1651 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652 .procname = "max_map_count",
1653 .data = &sysctl_max_map_count,
1654 .maxlen = sizeof(sysctl_max_map_count),
1655 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001656 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001657 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001659#else
1660 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001661 .procname = "nr_trim_pages",
1662 .data = &sysctl_nr_trim_pages,
1663 .maxlen = sizeof(sysctl_nr_trim_pages),
1664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001665 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001666 .extra1 = &zero,
1667 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668#endif
1669 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001670 .procname = "laptop_mode",
1671 .data = &laptop_mode,
1672 .maxlen = sizeof(laptop_mode),
1673 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001674 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001675 },
1676 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 .procname = "block_dump",
1678 .data = &block_dump,
1679 .maxlen = sizeof(block_dump),
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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 .procname = "vfs_cache_pressure",
1686 .data = &sysctl_vfs_cache_pressure,
1687 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1688 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001689 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001690 .extra1 = &zero,
1691 },
1692#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001694 .procname = "legacy_va_layout",
1695 .data = &sysctl_legacy_va_layout,
1696 .maxlen = sizeof(sysctl_legacy_va_layout),
1697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001698 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 .extra1 = &zero,
1700 },
1701#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001702#ifdef CONFIG_NUMA
1703 {
Christoph Lameter17436602006-01-18 17:42:32 -08001704 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001705 .data = &node_reclaim_mode,
1706 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001708 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001709 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001710 },
Christoph Lameter96146342006-07-03 00:24:13 -07001711 {
Christoph Lameter96146342006-07-03 00:24:13 -07001712 .procname = "min_unmapped_ratio",
1713 .data = &sysctl_min_unmapped_ratio,
1714 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001716 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001717 .extra1 = &zero,
1718 .extra2 = &one_hundred,
1719 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001720 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001721 .procname = "min_slab_ratio",
1722 .data = &sysctl_min_slab_ratio,
1723 .maxlen = sizeof(sysctl_min_slab_ratio),
1724 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001725 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001726 .extra1 = &zero,
1727 .extra2 = &one_hundred,
1728 },
Christoph Lameter17436602006-01-18 17:42:32 -08001729#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001730#ifdef CONFIG_SMP
1731 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001732 .procname = "stat_interval",
1733 .data = &sysctl_stat_interval,
1734 .maxlen = sizeof(sysctl_stat_interval),
1735 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001736 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001737 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001738 {
1739 .procname = "stat_refresh",
1740 .data = NULL,
1741 .maxlen = 0,
1742 .mode = 0600,
1743 .proc_handler = vmstat_refresh,
1744 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001745#endif
David Howells6e141542009-12-15 19:27:45 +00001746#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001747 {
Eric Parised032182007-06-28 15:55:21 -04001748 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001749 .data = &dac_mmap_min_addr,
1750 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001751 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001752 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001753 },
David Howells6e141542009-12-15 19:27:45 +00001754#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001755#ifdef CONFIG_NUMA
1756 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001757 .procname = "numa_zonelist_order",
1758 .data = &numa_zonelist_order,
1759 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001761 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001762 },
1763#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001764#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001765 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001766 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001767 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001768#ifdef CONFIG_X86_32
1769 .data = &vdso32_enabled,
1770 .maxlen = sizeof(vdso32_enabled),
1771#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001772 .data = &vdso_enabled,
1773 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001774#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001775 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001776 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001777 .extra1 = &zero,
1778 },
1779#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001780#ifdef CONFIG_HIGHMEM
1781 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001782 .procname = "highmem_is_dirtyable",
1783 .data = &vm_highmem_is_dirtyable,
1784 .maxlen = sizeof(vm_highmem_is_dirtyable),
1785 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001786 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001787 .extra1 = &zero,
1788 .extra2 = &one,
1789 },
1790#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001791#ifdef CONFIG_MEMORY_FAILURE
1792 {
Andi Kleen6a460792009-09-16 11:50:15 +02001793 .procname = "memory_failure_early_kill",
1794 .data = &sysctl_memory_failure_early_kill,
1795 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1796 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001797 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001798 .extra1 = &zero,
1799 .extra2 = &one,
1800 },
1801 {
Andi Kleen6a460792009-09-16 11:50:15 +02001802 .procname = "memory_failure_recovery",
1803 .data = &sysctl_memory_failure_recovery,
1804 .maxlen = sizeof(sysctl_memory_failure_recovery),
1805 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001806 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001807 .extra1 = &zero,
1808 .extra2 = &one,
1809 },
1810#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001811 {
1812 .procname = "user_reserve_kbytes",
1813 .data = &sysctl_user_reserve_kbytes,
1814 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1815 .mode = 0644,
1816 .proc_handler = proc_doulongvec_minmax,
1817 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001818 {
1819 .procname = "admin_reserve_kbytes",
1820 .data = &sysctl_admin_reserve_kbytes,
1821 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1822 .mode = 0644,
1823 .proc_handler = proc_doulongvec_minmax,
1824 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001825#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1826 {
1827 .procname = "mmap_rnd_bits",
1828 .data = &mmap_rnd_bits,
1829 .maxlen = sizeof(mmap_rnd_bits),
1830 .mode = 0600,
1831 .proc_handler = proc_dointvec_minmax,
1832 .extra1 = (void *)&mmap_rnd_bits_min,
1833 .extra2 = (void *)&mmap_rnd_bits_max,
1834 },
1835#endif
1836#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1837 {
1838 .procname = "mmap_rnd_compat_bits",
1839 .data = &mmap_rnd_compat_bits,
1840 .maxlen = sizeof(mmap_rnd_compat_bits),
1841 .mode = 0600,
1842 .proc_handler = proc_dointvec_minmax,
1843 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1844 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1845 },
1846#endif
Vinayak Menonc1c6a992015-12-21 13:00:58 +05301847#ifdef CONFIG_SWAP
1848 {
1849 .procname = "swap_ratio",
1850 .data = &sysctl_swap_ratio,
1851 .maxlen = sizeof(sysctl_swap_ratio),
1852 .mode = 0644,
1853 .proc_handler = proc_dointvec_minmax,
1854 },
1855 {
1856 .procname = "swap_ratio_enable",
1857 .data = &sysctl_swap_ratio_enable,
1858 .maxlen = sizeof(sysctl_swap_ratio_enable),
1859 .mode = 0644,
1860 .proc_handler = proc_dointvec_minmax,
1861 },
1862#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001863 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001864};
1865
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001866static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001868 .procname = "inode-nr",
1869 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001870 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001872 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873 },
1874 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875 .procname = "inode-state",
1876 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001877 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001879 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001880 },
1881 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882 .procname = "file-nr",
1883 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001884 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001885 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001886 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887 },
1888 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001889 .procname = "file-max",
1890 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001891 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001893 .proc_handler = proc_doulongvec_minmax,
Will Deacon3141fcc2019-04-05 18:39:38 -07001894 .extra1 = &zero_ul,
Christian Brauner6b65c262019-03-07 16:29:43 -08001895 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001896 },
1897 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001898 .procname = "nr_open",
1899 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001900 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001901 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001902 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001903 .extra1 = &sysctl_nr_open_min,
1904 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001905 },
1906 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907 .procname = "dentry-state",
1908 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001909 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001910 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001911 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001912 },
1913 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914 .procname = "overflowuid",
1915 .data = &fs_overflowuid,
1916 .maxlen = sizeof(int),
1917 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001918 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 .extra1 = &minolduid,
1920 .extra2 = &maxolduid,
1921 },
1922 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923 .procname = "overflowgid",
1924 .data = &fs_overflowgid,
1925 .maxlen = sizeof(int),
1926 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001927 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928 .extra1 = &minolduid,
1929 .extra2 = &maxolduid,
1930 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001931#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001932 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933 .procname = "leases-enable",
1934 .data = &leases_enable,
1935 .maxlen = sizeof(int),
1936 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001937 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001939#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001940#ifdef CONFIG_DNOTIFY
1941 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942 .procname = "dir-notify-enable",
1943 .data = &dir_notify_enable,
1944 .maxlen = sizeof(int),
1945 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001946 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 },
1948#endif
1949#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001950#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001951 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952 .procname = "lease-break-time",
1953 .data = &lease_break_time,
1954 .maxlen = sizeof(int),
1955 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001956 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001958#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001959#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001960 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961 .procname = "aio-nr",
1962 .data = &aio_nr,
1963 .maxlen = sizeof(aio_nr),
1964 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001965 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966 },
1967 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968 .procname = "aio-max-nr",
1969 .data = &aio_max_nr,
1970 .maxlen = sizeof(aio_max_nr),
1971 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001972 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001974#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001975#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001976 {
Robert Love0399cb02005-07-13 12:38:18 -04001977 .procname = "inotify",
1978 .mode = 0555,
1979 .child = inotify_table,
1980 },
1981#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001982#ifdef CONFIG_EPOLL
1983 {
1984 .procname = "epoll",
1985 .mode = 0555,
1986 .child = epoll_table,
1987 },
1988#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001989#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001990 {
Kees Cook800179c2012-07-25 17:29:07 -07001991 .procname = "protected_symlinks",
1992 .data = &sysctl_protected_symlinks,
1993 .maxlen = sizeof(int),
1994 .mode = 0600,
1995 .proc_handler = proc_dointvec_minmax,
1996 .extra1 = &zero,
1997 .extra2 = &one,
1998 },
1999 {
2000 .procname = "protected_hardlinks",
2001 .data = &sysctl_protected_hardlinks,
2002 .maxlen = sizeof(int),
2003 .mode = 0600,
2004 .proc_handler = proc_dointvec_minmax,
2005 .extra1 = &zero,
2006 .extra2 = &one,
2007 },
2008 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07002009 .procname = "protected_fifos",
2010 .data = &sysctl_protected_fifos,
2011 .maxlen = sizeof(int),
2012 .mode = 0600,
2013 .proc_handler = proc_dointvec_minmax,
2014 .extra1 = &zero,
2015 .extra2 = &two,
2016 },
2017 {
2018 .procname = "protected_regular",
2019 .data = &sysctl_protected_regular,
2020 .maxlen = sizeof(int),
2021 .mode = 0600,
2022 .proc_handler = proc_dointvec_minmax,
2023 .extra1 = &zero,
2024 .extra2 = &two,
2025 },
2026 {
Alan Coxd6e71142005-06-23 00:09:43 -07002027 .procname = "suid_dumpable",
2028 .data = &suid_dumpable,
2029 .maxlen = sizeof(int),
2030 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07002031 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07002032 .extra1 = &zero,
2033 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07002034 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002035#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
2036 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002037 .procname = "binfmt_misc",
2038 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05002039 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002040 },
2041#endif
Jens Axboeb492e952010-05-19 21:03:16 +02002042 {
Jens Axboeff9da692010-06-03 14:54:39 +02002043 .procname = "pipe-max-size",
2044 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002045 .maxlen = sizeof(int),
2046 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02002047 .proc_handler = &pipe_proc_fn,
2048 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002049 },
Willy Tarreau759c0112016-01-18 16:36:09 +01002050 {
2051 .procname = "pipe-user-pages-hard",
2052 .data = &pipe_user_pages_hard,
2053 .maxlen = sizeof(pipe_user_pages_hard),
2054 .mode = 0644,
2055 .proc_handler = proc_doulongvec_minmax,
2056 },
2057 {
2058 .procname = "pipe-user-pages-soft",
2059 .data = &pipe_user_pages_soft,
2060 .maxlen = sizeof(pipe_user_pages_soft),
2061 .mode = 0644,
2062 .proc_handler = proc_doulongvec_minmax,
2063 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05002064 {
2065 .procname = "mount-max",
2066 .data = &sysctl_mount_max,
2067 .maxlen = sizeof(unsigned int),
2068 .mode = 0644,
2069 .proc_handler = proc_dointvec_minmax,
2070 .extra1 = &one,
2071 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002072 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073};
2074
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002075static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07002076#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002077 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002078 .procname = "exception-trace",
2079 .data = &show_unhandled_signals,
2080 .maxlen = sizeof(int),
2081 .mode = 0644,
2082 .proc_handler = proc_dointvec
2083 },
2084#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002085#if defined(CONFIG_OPTPROBES)
2086 {
2087 .procname = "kprobes-optimization",
2088 .data = &sysctl_kprobes_optimization,
2089 .maxlen = sizeof(int),
2090 .mode = 0644,
2091 .proc_handler = proc_kprobes_optimization_handler,
2092 .extra1 = &zero,
2093 .extra2 = &one,
2094 },
2095#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002096 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097};
2098
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002099static struct ctl_table dev_table[] = {
tracychui2f9f3682020-06-12 17:46:51 +08002100 {
2101 .procname = "ddr",
2102 .mode = 0555,
2103 .child = ddr_table,
2104 },
2105 { }
2106};
2107static struct ctl_table qpnp_power_on_table[] = {
2108 {
2109 .procname = "pon_reason",
2110 .data = &qpnp_pon_reason_extern,
2111 .maxlen = sizeof(int),
2112 .mode = 0444,
2113 .proc_handler = proc_dointvec,
2114 },
2115 {
2116 .procname = "poff_reason",
2117 .data = &qpnp_poff_reason_extern,
2118 .maxlen = sizeof(int),
2119 .mode = 0444,
2120 .proc_handler = proc_dointvec,
2121 },
2122 { }
2123};
2124static struct ctl_table ddr_table[] = {
2125 {
2126 .procname = "vendor",
2127 .data = &ddr_vendor,
2128 .maxlen = 32,
2129 .mode = 0444,
2130 .proc_handler = proc_dostring,
2131 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002132 { }
Robert Love0eeca282005-07-12 17:06:03 -04002133};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002135int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002136{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002137 struct ctl_table_header *hdr;
2138
2139 hdr = register_sysctl_table(sysctl_base_table);
2140 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002141 return 0;
2142}
2143
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002144#endif /* CONFIG_SYSCTL */
2145
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146/*
2147 * /proc/sys support
2148 */
2149
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002150#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002151
Kees Cookf8808302014-06-06 14:37:17 -07002152static int _proc_do_string(char *data, int maxlen, int write,
2153 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002154 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002155{
2156 size_t len;
2157 char __user *p;
2158 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002159
2160 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002161 *lenp = 0;
2162 return 0;
2163 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002164
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002165 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002166 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2167 /* Only continue writes not past the end of buffer. */
2168 len = strlen(data);
2169 if (len > maxlen - 1)
2170 len = maxlen - 1;
2171
2172 if (*ppos > len)
2173 return 0;
2174 len = *ppos;
2175 } else {
2176 /* Start writing from beginning of buffer. */
2177 len = 0;
2178 }
2179
Kees Cook2ca9bb42014-06-06 14:37:18 -07002180 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002181 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002182 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002183 if (get_user(c, p++))
2184 return -EFAULT;
2185 if (c == 0 || c == '\n')
2186 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002187 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002188 }
Kees Cookf8808302014-06-06 14:37:17 -07002189 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002190 } else {
2191 len = strlen(data);
2192 if (len > maxlen)
2193 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002194
2195 if (*ppos > len) {
2196 *lenp = 0;
2197 return 0;
2198 }
2199
2200 data += *ppos;
2201 len -= *ppos;
2202
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002203 if (len > *lenp)
2204 len = *lenp;
2205 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002206 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002207 return -EFAULT;
2208 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002209 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002210 return -EFAULT;
2211 len++;
2212 }
2213 *lenp = len;
2214 *ppos += len;
2215 }
2216 return 0;
2217}
2218
Kees Cookf4aacea2014-06-06 14:37:19 -07002219static void warn_sysctl_write(struct ctl_table *table)
2220{
2221 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2222 "This will not be supported in the future. To silence this\n"
2223 "warning, set kernel.sysctl_writes_strict = -1\n",
2224 current->comm, table->procname);
2225}
2226
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227/**
2228 * proc_dostring - read a string sysctl
2229 * @table: the sysctl table
2230 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002231 * @buffer: the user buffer
2232 * @lenp: the size of the user buffer
2233 * @ppos: file position
2234 *
2235 * Reads/writes a string from/to the user buffer. If the kernel
2236 * buffer provided is not large enough to hold the string, the
2237 * string is truncated. The copied string is %NULL-terminated.
2238 * If the string is being read by the user process, it is copied
2239 * and a newline '\n' is added. It is truncated if the buffer is
2240 * not large enough.
2241 *
2242 * Returns 0 on success.
2243 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002244int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245 void __user *buffer, size_t *lenp, loff_t *ppos)
2246{
Kees Cookf4aacea2014-06-06 14:37:19 -07002247 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2248 warn_sysctl_write(table);
2249
Kees Cookf8808302014-06-06 14:37:17 -07002250 return _proc_do_string((char *)(table->data), table->maxlen, write,
2251 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252}
2253
Amerigo Wang00b7c332010-05-05 00:26:45 +00002254static size_t proc_skip_spaces(char **buf)
2255{
2256 size_t ret;
2257 char *tmp = skip_spaces(*buf);
2258 ret = tmp - *buf;
2259 *buf = tmp;
2260 return ret;
2261}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002263static void proc_skip_char(char **buf, size_t *size, const char v)
2264{
2265 while (*size) {
2266 if (**buf != v)
2267 break;
2268 (*size)--;
2269 (*buf)++;
2270 }
2271}
2272
Amerigo Wang00b7c332010-05-05 00:26:45 +00002273#define TMPBUFLEN 22
2274/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002275 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002276 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002277 * @buf: a kernel buffer
2278 * @size: size of the kernel buffer
2279 * @val: this is where the number will be stored
2280 * @neg: set to %TRUE if number is negative
2281 * @perm_tr: a vector which contains the allowed trailers
2282 * @perm_tr_len: size of the perm_tr vector
2283 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002284 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002285 * In case of success %0 is returned and @buf and @size are updated with
2286 * the amount of bytes read. If @tr is non-NULL and a trailing
2287 * character exists (size is non-zero after returning from this
2288 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002289 */
2290static int proc_get_long(char **buf, size_t *size,
2291 unsigned long *val, bool *neg,
2292 const char *perm_tr, unsigned perm_tr_len, char *tr)
2293{
2294 int len;
2295 char *p, tmp[TMPBUFLEN];
2296
2297 if (!*size)
2298 return -EINVAL;
2299
2300 len = *size;
2301 if (len > TMPBUFLEN - 1)
2302 len = TMPBUFLEN - 1;
2303
2304 memcpy(tmp, *buf, len);
2305
2306 tmp[len] = 0;
2307 p = tmp;
2308 if (*p == '-' && *size > 1) {
2309 *neg = true;
2310 p++;
2311 } else
2312 *neg = false;
2313 if (!isdigit(*p))
2314 return -EINVAL;
2315
2316 *val = simple_strtoul(p, &p, 0);
2317
2318 len = p - tmp;
2319
2320 /* We don't know if the next char is whitespace thus we may accept
2321 * invalid integers (e.g. 1234...a) or two integers instead of one
2322 * (e.g. 123...1). So lets not allow such large numbers. */
2323 if (len == TMPBUFLEN - 1)
2324 return -EINVAL;
2325
2326 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2327 return -EINVAL;
2328
2329 if (tr && (len < *size))
2330 *tr = *p;
2331
2332 *buf += len;
2333 *size -= len;
2334
2335 return 0;
2336}
2337
2338/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002339 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002340 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002341 * @buf: the user buffer
2342 * @size: the size of the user buffer
2343 * @val: the integer to be converted
2344 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002345 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002346 * In case of success %0 is returned and @buf and @size are updated with
2347 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002348 */
2349static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2350 bool neg)
2351{
2352 int len;
2353 char tmp[TMPBUFLEN], *p = tmp;
2354
2355 sprintf(p, "%s%lu", neg ? "-" : "", val);
2356 len = strlen(tmp);
2357 if (len > *size)
2358 len = *size;
2359 if (copy_to_user(*buf, tmp, len))
2360 return -EFAULT;
2361 *size -= len;
2362 *buf += len;
2363 return 0;
2364}
2365#undef TMPBUFLEN
2366
2367static int proc_put_char(void __user **buf, size_t *size, char c)
2368{
2369 if (*size) {
2370 char __user **buffer = (char __user **)buf;
2371 if (put_user(c, *buffer))
2372 return -EFAULT;
2373 (*size)--, (*buffer)++;
2374 *buf = *buffer;
2375 }
2376 return 0;
2377}
2378
2379static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380 int *valp,
2381 int write, void *data)
2382{
2383 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002384 if (*negp) {
2385 if (*lvalp > (unsigned long) INT_MAX + 1)
2386 return -EINVAL;
2387 *valp = -*lvalp;
2388 } else {
2389 if (*lvalp > (unsigned long) INT_MAX)
2390 return -EINVAL;
2391 *valp = *lvalp;
2392 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 } else {
2394 int val = *valp;
2395 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002396 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002397 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002399 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 *lvalp = (unsigned long)val;
2401 }
2402 }
2403 return 0;
2404}
2405
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002406static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2407 int *valp,
2408 int write, void *data)
2409{
2410 if (write) {
2411 if (*negp)
2412 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002413 if (*lvalp > UINT_MAX)
2414 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002415 *valp = *lvalp;
2416 } else {
2417 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002418 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002419 *lvalp = (unsigned long)val;
2420 }
2421 return 0;
2422}
2423
Amerigo Wang00b7c332010-05-05 00:26:45 +00002424static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2425
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002426static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002427 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002428 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002429 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 int write, void *data),
2431 void *data)
2432{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002433 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002434 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002435 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436
Amerigo Wang00b7c332010-05-05 00:26:45 +00002437 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438 *lenp = 0;
2439 return 0;
2440 }
2441
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002442 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002443 vleft = table->maxlen / sizeof(*i);
2444 left = *lenp;
2445
2446 if (!conv)
2447 conv = do_proc_dointvec_conv;
2448
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002450 if (*ppos) {
2451 switch (sysctl_writes_strict) {
2452 case SYSCTL_WRITES_STRICT:
2453 goto out;
2454 case SYSCTL_WRITES_WARN:
2455 warn_sysctl_write(table);
2456 break;
2457 default:
2458 break;
2459 }
2460 }
2461
Amerigo Wang00b7c332010-05-05 00:26:45 +00002462 if (left > PAGE_SIZE - 1)
2463 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002464 p = kbuf = memdup_user_nul(buffer, left);
2465 if (IS_ERR(kbuf))
2466 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002467 }
2468
2469 for (; left && vleft--; i++, first=0) {
2470 unsigned long lval;
2471 bool neg;
2472
2473 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002474 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002475
J. R. Okajima563b0462010-05-25 16:10:14 -07002476 if (!left)
2477 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002478 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002479 proc_wspace_sep,
2480 sizeof(proc_wspace_sep), NULL);
2481 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002483 if (conv(&neg, &lval, i, 1, data)) {
2484 err = -EINVAL;
2485 break;
2486 }
2487 } else {
2488 if (conv(&neg, &lval, i, 0, data)) {
2489 err = -EINVAL;
2490 break;
2491 }
2492 if (!first)
2493 err = proc_put_char(&buffer, &left, '\t');
2494 if (err)
2495 break;
2496 err = proc_put_long(&buffer, &left, lval, neg);
2497 if (err)
2498 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499 }
2500 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002501
2502 if (!write && !first && left && !err)
2503 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002504 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002505 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002506 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002507 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002508 if (first)
2509 return err ? : -EINVAL;
2510 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002512out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002514 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002515}
2516
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002517static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002518 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002519 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002520 int write, void *data),
2521 void *data)
2522{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002523 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002524 buffer, lenp, ppos, conv, data);
2525}
2526
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527/**
2528 * proc_dointvec - read a vector of integers
2529 * @table: the sysctl table
2530 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002531 * @buffer: the user buffer
2532 * @lenp: the size of the user buffer
2533 * @ppos: file position
2534 *
2535 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2536 * values from/to the user buffer, treated as an ASCII string.
2537 *
2538 * Returns 0 on success.
2539 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002540int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002541 void __user *buffer, size_t *lenp, loff_t *ppos)
2542{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002543 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2544}
2545
2546/**
2547 * proc_douintvec - read a vector of unsigned integers
2548 * @table: the sysctl table
2549 * @write: %TRUE if this is a write to the sysctl file
2550 * @buffer: the user buffer
2551 * @lenp: the size of the user buffer
2552 * @ppos: file position
2553 *
2554 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2555 * values from/to the user buffer, treated as an ASCII string.
2556 *
2557 * Returns 0 on success.
2558 */
2559int proc_douintvec(struct ctl_table *table, int write,
2560 void __user *buffer, size_t *lenp, loff_t *ppos)
2561{
2562 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2563 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564}
2565
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002566/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002567 * Taint values can only be increased
2568 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002569 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002570static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002571 void __user *buffer, size_t *lenp, loff_t *ppos)
2572{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002573 struct ctl_table t;
2574 unsigned long tmptaint = get_taint();
2575 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002576
Bastian Blank91fcd412007-04-23 14:41:14 -07002577 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002578 return -EPERM;
2579
Andi Kleen25ddbb12008-10-15 22:01:41 -07002580 t = *table;
2581 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002582 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002583 if (err < 0)
2584 return err;
2585
2586 if (write) {
2587 /*
2588 * Poor man's atomic or. Not worth adding a primitive
2589 * to everyone's atomic.h for this
2590 */
2591 int i;
2592 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2593 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302594 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002595 }
2596 }
2597
2598 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002599}
2600
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002601#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002602static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002603 void __user *buffer, size_t *lenp, loff_t *ppos)
2604{
2605 if (write && !capable(CAP_SYS_ADMIN))
2606 return -EPERM;
2607
2608 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2609}
2610#endif
2611
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612struct do_proc_dointvec_minmax_conv_param {
2613 int *min;
2614 int *max;
2615};
2616
Amerigo Wang00b7c332010-05-05 00:26:45 +00002617static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2618 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619 int write, void *data)
2620{
2621 struct do_proc_dointvec_minmax_conv_param *param = data;
2622 if (write) {
Zev Weiss45a67f12019-03-11 23:28:02 -07002623 int val;
2624 if (*negp) {
2625 if (*lvalp > (unsigned long) INT_MAX + 1)
2626 return -EINVAL;
2627 val = -*lvalp;
2628 } else {
2629 if (*lvalp > (unsigned long) INT_MAX)
2630 return -EINVAL;
2631 val = *lvalp;
2632 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633 if ((param->min && *param->min > val) ||
2634 (param->max && *param->max < val))
2635 return -EINVAL;
2636 *valp = val;
2637 } else {
2638 int val = *valp;
2639 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002640 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002641 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002642 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002643 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 *lvalp = (unsigned long)val;
2645 }
2646 }
2647 return 0;
2648}
2649
2650/**
2651 * proc_dointvec_minmax - read a vector of integers with min/max values
2652 * @table: the sysctl table
2653 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 * @buffer: the user buffer
2655 * @lenp: the size of the user buffer
2656 * @ppos: file position
2657 *
2658 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2659 * values from/to the user buffer, treated as an ASCII string.
2660 *
2661 * This routine will ensure the values are within the range specified by
2662 * table->extra1 (min) and table->extra2 (max).
2663 *
2664 * Returns 0 on success.
2665 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002666int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 void __user *buffer, size_t *lenp, loff_t *ppos)
2668{
2669 struct do_proc_dointvec_minmax_conv_param param = {
2670 .min = (int *) table->extra1,
2671 .max = (int *) table->extra2,
2672 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002673 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 do_proc_dointvec_minmax_conv, &param);
2675}
2676
Kees Cook54b50192012-07-30 14:39:18 -07002677static void validate_coredump_safety(void)
2678{
Alex Kelly046d6622012-10-04 17:15:23 -07002679#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002680 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002681 core_pattern[0] != '/' && core_pattern[0] != '|') {
2682 printk(KERN_WARNING "Unsafe core_pattern used with "\
2683 "suid_dumpable=2. Pipe handler or fully qualified "\
2684 "core dump path required.\n");
2685 }
Alex Kelly046d6622012-10-04 17:15:23 -07002686#endif
Kees Cook54b50192012-07-30 14:39:18 -07002687}
2688
2689static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2690 void __user *buffer, size_t *lenp, loff_t *ppos)
2691{
2692 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2693 if (!error)
2694 validate_coredump_safety();
2695 return error;
2696}
2697
Alex Kelly046d6622012-10-04 17:15:23 -07002698#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002699static int proc_dostring_coredump(struct ctl_table *table, int write,
2700 void __user *buffer, size_t *lenp, loff_t *ppos)
2701{
2702 int error = proc_dostring(table, write, buffer, lenp, ppos);
2703 if (!error)
2704 validate_coredump_safety();
2705 return error;
2706}
Alex Kelly046d6622012-10-04 17:15:23 -07002707#endif
Kees Cook54b50192012-07-30 14:39:18 -07002708
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002709static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002710 void __user *buffer,
2711 size_t *lenp, loff_t *ppos,
2712 unsigned long convmul,
2713 unsigned long convdiv)
2714{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002715 unsigned long *i, *min, *max;
2716 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002717 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002718 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002719
2720 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002721 *lenp = 0;
2722 return 0;
2723 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002724
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002725 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002726 min = (unsigned long *) table->extra1;
2727 max = (unsigned long *) table->extra2;
2728 vleft = table->maxlen / sizeof(unsigned long);
2729 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002730
2731 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002732 if (*ppos) {
2733 switch (sysctl_writes_strict) {
2734 case SYSCTL_WRITES_STRICT:
2735 goto out;
2736 case SYSCTL_WRITES_WARN:
2737 warn_sysctl_write(table);
2738 break;
2739 default:
2740 break;
2741 }
2742 }
2743
Amerigo Wang00b7c332010-05-05 00:26:45 +00002744 if (left > PAGE_SIZE - 1)
2745 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002746 p = kbuf = memdup_user_nul(buffer, left);
2747 if (IS_ERR(kbuf))
2748 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002749 }
2750
Eric Dumazet27b3d802010-10-07 12:59:29 -07002751 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002752 unsigned long val;
2753
Linus Torvalds1da177e2005-04-16 15:20:36 -07002754 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002755 bool neg;
2756
Al Viro70f6cbb2015-12-24 00:13:10 -05002757 left -= proc_skip_spaces(&p);
Cheng Lin0e5c7502019-01-03 15:26:13 -08002758 if (!left)
2759 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002760
Al Viro70f6cbb2015-12-24 00:13:10 -05002761 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002762 proc_wspace_sep,
2763 sizeof(proc_wspace_sep), NULL);
2764 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002765 break;
2766 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002768 val = convmul * val / convdiv;
Christian Brauner726f69d2019-05-14 15:44:55 -07002769 if ((min && val < *min) || (max && val > *max)) {
2770 err = -EINVAL;
2771 break;
2772 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773 *i = val;
2774 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002775 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002776 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002777 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002778 if (err)
2779 break;
2780 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002781 err = proc_put_long(&buffer, &left, val, false);
2782 if (err)
2783 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002784 }
2785 }
2786
Amerigo Wang00b7c332010-05-05 00:26:45 +00002787 if (!write && !first && left && !err)
2788 err = proc_put_char(&buffer, &left, '\n');
2789 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002790 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002791 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002792 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002793 if (first)
2794 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002795 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002796 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002797out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002798 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002799 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002800}
2801
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002802static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002803 void __user *buffer,
2804 size_t *lenp, loff_t *ppos,
2805 unsigned long convmul,
2806 unsigned long convdiv)
2807{
2808 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002809 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002810}
2811
Linus Torvalds1da177e2005-04-16 15:20:36 -07002812/**
2813 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2814 * @table: the sysctl table
2815 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002816 * @buffer: the user buffer
2817 * @lenp: the size of the user buffer
2818 * @ppos: file position
2819 *
2820 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2821 * values from/to the user buffer, treated as an ASCII string.
2822 *
2823 * This routine will ensure the values are within the range specified by
2824 * table->extra1 (min) and table->extra2 (max).
2825 *
2826 * Returns 0 on success.
2827 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002828int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002829 void __user *buffer, size_t *lenp, loff_t *ppos)
2830{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002831 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002832}
2833
2834/**
2835 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2836 * @table: the sysctl table
2837 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002838 * @buffer: the user buffer
2839 * @lenp: the size of the user buffer
2840 * @ppos: file position
2841 *
2842 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2843 * values from/to the user buffer, treated as an ASCII string. The values
2844 * are treated as milliseconds, and converted to jiffies when they are stored.
2845 *
2846 * This routine will ensure the values are within the range specified by
2847 * table->extra1 (min) and table->extra2 (max).
2848 *
2849 * Returns 0 on success.
2850 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002851int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002852 void __user *buffer,
2853 size_t *lenp, loff_t *ppos)
2854{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002855 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002856 lenp, ppos, HZ, 1000l);
2857}
2858
2859
Amerigo Wang00b7c332010-05-05 00:26:45 +00002860static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002861 int *valp,
2862 int write, void *data)
2863{
2864 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002865 if (*lvalp > LONG_MAX / HZ)
2866 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002867 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2868 } else {
2869 int val = *valp;
2870 unsigned long lval;
2871 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002872 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002873 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002874 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002875 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002876 lval = (unsigned long)val;
2877 }
2878 *lvalp = lval / HZ;
2879 }
2880 return 0;
2881}
2882
Amerigo Wang00b7c332010-05-05 00:26:45 +00002883static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884 int *valp,
2885 int write, void *data)
2886{
2887 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002888 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2889 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002890 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2891 } else {
2892 int val = *valp;
2893 unsigned long lval;
2894 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002895 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002896 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002897 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002898 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899 lval = (unsigned long)val;
2900 }
2901 *lvalp = jiffies_to_clock_t(lval);
2902 }
2903 return 0;
2904}
2905
Amerigo Wang00b7c332010-05-05 00:26:45 +00002906static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907 int *valp,
2908 int write, void *data)
2909{
2910 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002911 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2912
2913 if (jif > INT_MAX)
2914 return 1;
2915 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002916 } else {
2917 int val = *valp;
2918 unsigned long lval;
2919 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002920 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002921 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002923 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002924 lval = (unsigned long)val;
2925 }
2926 *lvalp = jiffies_to_msecs(lval);
2927 }
2928 return 0;
2929}
2930
2931/**
2932 * proc_dointvec_jiffies - read a vector of integers as seconds
2933 * @table: the sysctl table
2934 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002935 * @buffer: the user buffer
2936 * @lenp: the size of the user buffer
2937 * @ppos: file position
2938 *
2939 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2940 * values from/to the user buffer, treated as an ASCII string.
2941 * The values read are assumed to be in seconds, and are converted into
2942 * jiffies.
2943 *
2944 * Returns 0 on success.
2945 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002946int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947 void __user *buffer, size_t *lenp, loff_t *ppos)
2948{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002949 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950 do_proc_dointvec_jiffies_conv,NULL);
2951}
2952
2953/**
2954 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2955 * @table: the sysctl table
2956 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957 * @buffer: the user buffer
2958 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002959 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002960 *
2961 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2962 * values from/to the user buffer, treated as an ASCII string.
2963 * The values read are assumed to be in 1/USER_HZ seconds, and
2964 * are converted into jiffies.
2965 *
2966 * Returns 0 on success.
2967 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002968int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002969 void __user *buffer, size_t *lenp, loff_t *ppos)
2970{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002971 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 do_proc_dointvec_userhz_jiffies_conv,NULL);
2973}
2974
2975/**
2976 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2977 * @table: the sysctl table
2978 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002979 * @buffer: the user buffer
2980 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002981 * @ppos: file position
2982 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002983 *
2984 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2985 * values from/to the user buffer, treated as an ASCII string.
2986 * The values read are assumed to be in 1/1000 seconds, and
2987 * are converted into jiffies.
2988 *
2989 * Returns 0 on success.
2990 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002991int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002992 void __user *buffer, size_t *lenp, loff_t *ppos)
2993{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002994 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002995 do_proc_dointvec_ms_jiffies_conv, NULL);
2996}
2997
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002998static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002999 void __user *buffer, size_t *lenp, loff_t *ppos)
3000{
3001 struct pid *new_pid;
3002 pid_t tmp;
3003 int r;
3004
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08003005 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003006
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003007 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003008 lenp, ppos, NULL, NULL);
3009 if (r || !write)
3010 return r;
3011
3012 new_pid = find_get_pid(tmp);
3013 if (!new_pid)
3014 return -ESRCH;
3015
3016 put_pid(xchg(&cad_pid, new_pid));
3017 return 0;
3018}
3019
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003020/**
3021 * proc_do_large_bitmap - read/write from/to a large bitmap
3022 * @table: the sysctl table
3023 * @write: %TRUE if this is a write to the sysctl file
3024 * @buffer: the user buffer
3025 * @lenp: the size of the user buffer
3026 * @ppos: file position
3027 *
3028 * The bitmap is stored at table->data and the bitmap length (in bits)
3029 * in table->maxlen.
3030 *
3031 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3032 * large bitmaps may be represented in a compact manner. Writing into
3033 * the file will clear the bitmap then update it with the given input.
3034 *
3035 * Returns 0 on success.
3036 */
3037int proc_do_large_bitmap(struct ctl_table *table, int write,
3038 void __user *buffer, size_t *lenp, loff_t *ppos)
3039{
3040 int err = 0;
3041 bool first = 1;
3042 size_t left = *lenp;
3043 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07003044 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003045 unsigned long *tmp_bitmap = NULL;
3046 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3047
WANG Cong122ff242014-05-12 16:04:53 -07003048 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003049 *lenp = 0;
3050 return 0;
3051 }
3052
3053 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003054 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003055
3056 if (left > PAGE_SIZE - 1)
3057 left = PAGE_SIZE - 1;
3058
Al Viro70f6cbb2015-12-24 00:13:10 -05003059 p = kbuf = memdup_user_nul(buffer, left);
3060 if (IS_ERR(kbuf))
3061 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003062
3063 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
3064 GFP_KERNEL);
3065 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003066 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003067 return -ENOMEM;
3068 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003069 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003070 while (!err && left) {
3071 unsigned long val_a, val_b;
3072 bool neg;
3073
Al Viro70f6cbb2015-12-24 00:13:10 -05003074 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003075 sizeof(tr_a), &c);
3076 if (err)
3077 break;
3078 if (val_a >= bitmap_len || neg) {
3079 err = -EINVAL;
3080 break;
3081 }
3082
3083 val_b = val_a;
3084 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003085 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003086 left--;
3087 }
3088
3089 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05003090 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003091 &neg, tr_b, sizeof(tr_b),
3092 &c);
3093 if (err)
3094 break;
3095 if (val_b >= bitmap_len || neg ||
3096 val_a > val_b) {
3097 err = -EINVAL;
3098 break;
3099 }
3100 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003101 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003102 left--;
3103 }
3104 }
3105
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003106 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003107 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003108 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003109 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003110 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003111 } else {
3112 unsigned long bit_a, bit_b = 0;
3113
3114 while (left) {
3115 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3116 if (bit_a >= bitmap_len)
3117 break;
3118 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3119 bit_a + 1) - 1;
3120
3121 if (!first) {
3122 err = proc_put_char(&buffer, &left, ',');
3123 if (err)
3124 break;
3125 }
3126 err = proc_put_long(&buffer, &left, bit_a, false);
3127 if (err)
3128 break;
3129 if (bit_a != bit_b) {
3130 err = proc_put_char(&buffer, &left, '-');
3131 if (err)
3132 break;
3133 err = proc_put_long(&buffer, &left, bit_b, false);
3134 if (err)
3135 break;
3136 }
3137
3138 first = 0; bit_b++;
3139 }
3140 if (!err)
3141 err = proc_put_char(&buffer, &left, '\n');
3142 }
3143
3144 if (!err) {
3145 if (write) {
3146 if (*ppos)
3147 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3148 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003149 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003150 }
3151 kfree(tmp_bitmap);
3152 *lenp -= left;
3153 *ppos += *lenp;
3154 return 0;
3155 } else {
3156 kfree(tmp_bitmap);
3157 return err;
3158 }
3159}
3160
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003161static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp,
3162 int *valp, int write, void *data)
3163{
3164 if (write) {
Satya Durga Srinivasu Prabhala3929bf02018-08-24 12:23:08 -07003165 if (*negp || *lvalp == 0)
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003166 return -EINVAL;
3167 *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp;
3168 } else {
3169 *negp = false;
3170 *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp;
3171 }
3172
3173 return 0;
3174}
3175
3176/**
3177 * proc_douintvec_capacity - read a vector of integers in percentage and convert
3178 * into sched capacity
3179 * @table: the sysctl table
3180 * @write: %TRUE if this is a write to the sysctl file
3181 * @buffer: the user buffer
3182 * @lenp: the size of the user buffer
3183 * @ppos: file position
3184 *
3185 * Returns 0 on success.
3186 */
3187int proc_douintvec_capacity(struct ctl_table *table, int write,
3188 void __user *buffer, size_t *lenp, loff_t *ppos)
3189{
3190 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3191 do_proc_douintvec_capacity_conv, NULL);
3192}
3193
Jovi Zhang55610502011-01-12 17:00:45 -08003194#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003195
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003196int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003197 void __user *buffer, size_t *lenp, loff_t *ppos)
3198{
3199 return -ENOSYS;
3200}
3201
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003202int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003203 void __user *buffer, size_t *lenp, loff_t *ppos)
3204{
3205 return -ENOSYS;
3206}
3207
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003208int proc_douintvec(struct ctl_table *table, int write,
3209 void __user *buffer, size_t *lenp, loff_t *ppos)
3210{
3211 return -ENOSYS;
3212}
3213
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003214int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003215 void __user *buffer, size_t *lenp, loff_t *ppos)
3216{
3217 return -ENOSYS;
3218}
3219
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003220int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003221 void __user *buffer, size_t *lenp, loff_t *ppos)
3222{
3223 return -ENOSYS;
3224}
3225
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003226int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003227 void __user *buffer, size_t *lenp, loff_t *ppos)
3228{
3229 return -ENOSYS;
3230}
3231
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003232int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003233 void __user *buffer, size_t *lenp, loff_t *ppos)
3234{
3235 return -ENOSYS;
3236}
3237
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003238int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003239 void __user *buffer, size_t *lenp, loff_t *ppos)
3240{
3241 return -ENOSYS;
3242}
3243
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003244int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003245 void __user *buffer,
3246 size_t *lenp, loff_t *ppos)
3247{
3248 return -ENOSYS;
3249}
3250
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003251int proc_douintvec_capacity(struct ctl_table *table, int write,
3252 void __user *buffer, size_t *lenp, loff_t *ppos)
3253{
3254 return -ENOSYS;
3255}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003256
Jovi Zhang55610502011-01-12 17:00:45 -08003257#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003258
Linus Torvalds1da177e2005-04-16 15:20:36 -07003259/*
3260 * No sense putting this after each symbol definition, twice,
3261 * exception granted :-)
3262 */
3263EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003264EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003265EXPORT_SYMBOL(proc_dointvec_jiffies);
3266EXPORT_SYMBOL(proc_dointvec_minmax);
3267EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3268EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3269EXPORT_SYMBOL(proc_dostring);
3270EXPORT_SYMBOL(proc_doulongvec_minmax);
3271EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);