blob: 81e0209ecdad7a03ffae0faf93e46b3f0d1195ae [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>
tracychui312da522020-06-12 17:46:51 +080069/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
70#include <soc/qcom/smem.h>
71/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73#include <asm/uaccess.h>
74#include <asm/processor.h>
75
Andi Kleen29cbc782006-09-30 01:47:55 +020076#ifdef CONFIG_X86
77#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010078#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010079#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020080#endif
David Howellsd550bbd2012-03-28 18:30:03 +010081#ifdef CONFIG_SPARC
82#include <asm/setup.h>
83#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080084#ifdef CONFIG_BSD_PROCESS_ACCT
85#include <linux/acct.h>
86#endif
Dave Young4f0e0562010-03-10 15:24:09 -080087#ifdef CONFIG_RT_MUTEXES
88#include <linux/rtmutex.h>
89#endif
Dave Young2edf5e42010-03-10 15:24:10 -080090#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
91#include <linux/lockdep.h>
92#endif
Dave Young15485a42010-03-10 15:24:07 -080093#ifdef CONFIG_CHR_DEV_SG
94#include <scsi/sg.h>
95#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020096
Don Zickus58687ac2010-05-07 17:11:44 -040097#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050098#include <linux/nmi.h>
99#endif
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#if defined(CONFIG_SYSCTL)
102
103/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700104extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700105#ifdef CONFIG_COREDUMP
106extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700108extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700109#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800112extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100113extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300114extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000115#ifndef CONFIG_MMU
116extern int sysctl_nr_trim_pages;
117#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400120#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121static int sixty = 60;
122#endif
123
Aaron Tomlin270750db2014-01-20 17:34:13 +0000124static int __maybe_unused neg_one = -1;
125
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700126static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700127static int __maybe_unused one = 1;
128static int __maybe_unused two = 2;
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700129static int __maybe_unused three = 3;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700130static int __maybe_unused four = 4;
Will Deacon3141fcc2019-04-05 18:39:38 -0700131static unsigned long zero_ul;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800132static unsigned long one_ul = 1;
Christian Brauner6b65c262019-03-07 16:29:43 -0800133static unsigned long long_max = LONG_MAX;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700134static int one_hundred = 100;
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700135static int __maybe_unused one_thousand = 1000;
Satya Durga Srinivasu Prabhalac18b4032018-04-17 11:21:23 -0700136#ifdef CONFIG_SCHED_WALT
137static int two_million = 2000000;
138#endif
Dave Youngaf913222009-09-22 16:43:33 -0700139#ifdef CONFIG_PRINTK
140static int ten_thousand = 10000;
141#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300142#ifdef CONFIG_PERF_EVENTS
143static int six_hundred_forty_kb = 640 * 1024;
144#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700145
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700146/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
147static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
150static int maxolduid = 65535;
151static int minolduid;
152
153static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700154static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Liu Hua80df2842014-04-07 15:38:57 -0700156/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
157#ifdef CONFIG_DETECT_HUNG_TASK
158static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
159#endif
160
Dave Youngd14f1722010-02-25 20:28:57 -0500161#ifdef CONFIG_INOTIFY_USER
162#include <linux/inotify.h>
163#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700164#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165#endif
166
167#ifdef __hppa__
168extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530169#endif
170
171#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172extern int unaligned_enabled;
173#endif
174
Jes Sorensend2b176e2006-02-28 09:42:23 -0800175#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800176extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800177#endif
178
Vineet Guptab6fca722013-01-09 20:06:28 +0530179#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
180extern int no_unaligned_warning;
181#endif
182
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700183#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700184
185#define SYSCTL_WRITES_LEGACY -1
186#define SYSCTL_WRITES_WARN 0
187#define SYSCTL_WRITES_STRICT 1
188
Kees Cook41662f52016-01-20 15:00:45 -0800189static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700190
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700191static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700192 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700193static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800194 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700195#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700196
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700197#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700198static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700199 void __user *buffer, size_t *lenp, loff_t *ppos);
200#endif
201
Kees Cook54b50192012-07-30 14:39:18 -0700202static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
203 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700204#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700205static int proc_dostring_coredump(struct ctl_table *table, int write,
206 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700207#endif
Kees Cook54b50192012-07-30 14:39:18 -0700208
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700209#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800210/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100211static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700212
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700213static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700214 void __user *buffer, size_t *lenp,
215 loff_t *ppos)
216{
217 int error;
218
219 error = proc_dointvec(table, write, buffer, lenp, ppos);
220 if (error)
221 return error;
222
223 if (write)
224 sysrq_toggle_support(__sysrq_enabled);
225
226 return 0;
227}
228
229#endif
230
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700231static struct ctl_table kern_table[];
232static struct ctl_table vm_table[];
233static struct ctl_table fs_table[];
234static struct ctl_table debug_table[];
235static struct ctl_table dev_table[];
tracychui312da522020-06-12 17:46:51 +0800236/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
237static struct ctl_table qpnp_power_on_table[];
238static struct ctl_table ddr_table[];
239/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700240extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800241#ifdef CONFIG_EPOLL
242extern struct ctl_table epoll_table[];
243#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
245#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
246int sysctl_legacy_va_layout;
247#endif
248
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249/* The default sysctl tables: */
250
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800251static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 .procname = "kernel",
254 .mode = 0555,
255 .child = kern_table,
256 },
257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 .procname = "vm",
259 .mode = 0555,
260 .child = vm_table,
261 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 .procname = "fs",
264 .mode = 0555,
265 .child = fs_table,
266 },
267 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 .procname = "debug",
269 .mode = 0555,
270 .child = debug_table,
271 },
272 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 .procname = "dev",
274 .mode = 0555,
275 .child = dev_table,
276 },
tracychui312da522020-06-12 17:46:51 +0800277/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
278 {
279 .procname = "qpnp-power-on",
280 .mode = 0555,
281 .child = qpnp_power_on_table,
282 },
283/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700284 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285};
286
Ingo Molnar77e54a12007-07-09 18:52:00 +0200287#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100288static int min_sched_granularity_ns = 100000; /* 100 usecs */
289static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
290static int min_wakeup_granularity_ns; /* 0 usecs */
291static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200292#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100293static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
294static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200295#endif /* CONFIG_SMP */
296#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200297
Mel Gorman5e771902010-05-24 14:32:31 -0700298#ifdef CONFIG_COMPACTION
299static int min_extfrag_threshold;
300static int max_extfrag_threshold = 1000;
301#endif
302
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700303static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200304 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200305 .procname = "sched_child_runs_first",
306 .data = &sysctl_sched_child_runs_first,
307 .maxlen = sizeof(unsigned int),
308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800309 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200310 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530311#if defined(CONFIG_PREEMPT_TRACER) || defined(CONFIG_IRQSOFF_TRACER)
312 {
313 .procname = "preemptoff_tracing_threshold_ns",
314 .data = &sysctl_preemptoff_tracing_threshold_ns,
315 .maxlen = sizeof(unsigned int),
316 .mode = 0644,
317 .proc_handler = proc_dointvec,
318 },
Pavankumar Kondeti0d2621b2018-03-26 15:56:26 +0530319 {
320 .procname = "irqsoff_tracing_threshold_ns",
321 .data = &sysctl_irqsoff_tracing_threshold_ns,
322 .maxlen = sizeof(unsigned int),
323 .mode = 0644,
324 .proc_handler = proc_dointvec,
325 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530326#endif
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800327#ifdef CONFIG_SCHED_WALT
328 {
329 .procname = "sched_cpu_high_irqload",
330 .data = &sysctl_sched_cpu_high_irqload,
331 .maxlen = sizeof(unsigned int),
332 .mode = 0644,
333 .proc_handler = proc_dointvec,
334 },
Joonwoo Park6f188472017-06-16 11:32:17 -0700335 {
336 .procname = "sched_group_upmigrate",
337 .data = &sysctl_sched_group_upmigrate_pct,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700340 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700341 .extra1 = &sysctl_sched_group_downmigrate_pct,
342 },
343 {
344 .procname = "sched_group_downmigrate",
345 .data = &sysctl_sched_group_downmigrate_pct,
346 .maxlen = sizeof(unsigned int),
347 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700348 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700349 .extra1 = &zero,
350 .extra2 = &sysctl_sched_group_upmigrate_pct,
351 },
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530352 {
353 .procname = "sched_boost",
354 .data = &sysctl_sched_boost,
355 .maxlen = sizeof(unsigned int),
356 .mode = 0644,
357 .proc_handler = sched_boost_handler,
358 .extra1 = &zero,
359 .extra2 = &three,
360 },
Pavankumar Kondeti4e13d112018-01-25 01:12:08 +0530361 {
362 .procname = "sched_walt_rotate_big_tasks",
363 .data = &sysctl_sched_walt_rotate_big_tasks,
364 .maxlen = sizeof(unsigned int),
365 .mode = 0644,
366 .proc_handler = proc_dointvec_minmax,
367 .extra1 = &zero,
368 .extra2 = &one,
369 },
Lingutla Chandrasekhar57eb0712018-03-12 10:20:08 +0530370 {
371 .procname = "sched_initial_task_util",
372 .data = &sysctl_sched_init_task_load_pct,
373 .maxlen = sizeof(unsigned int),
374 .mode = 0644,
375 .proc_handler = proc_dointvec,
376 },
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700377 {
378 .procname = "sched_min_task_util_for_boost_colocation",
379 .data = &sysctl_sched_min_task_util_for_boost_colocation,
380 .maxlen = sizeof(unsigned int),
381 .mode = 0644,
382 .proc_handler = proc_dointvec_minmax,
383 .extra1 = &zero,
384 .extra2 = &one_thousand,
385 },
Satya Durga Srinivasu Prabhalac18b4032018-04-17 11:21:23 -0700386 {
387 .procname = "sched_little_cluster_coloc_fmin_khz",
388 .data = &sysctl_sched_little_cluster_coloc_fmin_khz,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
391 .proc_handler = sched_little_cluster_coloc_fmin_khz_handler,
392 .extra1 = &zero,
393 .extra2 = &two_million,
394 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800395#endif
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530396 {
397 .procname = "sched_upmigrate",
398 .data = &sysctl_sched_capacity_margin,
399 .maxlen = sizeof(unsigned int),
400 .mode = 0644,
401 .proc_handler = sched_updown_migrate_handler,
402 },
403 {
404 .procname = "sched_downmigrate",
405 .data = &sysctl_sched_capacity_margin_down,
406 .maxlen = sizeof(unsigned int),
407 .mode = 0644,
408 .proc_handler = sched_updown_migrate_handler,
409 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200410#ifdef CONFIG_SCHED_DEBUG
411 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100412 .procname = "sched_min_granularity_ns",
413 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200414 .maxlen = sizeof(unsigned int),
415 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800416 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100417 .extra1 = &min_sched_granularity_ns,
418 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200419 },
420 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200421 .procname = "sched_latency_ns",
422 .data = &sysctl_sched_latency,
423 .maxlen = sizeof(unsigned int),
424 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800425 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200426 .extra1 = &min_sched_granularity_ns,
427 .extra2 = &max_sched_granularity_ns,
428 },
429 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000430 .procname = "sched_sync_hint_enable",
431 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100432 .maxlen = sizeof(unsigned int),
433 .mode = 0644,
434 .proc_handler = proc_dointvec,
435 },
436 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100437 .procname = "sched_cstate_aware",
438 .data = &sysctl_sched_cstate_aware,
439 .maxlen = sizeof(unsigned int),
440 .mode = 0644,
441 .proc_handler = proc_dointvec,
442 },
443 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200444 .procname = "sched_wakeup_granularity_ns",
445 .data = &sysctl_sched_wakeup_granularity,
446 .maxlen = sizeof(unsigned int),
447 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800448 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200449 .extra1 = &min_wakeup_granularity_ns,
450 .extra2 = &max_wakeup_granularity_ns,
451 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200452#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200453 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100454 .procname = "sched_tunable_scaling",
455 .data = &sysctl_sched_tunable_scaling,
456 .maxlen = sizeof(enum sched_tunable_scaling),
457 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800458 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100459 .extra1 = &min_sched_tunable_scaling,
460 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200461 },
462 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900463 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200464 .data = &sysctl_sched_migration_cost,
465 .maxlen = sizeof(unsigned int),
466 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800467 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200468 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100469 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100470 .procname = "sched_nr_migrate",
471 .data = &sysctl_sched_nr_migrate,
472 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800474 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100475 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530476 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900477 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200478 .data = &sysctl_sched_time_avg,
479 .maxlen = sizeof(unsigned int),
480 .mode = 0644,
Pavankumar Kondeti12939492017-02-02 14:24:34 +0530481 .proc_handler = proc_dointvec_minmax,
482 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200483 },
484 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900485 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800486 .data = &sysctl_sched_shares_window,
487 .maxlen = sizeof(unsigned int),
488 .mode = 0644,
489 .proc_handler = proc_dointvec,
490 },
Mel Gormancb251762016-02-05 09:08:36 +0000491#ifdef CONFIG_SCHEDSTATS
492 {
493 .procname = "sched_schedstats",
494 .data = NULL,
495 .maxlen = sizeof(unsigned int),
496 .mode = 0644,
497 .proc_handler = sysctl_schedstats,
498 .extra1 = &zero,
499 .extra2 = &one,
500 },
501#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200502#endif /* CONFIG_SMP */
503#ifdef CONFIG_NUMA_BALANCING
504 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200505 .procname = "numa_balancing_scan_delay_ms",
506 .data = &sysctl_numa_balancing_scan_delay,
507 .maxlen = sizeof(unsigned int),
508 .mode = 0644,
509 .proc_handler = proc_dointvec,
510 },
511 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200512 .procname = "numa_balancing_scan_period_min_ms",
513 .data = &sysctl_numa_balancing_scan_period_min,
514 .maxlen = sizeof(unsigned int),
515 .mode = 0644,
516 .proc_handler = proc_dointvec,
517 },
518 {
519 .procname = "numa_balancing_scan_period_max_ms",
520 .data = &sysctl_numa_balancing_scan_period_max,
521 .maxlen = sizeof(unsigned int),
522 .mode = 0644,
523 .proc_handler = proc_dointvec,
524 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200525 {
526 .procname = "numa_balancing_scan_size_mb",
527 .data = &sysctl_numa_balancing_scan_size,
528 .maxlen = sizeof(unsigned int),
529 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400530 .proc_handler = proc_dointvec_minmax,
531 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200532 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100533 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800534 .procname = "numa_balancing",
535 .data = NULL, /* filled in by handler */
536 .maxlen = sizeof(unsigned int),
537 .mode = 0644,
538 .proc_handler = sysctl_numa_balancing,
539 .extra1 = &zero,
540 .extra2 = &one,
541 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200542#endif /* CONFIG_NUMA_BALANCING */
543#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200544 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100545 .procname = "sched_rt_period_us",
546 .data = &sysctl_sched_rt_period,
547 .maxlen = sizeof(unsigned int),
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100550 },
551 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100552 .procname = "sched_rt_runtime_us",
553 .data = &sysctl_sched_rt_runtime,
554 .maxlen = sizeof(int),
555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100557 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600558 {
559 .procname = "sched_rr_timeslice_ms",
560 .data = &sched_rr_timeslice,
561 .maxlen = sizeof(int),
562 .mode = 0644,
563 .proc_handler = sched_rr_handler,
564 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100565#ifdef CONFIG_SCHED_AUTOGROUP
566 {
567 .procname = "sched_autogroup_enabled",
568 .data = &sysctl_sched_autogroup_enabled,
569 .maxlen = sizeof(unsigned int),
570 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800571 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100572 .extra1 = &zero,
573 .extra2 = &one,
574 },
575#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700576#ifdef CONFIG_CFS_BANDWIDTH
577 {
578 .procname = "sched_cfs_bandwidth_slice_us",
579 .data = &sysctl_sched_cfs_bandwidth_slice,
580 .maxlen = sizeof(unsigned int),
581 .mode = 0644,
582 .proc_handler = proc_dointvec_minmax,
583 .extra1 = &one,
584 },
585#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100586#ifdef CONFIG_SCHED_TUNE
587 {
588 .procname = "sched_cfs_boost",
589 .data = &sysctl_sched_cfs_boost,
590 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100591#ifdef CONFIG_CGROUP_SCHEDTUNE
592 .mode = 0444,
593#else
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100594 .mode = 0644,
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100595#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100596 .proc_handler = &sysctl_sched_cfs_boost_handler,
597 .extra1 = &zero,
598 .extra2 = &one_hundred,
599 },
600#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700601#ifdef CONFIG_PROVE_LOCKING
602 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700603 .procname = "prove_locking",
604 .data = &prove_locking,
605 .maxlen = sizeof(int),
606 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800607 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700608 },
609#endif
610#ifdef CONFIG_LOCK_STAT
611 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700612 .procname = "lock_stat",
613 .data = &lock_stat,
614 .maxlen = sizeof(int),
615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800616 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700617 },
618#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200619 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 .procname = "panic",
621 .data = &panic_timeout,
622 .maxlen = sizeof(int),
623 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800624 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 },
Alex Kelly046d6622012-10-04 17:15:23 -0700626#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 .procname = "core_uses_pid",
629 .data = &core_uses_pid,
630 .maxlen = sizeof(int),
631 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800632 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 },
634 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 .procname = "core_pattern",
636 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700637 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700639 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 },
Neil Hormana2939802009-09-23 15:56:56 -0700641 {
Neil Hormana2939802009-09-23 15:56:56 -0700642 .procname = "core_pipe_limit",
643 .data = &core_pipe_limit,
644 .maxlen = sizeof(unsigned int),
645 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800646 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700647 },
Alex Kelly046d6622012-10-04 17:15:23 -0700648#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800649#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700652 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800653 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800654 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700656 {
657 .procname = "sysctl_writes_strict",
658 .data = &sysctl_writes_strict,
659 .maxlen = sizeof(int),
660 .mode = 0644,
661 .proc_handler = proc_dointvec_minmax,
662 .extra1 = &neg_one,
663 .extra2 = &one,
664 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800665#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100666#ifdef CONFIG_LATENCYTOP
667 {
668 .procname = "latencytop",
669 .data = &latencytop_enabled,
670 .maxlen = sizeof(int),
671 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000672 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100673 },
674#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675#ifdef CONFIG_BLK_DEV_INITRD
676 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .procname = "real-root-dev",
678 .data = &real_root_dev,
679 .maxlen = sizeof(int),
680 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800681 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 },
683#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700684 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700685 .procname = "print-fatal-signals",
686 .data = &print_fatal_signals,
687 .maxlen = sizeof(int),
688 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800689 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700690 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700691#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "reboot-cmd",
694 .data = reboot_command,
695 .maxlen = 256,
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
699 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .procname = "stop-a",
701 .data = &stop_a_enabled,
702 .maxlen = sizeof (int),
703 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800704 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 },
706 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 .procname = "scons-poweroff",
708 .data = &scons_pwroff,
709 .maxlen = sizeof (int),
710 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800711 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 },
713#endif
David S. Miller08714202008-11-16 23:49:24 -0800714#ifdef CONFIG_SPARC64
715 {
David S. Miller08714202008-11-16 23:49:24 -0800716 .procname = "tsb-ratio",
717 .data = &sysctl_tsb_ratio,
718 .maxlen = sizeof (int),
719 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800720 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800721 },
722#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723#ifdef __hppa__
724 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 .procname = "soft-power",
726 .data = &pwrsw_enabled,
727 .maxlen = sizeof (int),
728 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800729 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530731#endif
732#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 .procname = "unaligned-trap",
735 .data = &unaligned_enabled,
736 .maxlen = sizeof (int),
737 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800738 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 },
740#endif
741 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .procname = "ctrl-alt-del",
743 .data = &C_A_D,
744 .maxlen = sizeof(int),
745 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800746 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400748#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200749 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200750 .procname = "ftrace_enabled",
751 .data = &ftrace_enabled,
752 .maxlen = sizeof(int),
753 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800754 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200755 },
756#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500757#ifdef CONFIG_STACK_TRACER
758 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500759 .procname = "stack_tracer_enabled",
760 .data = &stack_tracer_enabled,
761 .maxlen = sizeof(int),
762 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800763 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500764 },
765#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400766#ifdef CONFIG_TRACING
767 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100768 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400769 .data = &ftrace_dump_on_oops,
770 .maxlen = sizeof(int),
771 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800772 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400773 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400774 {
775 .procname = "traceoff_on_warning",
776 .data = &__disable_trace_on_warning,
777 .maxlen = sizeof(__disable_trace_on_warning),
778 .mode = 0644,
779 .proc_handler = proc_dointvec,
780 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500781 {
782 .procname = "tracepoint_printk",
783 .data = &tracepoint_printk,
784 .maxlen = sizeof(tracepoint_printk),
785 .mode = 0644,
786 .proc_handler = proc_dointvec,
787 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400788#endif
Dave Young2965faa2015-09-09 15:38:55 -0700789#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800790 {
791 .procname = "kexec_load_disabled",
792 .data = &kexec_load_disabled,
793 .maxlen = sizeof(int),
794 .mode = 0644,
795 /* only handle a transition from default "0" to "1" */
796 .proc_handler = proc_dointvec_minmax,
797 .extra1 = &one,
798 .extra2 = &one,
799 },
800#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200801#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 .procname = "modprobe",
804 .data = &modprobe_path,
805 .maxlen = KMOD_PATH_LEN,
806 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800807 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 },
Kees Cook3d433212009-04-02 15:49:29 -0700809 {
Kees Cook3d433212009-04-02 15:49:29 -0700810 .procname = "modules_disabled",
811 .data = &modules_disabled,
812 .maxlen = sizeof(int),
813 .mode = 0644,
814 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800815 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700816 .extra1 = &one,
817 .extra2 = &one,
818 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700820#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100823 .data = &uevent_helper,
824 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800826 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 },
Michael Marineau86d56132014-04-10 14:09:31 -0700828#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829#ifdef CONFIG_CHR_DEV_SG
830 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 .procname = "sg-big-buff",
832 .data = &sg_big_buff,
833 .maxlen = sizeof (int),
834 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800835 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 },
837#endif
838#ifdef CONFIG_BSD_PROCESS_ACCT
839 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 .procname = "acct",
841 .data = &acct_parm,
842 .maxlen = 3*sizeof(int),
843 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800844 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 },
846#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847#ifdef CONFIG_MAGIC_SYSRQ
848 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800850 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 .maxlen = sizeof (int),
852 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700853 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 },
855#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700856#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700859 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 .maxlen = sizeof (int),
861 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800862 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700864#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700867 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 .maxlen = sizeof(int),
869 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700870 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 },
872 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 .procname = "random",
874 .mode = 0555,
875 .child = random_table,
876 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 {
Eric Paris17f60a72011-04-01 17:07:50 -0400878 .procname = "usermodehelper",
879 .mode = 0555,
880 .child = usermodehelper_table,
881 },
882 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 .procname = "overflowuid",
884 .data = &overflowuid,
885 .maxlen = sizeof(int),
886 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800887 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 .extra1 = &minolduid,
889 .extra2 = &maxolduid,
890 },
891 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 .procname = "overflowgid",
893 .data = &overflowgid,
894 .maxlen = sizeof(int),
895 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800896 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 .extra1 = &minolduid,
898 .extra2 = &maxolduid,
899 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800900#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901#ifdef CONFIG_MATHEMU
902 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 .procname = "ieee_emulation_warnings",
904 .data = &sysctl_ieee_emulation_warnings,
905 .maxlen = sizeof(int),
906 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800907 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 },
909#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200912 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 .maxlen = sizeof(int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 },
917#endif
918 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 .procname = "pid_max",
920 .data = &pid_max,
921 .maxlen = sizeof (int),
922 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800923 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 .extra1 = &pid_max_min,
925 .extra2 = &pid_max_max,
926 },
927 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 .procname = "panic_on_oops",
929 .data = &panic_on_oops,
930 .maxlen = sizeof(int),
931 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800932 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800934#if defined CONFIG_PRINTK
935 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800936 .procname = "printk",
937 .data = &console_loglevel,
938 .maxlen = 4*sizeof(int),
939 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800940 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800941 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700944 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 .maxlen = sizeof(int),
946 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800947 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 },
949 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700951 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952 .maxlen = sizeof(int),
953 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800954 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 },
Dave Youngaf913222009-09-22 16:43:33 -0700956 {
Dave Youngaf913222009-09-22 16:43:33 -0700957 .procname = "printk_delay",
958 .data = &printk_delay_msec,
959 .maxlen = sizeof(int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700962 .extra1 = &zero,
963 .extra2 = &ten_thousand,
964 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700966 .procname = "printk_devkmsg",
967 .data = devkmsg_log_str,
968 .maxlen = DEVKMSG_STR_MAX_SIZE,
969 .mode = 0644,
970 .proc_handler = devkmsg_sysctl_set_loglvl,
971 },
972 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800973 .procname = "dmesg_restrict",
974 .data = &dmesg_restrict,
975 .maxlen = sizeof(int),
976 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700977 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800978 .extra1 = &zero,
979 .extra2 = &one,
980 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800981 {
982 .procname = "kptr_restrict",
983 .data = &kptr_restrict,
984 .maxlen = sizeof(int),
985 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700986 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800987 .extra1 = &zero,
988 .extra2 = &two,
989 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800990#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800991 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 .procname = "ngroups_max",
993 .data = &ngroups_max,
994 .maxlen = sizeof (int),
995 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800996 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997 },
Dan Ballard73efc032011-10-31 17:11:20 -0700998 {
999 .procname = "cap_last_cap",
1000 .data = (void *)&cap_last_cap,
1001 .maxlen = sizeof(int),
1002 .mode = 0444,
1003 .proc_handler = proc_dointvec,
1004 },
Don Zickus58687ac2010-05-07 17:11:44 -04001005#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -05001006 {
Don Zickus58687ac2010-05-07 17:11:44 -04001007 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +02001008 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -05001009 .maxlen = sizeof (int),
1010 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001011 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001012 .extra1 = &zero,
1013 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -04001014 },
1015 {
1016 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001017 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -04001018 .maxlen = sizeof(int),
1019 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001020 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +08001021 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -04001022 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -05001023 },
Don Zickus2508ce12010-05-07 17:11:46 -04001024 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001025 .procname = "nmi_watchdog",
1026 .data = &nmi_watchdog_enabled,
1027 .maxlen = sizeof (int),
1028 .mode = 0644,
1029 .proc_handler = proc_nmi_watchdog,
1030 .extra1 = &zero,
1031#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
1032 .extra2 = &one,
1033#else
1034 .extra2 = &zero,
1035#endif
1036 },
1037 {
1038 .procname = "soft_watchdog",
1039 .data = &soft_watchdog_enabled,
1040 .maxlen = sizeof (int),
1041 .mode = 0644,
1042 .proc_handler = proc_soft_watchdog,
1043 .extra1 = &zero,
1044 .extra2 = &one,
1045 },
1046 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001047 .procname = "watchdog_cpumask",
1048 .data = &watchdog_cpumask_bits,
1049 .maxlen = NR_CPUS,
1050 .mode = 0644,
1051 .proc_handler = proc_watchdog_cpumask,
1052 },
1053 {
Don Zickus2508ce12010-05-07 17:11:46 -04001054 .procname = "softlockup_panic",
1055 .data = &softlockup_panic,
1056 .maxlen = sizeof(int),
1057 .mode = 0644,
1058 .proc_handler = proc_dointvec_minmax,
1059 .extra1 = &zero,
1060 .extra2 = &one,
1061 },
Don Zickusac1f5912015-11-05 18:44:44 -08001062#ifdef CONFIG_HARDLOCKUP_DETECTOR
1063 {
1064 .procname = "hardlockup_panic",
1065 .data = &hardlockup_panic,
1066 .maxlen = sizeof(int),
1067 .mode = 0644,
1068 .proc_handler = proc_dointvec_minmax,
1069 .extra1 = &zero,
1070 .extra2 = &one,
1071 },
1072#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001073#ifdef CONFIG_SMP
1074 {
1075 .procname = "softlockup_all_cpu_backtrace",
1076 .data = &sysctl_softlockup_all_cpu_backtrace,
1077 .maxlen = sizeof(int),
1078 .mode = 0644,
1079 .proc_handler = proc_dointvec_minmax,
1080 .extra1 = &zero,
1081 .extra2 = &one,
1082 },
Jiri Kosina55537872015-11-05 18:44:41 -08001083 {
1084 .procname = "hardlockup_all_cpu_backtrace",
1085 .data = &sysctl_hardlockup_all_cpu_backtrace,
1086 .maxlen = sizeof(int),
1087 .mode = 0644,
1088 .proc_handler = proc_dointvec_minmax,
1089 .extra1 = &zero,
1090 .extra2 = &one,
1091 },
Aaron Tomlined235872014-06-23 13:22:05 -07001092#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001093#endif
1094#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1095 {
1096 .procname = "unknown_nmi_panic",
1097 .data = &unknown_nmi_panic,
1098 .maxlen = sizeof (int),
1099 .mode = 0644,
1100 .proc_handler = proc_dointvec,
1101 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001102#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103#if defined(CONFIG_X86)
1104 {
Don Zickus8da5add2006-09-26 10:52:27 +02001105 .procname = "panic_on_unrecovered_nmi",
1106 .data = &panic_on_unrecovered_nmi,
1107 .maxlen = sizeof(int),
1108 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001109 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001110 },
1111 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001112 .procname = "panic_on_io_nmi",
1113 .data = &panic_on_io_nmi,
1114 .maxlen = sizeof(int),
1115 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001116 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001117 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001118#ifdef CONFIG_DEBUG_STACKOVERFLOW
1119 {
1120 .procname = "panic_on_stackoverflow",
1121 .data = &sysctl_panic_on_stackoverflow,
1122 .maxlen = sizeof(int),
1123 .mode = 0644,
1124 .proc_handler = proc_dointvec,
1125 },
1126#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001127 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 .procname = "bootloader_type",
1129 .data = &bootloader_type,
1130 .maxlen = sizeof (int),
1131 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001132 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001134 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001135 .procname = "bootloader_version",
1136 .data = &bootloader_version,
1137 .maxlen = sizeof (int),
1138 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001139 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001140 },
1141 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001142 .procname = "kstack_depth_to_print",
1143 .data = &kstack_depth_to_print,
1144 .maxlen = sizeof(int),
1145 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001146 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001147 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001148 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001149 .procname = "io_delay_type",
1150 .data = &io_delay_type,
1151 .maxlen = sizeof(int),
1152 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001153 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001154 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001156#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 .procname = "randomize_va_space",
1159 .data = &randomize_va_space,
1160 .maxlen = sizeof(int),
1161 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001162 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001164#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001165#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001166 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001167 .procname = "spin_retry",
1168 .data = &spin_retry,
1169 .maxlen = sizeof (int),
1170 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001171 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001172 },
1173#endif
Len Brown673d5b42007-07-28 03:33:16 -04001174#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001175 {
Pavel Machekc255d842006-02-20 18:27:58 -08001176 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001177 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001178 .maxlen = sizeof (unsigned long),
1179 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001180 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001181 },
1182#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301183#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001184 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001185 .procname = "ignore-unaligned-usertrap",
1186 .data = &no_unaligned_warning,
1187 .maxlen = sizeof (int),
1188 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001189 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001190 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301191#endif
1192#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001193 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001194 .procname = "unaligned-dump-stack",
1195 .data = &unaligned_dump_stack,
1196 .maxlen = sizeof (int),
1197 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001198 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001199 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001200#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001201#ifdef CONFIG_DETECT_HUNG_TASK
1202 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001203 .procname = "hung_task_panic",
1204 .data = &sysctl_hung_task_panic,
1205 .maxlen = sizeof(int),
1206 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001207 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001208 .extra1 = &zero,
1209 .extra2 = &one,
1210 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001211 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001212 .procname = "hung_task_check_count",
1213 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001214 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001215 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001216 .proc_handler = proc_dointvec_minmax,
1217 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001218 },
1219 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001220 .procname = "hung_task_timeout_secs",
1221 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001222 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001223 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001224 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001225 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001226 },
1227 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001228 .procname = "hung_task_warnings",
1229 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001230 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001231 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001232 .proc_handler = proc_dointvec_minmax,
1233 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001234 },
Imran Khana9788f42017-09-18 15:48:30 +05301235 {
1236 .procname = "hung_task_selective_monitoring",
1237 .data = &sysctl_hung_task_selective_monitoring,
1238 .maxlen = sizeof(int),
1239 .mode = 0644,
1240 .proc_handler = proc_dointvec_minmax,
1241 .extra1 = &zero,
1242 .extra2 = &one,
1243 },
1244
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001245#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001246#ifdef CONFIG_RT_MUTEXES
1247 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001248 .procname = "max_lock_depth",
1249 .data = &max_lock_depth,
1250 .maxlen = sizeof(int),
1251 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001252 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001253 },
1254#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001255 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001256 .procname = "poweroff_cmd",
1257 .data = &poweroff_cmd,
1258 .maxlen = POWEROFF_CMD_PATH_LEN,
1259 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001260 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001261 },
David Howells0b77f5b2008-04-29 01:01:32 -07001262#ifdef CONFIG_KEYS
1263 {
David Howells0b77f5b2008-04-29 01:01:32 -07001264 .procname = "keys",
1265 .mode = 0555,
1266 .child = key_sysctls,
1267 },
1268#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001269#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001270 /*
1271 * User-space scripts rely on the existence of this file
1272 * as a feature check for perf_events being enabled.
1273 *
1274 * So it's an ABI, do not remove!
1275 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001276 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001277 .procname = "perf_event_paranoid",
1278 .data = &sysctl_perf_event_paranoid,
1279 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001281 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001282 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001283 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001284 .procname = "perf_event_mlock_kb",
1285 .data = &sysctl_perf_event_mlock,
1286 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001287 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001288 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001289 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001290 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001291 .procname = "perf_event_max_sample_rate",
1292 .data = &sysctl_perf_event_sample_rate,
1293 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001294 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001295 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001296 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001297 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001298 {
1299 .procname = "perf_cpu_time_max_percent",
1300 .data = &sysctl_perf_cpu_time_max_percent,
1301 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1302 .mode = 0644,
1303 .proc_handler = perf_cpu_time_max_percent_handler,
1304 .extra1 = &zero,
1305 .extra2 = &one_hundred,
1306 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001307 {
1308 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001309 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001310 .maxlen = sizeof(sysctl_perf_event_max_stack),
1311 .mode = 0644,
1312 .proc_handler = perf_event_max_stack_handler,
1313 .extra1 = &zero,
1314 .extra2 = &six_hundred_forty_kb,
1315 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001316 {
1317 .procname = "perf_event_max_contexts_per_stack",
1318 .data = &sysctl_perf_event_max_contexts_per_stack,
1319 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1320 .mode = 0644,
1321 .proc_handler = perf_event_max_stack_handler,
1322 .extra1 = &zero,
1323 .extra2 = &one_thousand,
1324 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001325#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001326#ifdef CONFIG_KMEMCHECK
1327 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001328 .procname = "kmemcheck",
1329 .data = &kmemcheck_enabled,
1330 .maxlen = sizeof(int),
1331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001332 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001333 },
1334#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001335 {
1336 .procname = "panic_on_warn",
1337 .data = &panic_on_warn,
1338 .maxlen = sizeof(int),
1339 .mode = 0644,
1340 .proc_handler = proc_dointvec_minmax,
1341 .extra1 = &zero,
1342 .extra2 = &one,
1343 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001344#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1345 {
1346 .procname = "timer_migration",
1347 .data = &sysctl_timer_migration,
1348 .maxlen = sizeof(unsigned int),
1349 .mode = 0644,
1350 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001351 .extra1 = &zero,
1352 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001353 },
1354#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001355#ifdef CONFIG_BPF_SYSCALL
1356 {
1357 .procname = "unprivileged_bpf_disabled",
1358 .data = &sysctl_unprivileged_bpf_disabled,
1359 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1360 .mode = 0644,
1361 /* only handle a transition from default "0" to "1" */
1362 .proc_handler = proc_dointvec_minmax,
1363 .extra1 = &one,
1364 .extra2 = &one,
1365 },
1366#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001367#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1368 {
1369 .procname = "panic_on_rcu_stall",
1370 .data = &sysctl_panic_on_rcu_stall,
1371 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1372 .mode = 0644,
1373 .proc_handler = proc_dointvec_minmax,
1374 .extra1 = &zero,
1375 .extra2 = &one,
1376 },
1377#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001378#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001379 {
1380 .procname = "boot_reason",
1381 .data = &boot_reason,
1382 .maxlen = sizeof(int),
1383 .mode = 0444,
1384 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001385 },
1386
1387 {
1388 .procname = "cold_boot",
1389 .data = &cold_boot,
1390 .maxlen = sizeof(int),
1391 .mode = 0444,
1392 .proc_handler = proc_dointvec,
1393 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001394#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001395 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396};
1397
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001398static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400 .procname = "overcommit_memory",
1401 .data = &sysctl_overcommit_memory,
1402 .maxlen = sizeof(sysctl_overcommit_memory),
1403 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001404 .proc_handler = proc_dointvec_minmax,
1405 .extra1 = &zero,
1406 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 },
1408 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001409 .procname = "panic_on_oom",
1410 .data = &sysctl_panic_on_oom,
1411 .maxlen = sizeof(sysctl_panic_on_oom),
1412 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001413 .proc_handler = proc_dointvec_minmax,
1414 .extra1 = &zero,
1415 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001416 },
1417 {
David Rientjesfe071d72007-10-16 23:25:56 -07001418 .procname = "oom_kill_allocating_task",
1419 .data = &sysctl_oom_kill_allocating_task,
1420 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1421 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001422 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001423 },
1424 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001425 .procname = "oom_dump_tasks",
1426 .data = &sysctl_oom_dump_tasks,
1427 .maxlen = sizeof(sysctl_oom_dump_tasks),
1428 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001429 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001430 },
1431 {
Charan Teja Reddyf9920cf2018-05-01 20:20:20 +05301432 .procname = "reap_mem_on_sigkill",
1433 .data = &sysctl_reap_mem_on_sigkill,
1434 .maxlen = sizeof(sysctl_reap_mem_on_sigkill),
1435 .mode = 0644,
1436 .proc_handler = proc_dointvec,
1437 },
1438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 .procname = "overcommit_ratio",
1440 .data = &sysctl_overcommit_ratio,
1441 .maxlen = sizeof(sysctl_overcommit_ratio),
1442 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001443 .proc_handler = overcommit_ratio_handler,
1444 },
1445 {
1446 .procname = "overcommit_kbytes",
1447 .data = &sysctl_overcommit_kbytes,
1448 .maxlen = sizeof(sysctl_overcommit_kbytes),
1449 .mode = 0644,
1450 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 },
1452 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 .procname = "page-cluster",
1454 .data = &page_cluster,
1455 .maxlen = sizeof(int),
1456 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001457 .proc_handler = proc_dointvec_minmax,
1458 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 },
1460 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461 .procname = "dirty_background_ratio",
1462 .data = &dirty_background_ratio,
1463 .maxlen = sizeof(dirty_background_ratio),
1464 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001465 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 .extra1 = &zero,
1467 .extra2 = &one_hundred,
1468 },
1469 {
David Rientjes2da02992009-01-06 14:39:31 -08001470 .procname = "dirty_background_bytes",
1471 .data = &dirty_background_bytes,
1472 .maxlen = sizeof(dirty_background_bytes),
1473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001474 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001475 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001476 },
1477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .procname = "dirty_ratio",
1479 .data = &vm_dirty_ratio,
1480 .maxlen = sizeof(vm_dirty_ratio),
1481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001482 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 .extra1 = &zero,
1484 .extra2 = &one_hundred,
1485 },
1486 {
David Rientjes2da02992009-01-06 14:39:31 -08001487 .procname = "dirty_bytes",
1488 .data = &vm_dirty_bytes,
1489 .maxlen = sizeof(vm_dirty_bytes),
1490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001491 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001492 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001493 },
1494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001496 .data = &dirty_writeback_interval,
1497 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001499 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 },
1501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001503 .data = &dirty_expire_interval,
1504 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001506 .proc_handler = proc_dointvec_minmax,
1507 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 },
1509 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001510 .procname = "dirtytime_expire_seconds",
1511 .data = &dirtytime_expire_interval,
1512 .maxlen = sizeof(dirty_expire_interval),
1513 .mode = 0644,
1514 .proc_handler = dirtytime_interval_handler,
1515 .extra1 = &zero,
1516 },
1517 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001518 .procname = "nr_pdflush_threads",
1519 .mode = 0444 /* read-only */,
1520 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521 },
1522 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 .procname = "swappiness",
1524 .data = &vm_swappiness,
1525 .maxlen = sizeof(vm_swappiness),
1526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001527 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 .extra1 = &zero,
1529 .extra2 = &one_hundred,
1530 },
Vinayak Menonb9e4cc2b2018-06-11 18:58:39 +05301531 {
1532 .procname = "want_old_faultaround_pte",
1533 .data = &want_old_faultaround_pte,
1534 .maxlen = sizeof(want_old_faultaround_pte),
1535 .mode = 0644,
1536 .proc_handler = proc_dointvec_minmax,
1537 .extra1 = &zero,
1538 .extra2 = &one,
1539 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001541 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001543 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 .maxlen = sizeof(unsigned long),
1545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001546 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001547 },
1548#ifdef CONFIG_NUMA
1549 {
1550 .procname = "nr_hugepages_mempolicy",
1551 .data = NULL,
1552 .maxlen = sizeof(unsigned long),
1553 .mode = 0644,
1554 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001555 },
1556#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558 .procname = "hugetlb_shm_group",
1559 .data = &sysctl_hugetlb_shm_group,
1560 .maxlen = sizeof(gid_t),
1561 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001562 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 },
Mel Gorman396faf02007-07-17 04:03:13 -07001564 {
Mel Gorman396faf02007-07-17 04:03:13 -07001565 .procname = "hugepages_treat_as_movable",
1566 .data = &hugepages_treat_as_movable,
1567 .maxlen = sizeof(int),
1568 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001569 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001570 },
Adam Litke54f9f802007-10-16 01:26:20 -07001571 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001572 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001573 .data = NULL,
1574 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001576 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001577 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578#endif
1579 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001580 .procname = "lowmem_reserve_ratio",
1581 .data = &sysctl_lowmem_reserve_ratio,
1582 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1583 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001584 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585 },
1586 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001587 .procname = "drop_caches",
1588 .data = &sysctl_drop_caches,
1589 .maxlen = sizeof(int),
Johannes Weinerb231f9d2019-11-30 17:56:08 -08001590 .mode = 0200,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001591 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001592 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001593 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001594 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001595#ifdef CONFIG_COMPACTION
1596 {
1597 .procname = "compact_memory",
1598 .data = &sysctl_compact_memory,
1599 .maxlen = sizeof(int),
1600 .mode = 0200,
1601 .proc_handler = sysctl_compaction_handler,
1602 },
Mel Gorman5e771902010-05-24 14:32:31 -07001603 {
1604 .procname = "extfrag_threshold",
1605 .data = &sysctl_extfrag_threshold,
1606 .maxlen = sizeof(int),
1607 .mode = 0644,
1608 .proc_handler = sysctl_extfrag_handler,
1609 .extra1 = &min_extfrag_threshold,
1610 .extra2 = &max_extfrag_threshold,
1611 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001612 {
1613 .procname = "compact_unevictable_allowed",
1614 .data = &sysctl_compact_unevictable_allowed,
1615 .maxlen = sizeof(int),
1616 .mode = 0644,
1617 .proc_handler = proc_dointvec,
1618 .extra1 = &zero,
1619 .extra2 = &one,
1620 },
Mel Gorman5e771902010-05-24 14:32:31 -07001621
Mel Gorman76ab0f52010-05-24 14:32:28 -07001622#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001623 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624 .procname = "min_free_kbytes",
1625 .data = &min_free_kbytes,
1626 .maxlen = sizeof(min_free_kbytes),
1627 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001628 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001629 .extra1 = &zero,
1630 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001631 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001632 .procname = "watermark_scale_factor",
1633 .data = &watermark_scale_factor,
1634 .maxlen = sizeof(watermark_scale_factor),
1635 .mode = 0644,
1636 .proc_handler = watermark_scale_factor_sysctl_handler,
Rik van Riel12462752011-09-01 15:26:50 -04001637 .extra1 = &zero,
1638 .extra2 = &zero,
1639 },
1640 {
1641 .procname = "extra_free_kbytes",
1642 .data = &extra_free_kbytes,
1643 .maxlen = sizeof(extra_free_kbytes),
1644 .mode = 0644,
1645 .proc_handler = min_free_kbytes_sysctl_handler,
1646 .extra1 = &zero,
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001647 },
1648 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001649 .procname = "percpu_pagelist_fraction",
1650 .data = &percpu_pagelist_fraction,
1651 .maxlen = sizeof(percpu_pagelist_fraction),
1652 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001653 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001654 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001655 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001656#ifdef CONFIG_MMU
1657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 .procname = "max_map_count",
1659 .data = &sysctl_max_map_count,
1660 .maxlen = sizeof(sysctl_max_map_count),
1661 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001662 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001663 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001665#else
1666 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001667 .procname = "nr_trim_pages",
1668 .data = &sysctl_nr_trim_pages,
1669 .maxlen = sizeof(sysctl_nr_trim_pages),
1670 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001671 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001672 .extra1 = &zero,
1673 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674#endif
1675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676 .procname = "laptop_mode",
1677 .data = &laptop_mode,
1678 .maxlen = sizeof(laptop_mode),
1679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001680 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001681 },
1682 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 .procname = "block_dump",
1684 .data = &block_dump,
1685 .maxlen = sizeof(block_dump),
1686 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001687 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688 .extra1 = &zero,
1689 },
1690 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691 .procname = "vfs_cache_pressure",
1692 .data = &sysctl_vfs_cache_pressure,
1693 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1694 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001695 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 .extra1 = &zero,
1697 },
1698#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1699 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700 .procname = "legacy_va_layout",
1701 .data = &sysctl_legacy_va_layout,
1702 .maxlen = sizeof(sysctl_legacy_va_layout),
1703 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001704 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705 .extra1 = &zero,
1706 },
1707#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001708#ifdef CONFIG_NUMA
1709 {
Christoph Lameter17436602006-01-18 17:42:32 -08001710 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001711 .data = &node_reclaim_mode,
1712 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001714 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001715 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001716 },
Christoph Lameter96146342006-07-03 00:24:13 -07001717 {
Christoph Lameter96146342006-07-03 00:24:13 -07001718 .procname = "min_unmapped_ratio",
1719 .data = &sysctl_min_unmapped_ratio,
1720 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1721 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001722 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001723 .extra1 = &zero,
1724 .extra2 = &one_hundred,
1725 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001726 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001727 .procname = "min_slab_ratio",
1728 .data = &sysctl_min_slab_ratio,
1729 .maxlen = sizeof(sysctl_min_slab_ratio),
1730 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001731 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001732 .extra1 = &zero,
1733 .extra2 = &one_hundred,
1734 },
Christoph Lameter17436602006-01-18 17:42:32 -08001735#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001736#ifdef CONFIG_SMP
1737 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001738 .procname = "stat_interval",
1739 .data = &sysctl_stat_interval,
1740 .maxlen = sizeof(sysctl_stat_interval),
1741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001742 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001743 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001744 {
1745 .procname = "stat_refresh",
1746 .data = NULL,
1747 .maxlen = 0,
1748 .mode = 0600,
1749 .proc_handler = vmstat_refresh,
1750 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001751#endif
David Howells6e141542009-12-15 19:27:45 +00001752#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001753 {
Eric Parised032182007-06-28 15:55:21 -04001754 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001755 .data = &dac_mmap_min_addr,
1756 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001758 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001759 },
David Howells6e141542009-12-15 19:27:45 +00001760#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001761#ifdef CONFIG_NUMA
1762 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001763 .procname = "numa_zonelist_order",
1764 .data = &numa_zonelist_order,
1765 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1766 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001767 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001768 },
1769#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001770#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001771 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001772 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001773 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001774#ifdef CONFIG_X86_32
1775 .data = &vdso32_enabled,
1776 .maxlen = sizeof(vdso32_enabled),
1777#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001778 .data = &vdso_enabled,
1779 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001780#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001781 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001782 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001783 .extra1 = &zero,
1784 },
1785#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001786#ifdef CONFIG_HIGHMEM
1787 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001788 .procname = "highmem_is_dirtyable",
1789 .data = &vm_highmem_is_dirtyable,
1790 .maxlen = sizeof(vm_highmem_is_dirtyable),
1791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001792 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001793 .extra1 = &zero,
1794 .extra2 = &one,
1795 },
1796#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001797#ifdef CONFIG_MEMORY_FAILURE
1798 {
Andi Kleen6a460792009-09-16 11:50:15 +02001799 .procname = "memory_failure_early_kill",
1800 .data = &sysctl_memory_failure_early_kill,
1801 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1802 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001803 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001804 .extra1 = &zero,
1805 .extra2 = &one,
1806 },
1807 {
Andi Kleen6a460792009-09-16 11:50:15 +02001808 .procname = "memory_failure_recovery",
1809 .data = &sysctl_memory_failure_recovery,
1810 .maxlen = sizeof(sysctl_memory_failure_recovery),
1811 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001812 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001813 .extra1 = &zero,
1814 .extra2 = &one,
1815 },
1816#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001817 {
1818 .procname = "user_reserve_kbytes",
1819 .data = &sysctl_user_reserve_kbytes,
1820 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1821 .mode = 0644,
1822 .proc_handler = proc_doulongvec_minmax,
1823 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001824 {
1825 .procname = "admin_reserve_kbytes",
1826 .data = &sysctl_admin_reserve_kbytes,
1827 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1828 .mode = 0644,
1829 .proc_handler = proc_doulongvec_minmax,
1830 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001831#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1832 {
1833 .procname = "mmap_rnd_bits",
1834 .data = &mmap_rnd_bits,
1835 .maxlen = sizeof(mmap_rnd_bits),
1836 .mode = 0600,
1837 .proc_handler = proc_dointvec_minmax,
1838 .extra1 = (void *)&mmap_rnd_bits_min,
1839 .extra2 = (void *)&mmap_rnd_bits_max,
1840 },
1841#endif
1842#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1843 {
1844 .procname = "mmap_rnd_compat_bits",
1845 .data = &mmap_rnd_compat_bits,
1846 .maxlen = sizeof(mmap_rnd_compat_bits),
1847 .mode = 0600,
1848 .proc_handler = proc_dointvec_minmax,
1849 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1850 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1851 },
1852#endif
Vinayak Menonc1c6a992015-12-21 13:00:58 +05301853#ifdef CONFIG_SWAP
1854 {
1855 .procname = "swap_ratio",
1856 .data = &sysctl_swap_ratio,
1857 .maxlen = sizeof(sysctl_swap_ratio),
1858 .mode = 0644,
1859 .proc_handler = proc_dointvec_minmax,
1860 },
1861 {
1862 .procname = "swap_ratio_enable",
1863 .data = &sysctl_swap_ratio_enable,
1864 .maxlen = sizeof(sysctl_swap_ratio_enable),
1865 .mode = 0644,
1866 .proc_handler = proc_dointvec_minmax,
1867 },
1868#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001869 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870};
1871
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001872static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874 .procname = "inode-nr",
1875 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001876 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001878 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879 },
1880 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 .procname = "inode-state",
1882 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001883 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001884 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001885 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886 },
1887 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 .procname = "file-nr",
1889 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001890 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001892 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893 },
1894 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 .procname = "file-max",
1896 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001897 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001898 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001899 .proc_handler = proc_doulongvec_minmax,
Will Deacon3141fcc2019-04-05 18:39:38 -07001900 .extra1 = &zero_ul,
Christian Brauner6b65c262019-03-07 16:29:43 -08001901 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 },
1903 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001904 .procname = "nr_open",
1905 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001906 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001907 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001908 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001909 .extra1 = &sysctl_nr_open_min,
1910 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001911 },
1912 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913 .procname = "dentry-state",
1914 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001915 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001917 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918 },
1919 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 .procname = "overflowuid",
1921 .data = &fs_overflowuid,
1922 .maxlen = sizeof(int),
1923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001924 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925 .extra1 = &minolduid,
1926 .extra2 = &maxolduid,
1927 },
1928 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929 .procname = "overflowgid",
1930 .data = &fs_overflowgid,
1931 .maxlen = sizeof(int),
1932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001933 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934 .extra1 = &minolduid,
1935 .extra2 = &maxolduid,
1936 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001937#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939 .procname = "leases-enable",
1940 .data = &leases_enable,
1941 .maxlen = sizeof(int),
1942 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001943 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001945#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001946#ifdef CONFIG_DNOTIFY
1947 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001948 .procname = "dir-notify-enable",
1949 .data = &dir_notify_enable,
1950 .maxlen = sizeof(int),
1951 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001952 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001953 },
1954#endif
1955#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001956#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958 .procname = "lease-break-time",
1959 .data = &lease_break_time,
1960 .maxlen = sizeof(int),
1961 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001962 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001964#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001965#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001967 .procname = "aio-nr",
1968 .data = &aio_nr,
1969 .maxlen = sizeof(aio_nr),
1970 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001971 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972 },
1973 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001974 .procname = "aio-max-nr",
1975 .data = &aio_max_nr,
1976 .maxlen = sizeof(aio_max_nr),
1977 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001978 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001979 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001980#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001981#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001982 {
Robert Love0399cb02005-07-13 12:38:18 -04001983 .procname = "inotify",
1984 .mode = 0555,
1985 .child = inotify_table,
1986 },
1987#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001988#ifdef CONFIG_EPOLL
1989 {
1990 .procname = "epoll",
1991 .mode = 0555,
1992 .child = epoll_table,
1993 },
1994#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001995#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001996 {
Kees Cook800179c2012-07-25 17:29:07 -07001997 .procname = "protected_symlinks",
1998 .data = &sysctl_protected_symlinks,
1999 .maxlen = sizeof(int),
2000 .mode = 0600,
2001 .proc_handler = proc_dointvec_minmax,
2002 .extra1 = &zero,
2003 .extra2 = &one,
2004 },
2005 {
2006 .procname = "protected_hardlinks",
2007 .data = &sysctl_protected_hardlinks,
2008 .maxlen = sizeof(int),
2009 .mode = 0600,
2010 .proc_handler = proc_dointvec_minmax,
2011 .extra1 = &zero,
2012 .extra2 = &one,
2013 },
2014 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07002015 .procname = "protected_fifos",
2016 .data = &sysctl_protected_fifos,
2017 .maxlen = sizeof(int),
2018 .mode = 0600,
2019 .proc_handler = proc_dointvec_minmax,
2020 .extra1 = &zero,
2021 .extra2 = &two,
2022 },
2023 {
2024 .procname = "protected_regular",
2025 .data = &sysctl_protected_regular,
2026 .maxlen = sizeof(int),
2027 .mode = 0600,
2028 .proc_handler = proc_dointvec_minmax,
2029 .extra1 = &zero,
2030 .extra2 = &two,
2031 },
2032 {
Alan Coxd6e71142005-06-23 00:09:43 -07002033 .procname = "suid_dumpable",
2034 .data = &suid_dumpable,
2035 .maxlen = sizeof(int),
2036 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07002037 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07002038 .extra1 = &zero,
2039 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07002040 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002041#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
2042 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002043 .procname = "binfmt_misc",
2044 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05002045 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002046 },
2047#endif
Jens Axboeb492e952010-05-19 21:03:16 +02002048 {
Jens Axboeff9da692010-06-03 14:54:39 +02002049 .procname = "pipe-max-size",
2050 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002051 .maxlen = sizeof(int),
2052 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02002053 .proc_handler = &pipe_proc_fn,
2054 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002055 },
Willy Tarreau759c0112016-01-18 16:36:09 +01002056 {
2057 .procname = "pipe-user-pages-hard",
2058 .data = &pipe_user_pages_hard,
2059 .maxlen = sizeof(pipe_user_pages_hard),
2060 .mode = 0644,
2061 .proc_handler = proc_doulongvec_minmax,
2062 },
2063 {
2064 .procname = "pipe-user-pages-soft",
2065 .data = &pipe_user_pages_soft,
2066 .maxlen = sizeof(pipe_user_pages_soft),
2067 .mode = 0644,
2068 .proc_handler = proc_doulongvec_minmax,
2069 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05002070 {
2071 .procname = "mount-max",
2072 .data = &sysctl_mount_max,
2073 .maxlen = sizeof(unsigned int),
2074 .mode = 0644,
2075 .proc_handler = proc_dointvec_minmax,
2076 .extra1 = &one,
2077 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002078 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079};
2080
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002081static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07002082#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002083 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002084 .procname = "exception-trace",
2085 .data = &show_unhandled_signals,
2086 .maxlen = sizeof(int),
2087 .mode = 0644,
2088 .proc_handler = proc_dointvec
2089 },
2090#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002091#if defined(CONFIG_OPTPROBES)
2092 {
2093 .procname = "kprobes-optimization",
2094 .data = &sysctl_kprobes_optimization,
2095 .maxlen = sizeof(int),
2096 .mode = 0644,
2097 .proc_handler = proc_kprobes_optimization_handler,
2098 .extra1 = &zero,
2099 .extra2 = &one,
2100 },
2101#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002102 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103};
2104
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002105static struct ctl_table dev_table[] = {
tracychui312da522020-06-12 17:46:51 +08002106 {
2107 .procname = "ddr",
2108 .mode = 0555,
2109 .child = ddr_table,
2110 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002111 { }
Robert Love0eeca282005-07-12 17:06:03 -04002112};
tracychui312da522020-06-12 17:46:51 +08002113/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
2114static struct ctl_table qpnp_power_on_table[] = {
2115 {
2116 .procname = "pon_reason",
2117 .data = &qpnp_pon_reason_extern,
2118 .maxlen = sizeof(int),
2119 .mode = 0444,
2120 .proc_handler = proc_dointvec,
2121 },
2122 {
2123 .procname = "poff_reason",
2124 .data = &qpnp_poff_reason_extern,
2125 .maxlen = sizeof(int),
2126 .mode = 0444,
2127 .proc_handler = proc_dointvec,
2128 },
2129 { }
2130};
2131static struct ctl_table ddr_table[] = {
2132 {
2133 .procname = "vendor",
2134 .data = &ddr_vendor,
2135 .maxlen = 32,
2136 .mode = 0444,
2137 .proc_handler = proc_dostring,
2138 },
2139 { }
2140};
2141/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002143int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002144{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002145 struct ctl_table_header *hdr;
2146
2147 hdr = register_sysctl_table(sysctl_base_table);
2148 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002149 return 0;
2150}
2151
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002152#endif /* CONFIG_SYSCTL */
2153
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154/*
2155 * /proc/sys support
2156 */
2157
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002158#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159
Kees Cookf8808302014-06-06 14:37:17 -07002160static int _proc_do_string(char *data, int maxlen, int write,
2161 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002162 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002163{
2164 size_t len;
2165 char __user *p;
2166 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002167
2168 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002169 *lenp = 0;
2170 return 0;
2171 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002172
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002173 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002174 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2175 /* Only continue writes not past the end of buffer. */
2176 len = strlen(data);
2177 if (len > maxlen - 1)
2178 len = maxlen - 1;
2179
2180 if (*ppos > len)
2181 return 0;
2182 len = *ppos;
2183 } else {
2184 /* Start writing from beginning of buffer. */
2185 len = 0;
2186 }
2187
Kees Cook2ca9bb42014-06-06 14:37:18 -07002188 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002189 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002190 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002191 if (get_user(c, p++))
2192 return -EFAULT;
2193 if (c == 0 || c == '\n')
2194 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002195 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002196 }
Kees Cookf8808302014-06-06 14:37:17 -07002197 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002198 } else {
2199 len = strlen(data);
2200 if (len > maxlen)
2201 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002202
2203 if (*ppos > len) {
2204 *lenp = 0;
2205 return 0;
2206 }
2207
2208 data += *ppos;
2209 len -= *ppos;
2210
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002211 if (len > *lenp)
2212 len = *lenp;
2213 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002214 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002215 return -EFAULT;
2216 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002217 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002218 return -EFAULT;
2219 len++;
2220 }
2221 *lenp = len;
2222 *ppos += len;
2223 }
2224 return 0;
2225}
2226
Kees Cookf4aacea2014-06-06 14:37:19 -07002227static void warn_sysctl_write(struct ctl_table *table)
2228{
2229 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2230 "This will not be supported in the future. To silence this\n"
2231 "warning, set kernel.sysctl_writes_strict = -1\n",
2232 current->comm, table->procname);
2233}
2234
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235/**
2236 * proc_dostring - read a string sysctl
2237 * @table: the sysctl table
2238 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 * @buffer: the user buffer
2240 * @lenp: the size of the user buffer
2241 * @ppos: file position
2242 *
2243 * Reads/writes a string from/to the user buffer. If the kernel
2244 * buffer provided is not large enough to hold the string, the
2245 * string is truncated. The copied string is %NULL-terminated.
2246 * If the string is being read by the user process, it is copied
2247 * and a newline '\n' is added. It is truncated if the buffer is
2248 * not large enough.
2249 *
2250 * Returns 0 on success.
2251 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002252int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 void __user *buffer, size_t *lenp, loff_t *ppos)
2254{
Kees Cookf4aacea2014-06-06 14:37:19 -07002255 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2256 warn_sysctl_write(table);
2257
Kees Cookf8808302014-06-06 14:37:17 -07002258 return _proc_do_string((char *)(table->data), table->maxlen, write,
2259 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260}
2261
Amerigo Wang00b7c332010-05-05 00:26:45 +00002262static size_t proc_skip_spaces(char **buf)
2263{
2264 size_t ret;
2265 char *tmp = skip_spaces(*buf);
2266 ret = tmp - *buf;
2267 *buf = tmp;
2268 return ret;
2269}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002271static void proc_skip_char(char **buf, size_t *size, const char v)
2272{
2273 while (*size) {
2274 if (**buf != v)
2275 break;
2276 (*size)--;
2277 (*buf)++;
2278 }
2279}
2280
Amerigo Wang00b7c332010-05-05 00:26:45 +00002281#define TMPBUFLEN 22
2282/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002283 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002284 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002285 * @buf: a kernel buffer
2286 * @size: size of the kernel buffer
2287 * @val: this is where the number will be stored
2288 * @neg: set to %TRUE if number is negative
2289 * @perm_tr: a vector which contains the allowed trailers
2290 * @perm_tr_len: size of the perm_tr vector
2291 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002292 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002293 * In case of success %0 is returned and @buf and @size are updated with
2294 * the amount of bytes read. If @tr is non-NULL and a trailing
2295 * character exists (size is non-zero after returning from this
2296 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002297 */
2298static int proc_get_long(char **buf, size_t *size,
2299 unsigned long *val, bool *neg,
2300 const char *perm_tr, unsigned perm_tr_len, char *tr)
2301{
2302 int len;
2303 char *p, tmp[TMPBUFLEN];
2304
2305 if (!*size)
2306 return -EINVAL;
2307
2308 len = *size;
2309 if (len > TMPBUFLEN - 1)
2310 len = TMPBUFLEN - 1;
2311
2312 memcpy(tmp, *buf, len);
2313
2314 tmp[len] = 0;
2315 p = tmp;
2316 if (*p == '-' && *size > 1) {
2317 *neg = true;
2318 p++;
2319 } else
2320 *neg = false;
2321 if (!isdigit(*p))
2322 return -EINVAL;
2323
2324 *val = simple_strtoul(p, &p, 0);
2325
2326 len = p - tmp;
2327
2328 /* We don't know if the next char is whitespace thus we may accept
2329 * invalid integers (e.g. 1234...a) or two integers instead of one
2330 * (e.g. 123...1). So lets not allow such large numbers. */
2331 if (len == TMPBUFLEN - 1)
2332 return -EINVAL;
2333
2334 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2335 return -EINVAL;
2336
2337 if (tr && (len < *size))
2338 *tr = *p;
2339
2340 *buf += len;
2341 *size -= len;
2342
2343 return 0;
2344}
2345
2346/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002347 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002348 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002349 * @buf: the user buffer
2350 * @size: the size of the user buffer
2351 * @val: the integer to be converted
2352 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002353 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002354 * In case of success %0 is returned and @buf and @size are updated with
2355 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002356 */
2357static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2358 bool neg)
2359{
2360 int len;
2361 char tmp[TMPBUFLEN], *p = tmp;
2362
2363 sprintf(p, "%s%lu", neg ? "-" : "", val);
2364 len = strlen(tmp);
2365 if (len > *size)
2366 len = *size;
2367 if (copy_to_user(*buf, tmp, len))
2368 return -EFAULT;
2369 *size -= len;
2370 *buf += len;
2371 return 0;
2372}
2373#undef TMPBUFLEN
2374
2375static int proc_put_char(void __user **buf, size_t *size, char c)
2376{
2377 if (*size) {
2378 char __user **buffer = (char __user **)buf;
2379 if (put_user(c, *buffer))
2380 return -EFAULT;
2381 (*size)--, (*buffer)++;
2382 *buf = *buffer;
2383 }
2384 return 0;
2385}
2386
2387static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 int *valp,
2389 int write, void *data)
2390{
2391 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002392 if (*negp) {
2393 if (*lvalp > (unsigned long) INT_MAX + 1)
2394 return -EINVAL;
2395 *valp = -*lvalp;
2396 } else {
2397 if (*lvalp > (unsigned long) INT_MAX)
2398 return -EINVAL;
2399 *valp = *lvalp;
2400 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 } else {
2402 int val = *valp;
2403 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002404 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002405 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002407 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 *lvalp = (unsigned long)val;
2409 }
2410 }
2411 return 0;
2412}
2413
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002414static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2415 int *valp,
2416 int write, void *data)
2417{
2418 if (write) {
2419 if (*negp)
2420 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002421 if (*lvalp > UINT_MAX)
2422 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002423 *valp = *lvalp;
2424 } else {
2425 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002426 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002427 *lvalp = (unsigned long)val;
2428 }
2429 return 0;
2430}
2431
Amerigo Wang00b7c332010-05-05 00:26:45 +00002432static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2433
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002434static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002435 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002436 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002437 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438 int write, void *data),
2439 void *data)
2440{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002441 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002442 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002443 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444
Amerigo Wang00b7c332010-05-05 00:26:45 +00002445 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002446 *lenp = 0;
2447 return 0;
2448 }
2449
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002450 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002451 vleft = table->maxlen / sizeof(*i);
2452 left = *lenp;
2453
2454 if (!conv)
2455 conv = do_proc_dointvec_conv;
2456
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002458 if (*ppos) {
2459 switch (sysctl_writes_strict) {
2460 case SYSCTL_WRITES_STRICT:
2461 goto out;
2462 case SYSCTL_WRITES_WARN:
2463 warn_sysctl_write(table);
2464 break;
2465 default:
2466 break;
2467 }
2468 }
2469
Amerigo Wang00b7c332010-05-05 00:26:45 +00002470 if (left > PAGE_SIZE - 1)
2471 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002472 p = kbuf = memdup_user_nul(buffer, left);
2473 if (IS_ERR(kbuf))
2474 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002475 }
2476
2477 for (; left && vleft--; i++, first=0) {
2478 unsigned long lval;
2479 bool neg;
2480
2481 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002482 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002483
J. R. Okajima563b0462010-05-25 16:10:14 -07002484 if (!left)
2485 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002486 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002487 proc_wspace_sep,
2488 sizeof(proc_wspace_sep), NULL);
2489 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002491 if (conv(&neg, &lval, i, 1, data)) {
2492 err = -EINVAL;
2493 break;
2494 }
2495 } else {
2496 if (conv(&neg, &lval, i, 0, data)) {
2497 err = -EINVAL;
2498 break;
2499 }
2500 if (!first)
2501 err = proc_put_char(&buffer, &left, '\t');
2502 if (err)
2503 break;
2504 err = proc_put_long(&buffer, &left, lval, neg);
2505 if (err)
2506 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507 }
2508 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002509
2510 if (!write && !first && left && !err)
2511 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002512 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002513 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002514 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002515 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002516 if (first)
2517 return err ? : -EINVAL;
2518 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002520out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002522 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523}
2524
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002525static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002526 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002527 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002528 int write, void *data),
2529 void *data)
2530{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002531 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002532 buffer, lenp, ppos, conv, data);
2533}
2534
Linus Torvalds1da177e2005-04-16 15:20:36 -07002535/**
2536 * proc_dointvec - read a vector of integers
2537 * @table: the sysctl table
2538 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 * @buffer: the user buffer
2540 * @lenp: the size of the user buffer
2541 * @ppos: file position
2542 *
2543 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2544 * values from/to the user buffer, treated as an ASCII string.
2545 *
2546 * Returns 0 on success.
2547 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002548int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549 void __user *buffer, size_t *lenp, loff_t *ppos)
2550{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002551 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2552}
2553
2554/**
2555 * proc_douintvec - read a vector of unsigned integers
2556 * @table: the sysctl table
2557 * @write: %TRUE if this is a write to the sysctl file
2558 * @buffer: the user buffer
2559 * @lenp: the size of the user buffer
2560 * @ppos: file position
2561 *
2562 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2563 * values from/to the user buffer, treated as an ASCII string.
2564 *
2565 * Returns 0 on success.
2566 */
2567int proc_douintvec(struct ctl_table *table, int write,
2568 void __user *buffer, size_t *lenp, loff_t *ppos)
2569{
2570 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2571 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572}
2573
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002574/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002575 * Taint values can only be increased
2576 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002577 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002578static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002579 void __user *buffer, size_t *lenp, loff_t *ppos)
2580{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002581 struct ctl_table t;
2582 unsigned long tmptaint = get_taint();
2583 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002584
Bastian Blank91fcd412007-04-23 14:41:14 -07002585 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002586 return -EPERM;
2587
Andi Kleen25ddbb12008-10-15 22:01:41 -07002588 t = *table;
2589 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002590 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002591 if (err < 0)
2592 return err;
2593
2594 if (write) {
2595 /*
2596 * Poor man's atomic or. Not worth adding a primitive
2597 * to everyone's atomic.h for this
2598 */
2599 int i;
2600 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2601 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302602 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002603 }
2604 }
2605
2606 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002607}
2608
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002609#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002610static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002611 void __user *buffer, size_t *lenp, loff_t *ppos)
2612{
2613 if (write && !capable(CAP_SYS_ADMIN))
2614 return -EPERM;
2615
2616 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2617}
2618#endif
2619
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620struct do_proc_dointvec_minmax_conv_param {
2621 int *min;
2622 int *max;
2623};
2624
Amerigo Wang00b7c332010-05-05 00:26:45 +00002625static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2626 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627 int write, void *data)
2628{
2629 struct do_proc_dointvec_minmax_conv_param *param = data;
2630 if (write) {
Zev Weiss45a67f12019-03-11 23:28:02 -07002631 int val;
2632 if (*negp) {
2633 if (*lvalp > (unsigned long) INT_MAX + 1)
2634 return -EINVAL;
2635 val = -*lvalp;
2636 } else {
2637 if (*lvalp > (unsigned long) INT_MAX)
2638 return -EINVAL;
2639 val = *lvalp;
2640 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641 if ((param->min && *param->min > val) ||
2642 (param->max && *param->max < val))
2643 return -EINVAL;
2644 *valp = val;
2645 } else {
2646 int val = *valp;
2647 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002648 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002649 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002651 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 *lvalp = (unsigned long)val;
2653 }
2654 }
2655 return 0;
2656}
2657
2658/**
2659 * proc_dointvec_minmax - read a vector of integers with min/max values
2660 * @table: the sysctl table
2661 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 * @buffer: the user buffer
2663 * @lenp: the size of the user buffer
2664 * @ppos: file position
2665 *
2666 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2667 * values from/to the user buffer, treated as an ASCII string.
2668 *
2669 * This routine will ensure the values are within the range specified by
2670 * table->extra1 (min) and table->extra2 (max).
2671 *
2672 * Returns 0 on success.
2673 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002674int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 void __user *buffer, size_t *lenp, loff_t *ppos)
2676{
2677 struct do_proc_dointvec_minmax_conv_param param = {
2678 .min = (int *) table->extra1,
2679 .max = (int *) table->extra2,
2680 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002681 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002682 do_proc_dointvec_minmax_conv, &param);
2683}
2684
Kees Cook54b50192012-07-30 14:39:18 -07002685static void validate_coredump_safety(void)
2686{
Alex Kelly046d6622012-10-04 17:15:23 -07002687#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002688 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002689 core_pattern[0] != '/' && core_pattern[0] != '|') {
2690 printk(KERN_WARNING "Unsafe core_pattern used with "\
2691 "suid_dumpable=2. Pipe handler or fully qualified "\
2692 "core dump path required.\n");
2693 }
Alex Kelly046d6622012-10-04 17:15:23 -07002694#endif
Kees Cook54b50192012-07-30 14:39:18 -07002695}
2696
2697static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2698 void __user *buffer, size_t *lenp, loff_t *ppos)
2699{
2700 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2701 if (!error)
2702 validate_coredump_safety();
2703 return error;
2704}
2705
Alex Kelly046d6622012-10-04 17:15:23 -07002706#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002707static int proc_dostring_coredump(struct ctl_table *table, int write,
2708 void __user *buffer, size_t *lenp, loff_t *ppos)
2709{
2710 int error = proc_dostring(table, write, buffer, lenp, ppos);
2711 if (!error)
2712 validate_coredump_safety();
2713 return error;
2714}
Alex Kelly046d6622012-10-04 17:15:23 -07002715#endif
Kees Cook54b50192012-07-30 14:39:18 -07002716
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002717static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 void __user *buffer,
2719 size_t *lenp, loff_t *ppos,
2720 unsigned long convmul,
2721 unsigned long convdiv)
2722{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002723 unsigned long *i, *min, *max;
2724 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002725 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002726 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002727
2728 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002729 *lenp = 0;
2730 return 0;
2731 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002732
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002733 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002734 min = (unsigned long *) table->extra1;
2735 max = (unsigned long *) table->extra2;
2736 vleft = table->maxlen / sizeof(unsigned long);
2737 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002738
2739 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002740 if (*ppos) {
2741 switch (sysctl_writes_strict) {
2742 case SYSCTL_WRITES_STRICT:
2743 goto out;
2744 case SYSCTL_WRITES_WARN:
2745 warn_sysctl_write(table);
2746 break;
2747 default:
2748 break;
2749 }
2750 }
2751
Amerigo Wang00b7c332010-05-05 00:26:45 +00002752 if (left > PAGE_SIZE - 1)
2753 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002754 p = kbuf = memdup_user_nul(buffer, left);
2755 if (IS_ERR(kbuf))
2756 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002757 }
2758
Eric Dumazet27b3d802010-10-07 12:59:29 -07002759 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002760 unsigned long val;
2761
Linus Torvalds1da177e2005-04-16 15:20:36 -07002762 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002763 bool neg;
2764
Al Viro70f6cbb2015-12-24 00:13:10 -05002765 left -= proc_skip_spaces(&p);
Cheng Lin0e5c7502019-01-03 15:26:13 -08002766 if (!left)
2767 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002768
Al Viro70f6cbb2015-12-24 00:13:10 -05002769 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002770 proc_wspace_sep,
2771 sizeof(proc_wspace_sep), NULL);
2772 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773 break;
2774 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002775 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002776 val = convmul * val / convdiv;
Christian Brauner726f69d2019-05-14 15:44:55 -07002777 if ((min && val < *min) || (max && val > *max)) {
2778 err = -EINVAL;
2779 break;
2780 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002781 *i = val;
2782 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002783 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002784 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002785 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002786 if (err)
2787 break;
2788 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002789 err = proc_put_long(&buffer, &left, val, false);
2790 if (err)
2791 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002792 }
2793 }
2794
Amerigo Wang00b7c332010-05-05 00:26:45 +00002795 if (!write && !first && left && !err)
2796 err = proc_put_char(&buffer, &left, '\n');
2797 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002798 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002799 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002800 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002801 if (first)
2802 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002803 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002804 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002805out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002806 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002807 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002808}
2809
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002810static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002811 void __user *buffer,
2812 size_t *lenp, loff_t *ppos,
2813 unsigned long convmul,
2814 unsigned long convdiv)
2815{
2816 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002817 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002818}
2819
Linus Torvalds1da177e2005-04-16 15:20:36 -07002820/**
2821 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2822 * @table: the sysctl table
2823 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002824 * @buffer: the user buffer
2825 * @lenp: the size of the user buffer
2826 * @ppos: file position
2827 *
2828 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2829 * values from/to the user buffer, treated as an ASCII string.
2830 *
2831 * This routine will ensure the values are within the range specified by
2832 * table->extra1 (min) and table->extra2 (max).
2833 *
2834 * Returns 0 on success.
2835 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002836int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002837 void __user *buffer, size_t *lenp, loff_t *ppos)
2838{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002839 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840}
2841
2842/**
2843 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2844 * @table: the sysctl table
2845 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002846 * @buffer: the user buffer
2847 * @lenp: the size of the user buffer
2848 * @ppos: file position
2849 *
2850 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2851 * values from/to the user buffer, treated as an ASCII string. The values
2852 * are treated as milliseconds, and converted to jiffies when they are stored.
2853 *
2854 * This routine will ensure the values are within the range specified by
2855 * table->extra1 (min) and table->extra2 (max).
2856 *
2857 * Returns 0 on success.
2858 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002859int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002860 void __user *buffer,
2861 size_t *lenp, loff_t *ppos)
2862{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002863 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864 lenp, ppos, HZ, 1000l);
2865}
2866
2867
Amerigo Wang00b7c332010-05-05 00:26:45 +00002868static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002869 int *valp,
2870 int write, void *data)
2871{
2872 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002873 if (*lvalp > LONG_MAX / HZ)
2874 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002875 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2876 } else {
2877 int val = *valp;
2878 unsigned long lval;
2879 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002880 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002881 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002882 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002883 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884 lval = (unsigned long)val;
2885 }
2886 *lvalp = lval / HZ;
2887 }
2888 return 0;
2889}
2890
Amerigo Wang00b7c332010-05-05 00:26:45 +00002891static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002892 int *valp,
2893 int write, void *data)
2894{
2895 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002896 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2897 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002898 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2899 } else {
2900 int val = *valp;
2901 unsigned long lval;
2902 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002903 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002904 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002905 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002906 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907 lval = (unsigned long)val;
2908 }
2909 *lvalp = jiffies_to_clock_t(lval);
2910 }
2911 return 0;
2912}
2913
Amerigo Wang00b7c332010-05-05 00:26:45 +00002914static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002915 int *valp,
2916 int write, void *data)
2917{
2918 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002919 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2920
2921 if (jif > INT_MAX)
2922 return 1;
2923 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002924 } else {
2925 int val = *valp;
2926 unsigned long lval;
2927 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002928 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002929 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002931 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932 lval = (unsigned long)val;
2933 }
2934 *lvalp = jiffies_to_msecs(lval);
2935 }
2936 return 0;
2937}
2938
2939/**
2940 * proc_dointvec_jiffies - read a vector of integers as seconds
2941 * @table: the sysctl table
2942 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 * @buffer: the user buffer
2944 * @lenp: the size of the user buffer
2945 * @ppos: file position
2946 *
2947 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2948 * values from/to the user buffer, treated as an ASCII string.
2949 * The values read are assumed to be in seconds, and are converted into
2950 * jiffies.
2951 *
2952 * Returns 0 on success.
2953 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002954int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955 void __user *buffer, size_t *lenp, loff_t *ppos)
2956{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002957 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958 do_proc_dointvec_jiffies_conv,NULL);
2959}
2960
2961/**
2962 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2963 * @table: the sysctl table
2964 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002965 * @buffer: the user buffer
2966 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002967 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002968 *
2969 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2970 * values from/to the user buffer, treated as an ASCII string.
2971 * The values read are assumed to be in 1/USER_HZ seconds, and
2972 * are converted into jiffies.
2973 *
2974 * Returns 0 on success.
2975 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002976int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002977 void __user *buffer, size_t *lenp, loff_t *ppos)
2978{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002979 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980 do_proc_dointvec_userhz_jiffies_conv,NULL);
2981}
2982
2983/**
2984 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2985 * @table: the sysctl table
2986 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002987 * @buffer: the user buffer
2988 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002989 * @ppos: file position
2990 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002991 *
2992 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2993 * values from/to the user buffer, treated as an ASCII string.
2994 * The values read are assumed to be in 1/1000 seconds, and
2995 * are converted into jiffies.
2996 *
2997 * Returns 0 on success.
2998 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002999int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003000 void __user *buffer, size_t *lenp, loff_t *ppos)
3001{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003002 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003 do_proc_dointvec_ms_jiffies_conv, NULL);
3004}
3005
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003006static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003007 void __user *buffer, size_t *lenp, loff_t *ppos)
3008{
3009 struct pid *new_pid;
3010 pid_t tmp;
3011 int r;
3012
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08003013 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003014
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003015 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003016 lenp, ppos, NULL, NULL);
3017 if (r || !write)
3018 return r;
3019
3020 new_pid = find_get_pid(tmp);
3021 if (!new_pid)
3022 return -ESRCH;
3023
3024 put_pid(xchg(&cad_pid, new_pid));
3025 return 0;
3026}
3027
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003028/**
3029 * proc_do_large_bitmap - read/write from/to a large bitmap
3030 * @table: the sysctl table
3031 * @write: %TRUE if this is a write to the sysctl file
3032 * @buffer: the user buffer
3033 * @lenp: the size of the user buffer
3034 * @ppos: file position
3035 *
3036 * The bitmap is stored at table->data and the bitmap length (in bits)
3037 * in table->maxlen.
3038 *
3039 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3040 * large bitmaps may be represented in a compact manner. Writing into
3041 * the file will clear the bitmap then update it with the given input.
3042 *
3043 * Returns 0 on success.
3044 */
3045int proc_do_large_bitmap(struct ctl_table *table, int write,
3046 void __user *buffer, size_t *lenp, loff_t *ppos)
3047{
3048 int err = 0;
3049 bool first = 1;
3050 size_t left = *lenp;
3051 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07003052 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003053 unsigned long *tmp_bitmap = NULL;
3054 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3055
WANG Cong122ff242014-05-12 16:04:53 -07003056 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003057 *lenp = 0;
3058 return 0;
3059 }
3060
3061 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003062 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003063
3064 if (left > PAGE_SIZE - 1)
3065 left = PAGE_SIZE - 1;
3066
Al Viro70f6cbb2015-12-24 00:13:10 -05003067 p = kbuf = memdup_user_nul(buffer, left);
3068 if (IS_ERR(kbuf))
3069 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003070
3071 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
3072 GFP_KERNEL);
3073 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003074 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003075 return -ENOMEM;
3076 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003077 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003078 while (!err && left) {
3079 unsigned long val_a, val_b;
3080 bool neg;
3081
Al Viro70f6cbb2015-12-24 00:13:10 -05003082 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003083 sizeof(tr_a), &c);
3084 if (err)
3085 break;
3086 if (val_a >= bitmap_len || neg) {
3087 err = -EINVAL;
3088 break;
3089 }
3090
3091 val_b = val_a;
3092 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003093 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003094 left--;
3095 }
3096
3097 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05003098 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003099 &neg, tr_b, sizeof(tr_b),
3100 &c);
3101 if (err)
3102 break;
3103 if (val_b >= bitmap_len || neg ||
3104 val_a > val_b) {
3105 err = -EINVAL;
3106 break;
3107 }
3108 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003109 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003110 left--;
3111 }
3112 }
3113
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003114 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003115 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003116 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003117 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003118 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003119 } else {
3120 unsigned long bit_a, bit_b = 0;
3121
3122 while (left) {
3123 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3124 if (bit_a >= bitmap_len)
3125 break;
3126 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3127 bit_a + 1) - 1;
3128
3129 if (!first) {
3130 err = proc_put_char(&buffer, &left, ',');
3131 if (err)
3132 break;
3133 }
3134 err = proc_put_long(&buffer, &left, bit_a, false);
3135 if (err)
3136 break;
3137 if (bit_a != bit_b) {
3138 err = proc_put_char(&buffer, &left, '-');
3139 if (err)
3140 break;
3141 err = proc_put_long(&buffer, &left, bit_b, false);
3142 if (err)
3143 break;
3144 }
3145
3146 first = 0; bit_b++;
3147 }
3148 if (!err)
3149 err = proc_put_char(&buffer, &left, '\n');
3150 }
3151
3152 if (!err) {
3153 if (write) {
3154 if (*ppos)
3155 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3156 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003157 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003158 }
3159 kfree(tmp_bitmap);
3160 *lenp -= left;
3161 *ppos += *lenp;
3162 return 0;
3163 } else {
3164 kfree(tmp_bitmap);
3165 return err;
3166 }
3167}
3168
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003169static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp,
3170 int *valp, int write, void *data)
3171{
3172 if (write) {
Satya Durga Srinivasu Prabhala3929bf02018-08-24 12:23:08 -07003173 if (*negp || *lvalp == 0)
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003174 return -EINVAL;
3175 *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp;
3176 } else {
3177 *negp = false;
3178 *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp;
3179 }
3180
3181 return 0;
3182}
3183
3184/**
3185 * proc_douintvec_capacity - read a vector of integers in percentage and convert
3186 * into sched capacity
3187 * @table: the sysctl table
3188 * @write: %TRUE if this is a write to the sysctl file
3189 * @buffer: the user buffer
3190 * @lenp: the size of the user buffer
3191 * @ppos: file position
3192 *
3193 * Returns 0 on success.
3194 */
3195int proc_douintvec_capacity(struct ctl_table *table, int write,
3196 void __user *buffer, size_t *lenp, loff_t *ppos)
3197{
3198 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3199 do_proc_douintvec_capacity_conv, NULL);
3200}
3201
Jovi Zhang55610502011-01-12 17:00:45 -08003202#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003203
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003204int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205 void __user *buffer, size_t *lenp, loff_t *ppos)
3206{
3207 return -ENOSYS;
3208}
3209
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003210int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003211 void __user *buffer, size_t *lenp, loff_t *ppos)
3212{
3213 return -ENOSYS;
3214}
3215
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003216int proc_douintvec(struct ctl_table *table, int write,
3217 void __user *buffer, size_t *lenp, loff_t *ppos)
3218{
3219 return -ENOSYS;
3220}
3221
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003222int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003223 void __user *buffer, size_t *lenp, loff_t *ppos)
3224{
3225 return -ENOSYS;
3226}
3227
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003228int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003229 void __user *buffer, size_t *lenp, loff_t *ppos)
3230{
3231 return -ENOSYS;
3232}
3233
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003234int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003235 void __user *buffer, size_t *lenp, loff_t *ppos)
3236{
3237 return -ENOSYS;
3238}
3239
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003240int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003241 void __user *buffer, size_t *lenp, loff_t *ppos)
3242{
3243 return -ENOSYS;
3244}
3245
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003246int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003247 void __user *buffer, size_t *lenp, loff_t *ppos)
3248{
3249 return -ENOSYS;
3250}
3251
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003252int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003253 void __user *buffer,
3254 size_t *lenp, loff_t *ppos)
3255{
3256 return -ENOSYS;
3257}
3258
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003259int proc_douintvec_capacity(struct ctl_table *table, int write,
3260 void __user *buffer, size_t *lenp, loff_t *ppos)
3261{
3262 return -ENOSYS;
3263}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003264
Jovi Zhang55610502011-01-12 17:00:45 -08003265#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003266
Linus Torvalds1da177e2005-04-16 15:20:36 -07003267/*
3268 * No sense putting this after each symbol definition, twice,
3269 * exception granted :-)
3270 */
3271EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003272EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003273EXPORT_SYMBOL(proc_dointvec_jiffies);
3274EXPORT_SYMBOL(proc_dointvec_minmax);
3275EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3276EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3277EXPORT_SYMBOL(proc_dostring);
3278EXPORT_SYMBOL(proc_doulongvec_minmax);
3279EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);