blob: 3a16618310183e63657db6db844ab43a390e6847 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080022#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070027#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080028#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080029#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070031#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020033#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080066#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070067#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050068#include <linux/mount.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#include <asm/uaccess.h>
71#include <asm/processor.h>
72
Andi Kleen29cbc782006-09-30 01:47:55 +020073#ifdef CONFIG_X86
74#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010075#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010076#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020077#endif
David Howellsd550bbd2012-03-28 18:30:03 +010078#ifdef CONFIG_SPARC
79#include <asm/setup.h>
80#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080081#ifdef CONFIG_BSD_PROCESS_ACCT
82#include <linux/acct.h>
83#endif
Dave Young4f0e0562010-03-10 15:24:09 -080084#ifdef CONFIG_RT_MUTEXES
85#include <linux/rtmutex.h>
86#endif
Dave Young2edf5e42010-03-10 15:24:10 -080087#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88#include <linux/lockdep.h>
89#endif
Dave Young15485a42010-03-10 15:24:07 -080090#ifdef CONFIG_CHR_DEV_SG
91#include <scsi/sg.h>
92#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020093
Don Zickus58687ac2010-05-07 17:11:44 -040094#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050095#include <linux/nmi.h>
96#endif
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#if defined(CONFIG_SYSCTL)
99
100/* External variables not in a header file. */
Daniel Micay15169fa2017-05-16 17:51:48 -0400101#ifdef CONFIG_USB
102extern int deny_new_usb;
103#endif
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
Daniel Borkmannb6ef4bc2021-05-11 22:35:17 +0200231#ifdef CONFIG_BPF_SYSCALL
Josh Poimboeuf64818352022-02-18 11:49:08 -0800232
233void __weak unpriv_ebpf_notify(int new_state)
234{
235}
236
Daniel Borkmannb6ef4bc2021-05-11 22:35:17 +0200237static int bpf_unpriv_handler(struct ctl_table *table, int write,
238 void *buffer, size_t *lenp, loff_t *ppos)
239{
240 int ret, unpriv_enable = *(int *)table->data;
241 bool locked_state = unpriv_enable == 1;
242 struct ctl_table tmp = *table;
243
244 if (write && !capable(CAP_SYS_ADMIN))
245 return -EPERM;
246
247 tmp.data = &unpriv_enable;
248 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
249 if (write && !ret) {
250 if (locked_state && unpriv_enable != 1)
251 return -EPERM;
252 *(int *)table->data = unpriv_enable;
253 }
Josh Poimboeuf64818352022-02-18 11:49:08 -0800254
255 unpriv_ebpf_notify(unpriv_enable);
256
Daniel Borkmannb6ef4bc2021-05-11 22:35:17 +0200257 return ret;
258}
259#endif
260
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700261static struct ctl_table kern_table[];
262static struct ctl_table vm_table[];
263static struct ctl_table fs_table[];
264static struct ctl_table debug_table[];
265static struct ctl_table dev_table[];
266extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800267#ifdef CONFIG_EPOLL
268extern struct ctl_table epoll_table[];
269#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
271#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
272int sysctl_legacy_va_layout;
273#endif
274
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275/* The default sysctl tables: */
276
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800277static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 .procname = "kernel",
280 .mode = 0555,
281 .child = kern_table,
282 },
283 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 .procname = "vm",
285 .mode = 0555,
286 .child = vm_table,
287 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 .procname = "fs",
290 .mode = 0555,
291 .child = fs_table,
292 },
293 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 .procname = "debug",
295 .mode = 0555,
296 .child = debug_table,
297 },
298 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 .procname = "dev",
300 .mode = 0555,
301 .child = dev_table,
302 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700303 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304};
305
Ingo Molnar77e54a12007-07-09 18:52:00 +0200306#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100307static int min_sched_granularity_ns = 100000; /* 100 usecs */
308static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
309static int min_wakeup_granularity_ns; /* 0 usecs */
310static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200311#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100312static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
313static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200314#endif /* CONFIG_SMP */
315#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200316
Mel Gorman5e771902010-05-24 14:32:31 -0700317#ifdef CONFIG_COMPACTION
318static int min_extfrag_threshold;
319static int max_extfrag_threshold = 1000;
320#endif
321
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700322static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200323 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200324 .procname = "sched_child_runs_first",
325 .data = &sysctl_sched_child_runs_first,
326 .maxlen = sizeof(unsigned int),
327 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800328 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200329 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530330#if defined(CONFIG_PREEMPT_TRACER) || defined(CONFIG_IRQSOFF_TRACER)
331 {
332 .procname = "preemptoff_tracing_threshold_ns",
333 .data = &sysctl_preemptoff_tracing_threshold_ns,
334 .maxlen = sizeof(unsigned int),
335 .mode = 0644,
336 .proc_handler = proc_dointvec,
337 },
Pavankumar Kondeti0d2621b2018-03-26 15:56:26 +0530338 {
339 .procname = "irqsoff_tracing_threshold_ns",
340 .data = &sysctl_irqsoff_tracing_threshold_ns,
341 .maxlen = sizeof(unsigned int),
342 .mode = 0644,
343 .proc_handler = proc_dointvec,
344 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530345#endif
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800346#ifdef CONFIG_SCHED_WALT
347 {
348 .procname = "sched_cpu_high_irqload",
349 .data = &sysctl_sched_cpu_high_irqload,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
352 .proc_handler = proc_dointvec,
353 },
Joonwoo Park6f188472017-06-16 11:32:17 -0700354 {
355 .procname = "sched_group_upmigrate",
356 .data = &sysctl_sched_group_upmigrate_pct,
357 .maxlen = sizeof(unsigned int),
358 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700359 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700360 .extra1 = &sysctl_sched_group_downmigrate_pct,
361 },
362 {
363 .procname = "sched_group_downmigrate",
364 .data = &sysctl_sched_group_downmigrate_pct,
365 .maxlen = sizeof(unsigned int),
366 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700367 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700368 .extra1 = &zero,
369 .extra2 = &sysctl_sched_group_upmigrate_pct,
370 },
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530371 {
372 .procname = "sched_boost",
373 .data = &sysctl_sched_boost,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = sched_boost_handler,
377 .extra1 = &zero,
378 .extra2 = &three,
379 },
Pavankumar Kondeti4e13d112018-01-25 01:12:08 +0530380 {
381 .procname = "sched_walt_rotate_big_tasks",
382 .data = &sysctl_sched_walt_rotate_big_tasks,
383 .maxlen = sizeof(unsigned int),
384 .mode = 0644,
385 .proc_handler = proc_dointvec_minmax,
386 .extra1 = &zero,
387 .extra2 = &one,
388 },
Lingutla Chandrasekhar57eb0712018-03-12 10:20:08 +0530389 {
390 .procname = "sched_initial_task_util",
391 .data = &sysctl_sched_init_task_load_pct,
392 .maxlen = sizeof(unsigned int),
393 .mode = 0644,
394 .proc_handler = proc_dointvec,
395 },
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700396 {
397 .procname = "sched_min_task_util_for_boost_colocation",
398 .data = &sysctl_sched_min_task_util_for_boost_colocation,
399 .maxlen = sizeof(unsigned int),
400 .mode = 0644,
401 .proc_handler = proc_dointvec_minmax,
402 .extra1 = &zero,
403 .extra2 = &one_thousand,
404 },
Satya Durga Srinivasu Prabhalac18b4032018-04-17 11:21:23 -0700405 {
406 .procname = "sched_little_cluster_coloc_fmin_khz",
407 .data = &sysctl_sched_little_cluster_coloc_fmin_khz,
408 .maxlen = sizeof(unsigned int),
409 .mode = 0644,
410 .proc_handler = sched_little_cluster_coloc_fmin_khz_handler,
411 .extra1 = &zero,
412 .extra2 = &two_million,
413 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800414#endif
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530415 {
416 .procname = "sched_upmigrate",
417 .data = &sysctl_sched_capacity_margin,
418 .maxlen = sizeof(unsigned int),
419 .mode = 0644,
420 .proc_handler = sched_updown_migrate_handler,
421 },
422 {
423 .procname = "sched_downmigrate",
424 .data = &sysctl_sched_capacity_margin_down,
425 .maxlen = sizeof(unsigned int),
426 .mode = 0644,
427 .proc_handler = sched_updown_migrate_handler,
428 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200429#ifdef CONFIG_SCHED_DEBUG
430 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100431 .procname = "sched_min_granularity_ns",
432 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200433 .maxlen = sizeof(unsigned int),
434 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800435 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100436 .extra1 = &min_sched_granularity_ns,
437 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200438 },
439 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200440 .procname = "sched_latency_ns",
441 .data = &sysctl_sched_latency,
442 .maxlen = sizeof(unsigned int),
443 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800444 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200445 .extra1 = &min_sched_granularity_ns,
446 .extra2 = &max_sched_granularity_ns,
447 },
448 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000449 .procname = "sched_sync_hint_enable",
450 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100451 .maxlen = sizeof(unsigned int),
452 .mode = 0644,
453 .proc_handler = proc_dointvec,
454 },
455 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100456 .procname = "sched_cstate_aware",
457 .data = &sysctl_sched_cstate_aware,
458 .maxlen = sizeof(unsigned int),
459 .mode = 0644,
460 .proc_handler = proc_dointvec,
461 },
462 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200463 .procname = "sched_wakeup_granularity_ns",
464 .data = &sysctl_sched_wakeup_granularity,
465 .maxlen = sizeof(unsigned int),
466 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800467 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200468 .extra1 = &min_wakeup_granularity_ns,
469 .extra2 = &max_wakeup_granularity_ns,
470 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200471#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200472 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100473 .procname = "sched_tunable_scaling",
474 .data = &sysctl_sched_tunable_scaling,
475 .maxlen = sizeof(enum sched_tunable_scaling),
476 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800477 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100478 .extra1 = &min_sched_tunable_scaling,
479 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200480 },
481 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900482 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200483 .data = &sysctl_sched_migration_cost,
484 .maxlen = sizeof(unsigned int),
485 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800486 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200487 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100488 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100489 .procname = "sched_nr_migrate",
490 .data = &sysctl_sched_nr_migrate,
491 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100492 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800493 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100494 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530495 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900496 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200497 .data = &sysctl_sched_time_avg,
498 .maxlen = sizeof(unsigned int),
499 .mode = 0644,
Pavankumar Kondeti12939492017-02-02 14:24:34 +0530500 .proc_handler = proc_dointvec_minmax,
501 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200502 },
503 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900504 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800505 .data = &sysctl_sched_shares_window,
506 .maxlen = sizeof(unsigned int),
507 .mode = 0644,
508 .proc_handler = proc_dointvec,
509 },
Mel Gormancb251762016-02-05 09:08:36 +0000510#ifdef CONFIG_SCHEDSTATS
511 {
512 .procname = "sched_schedstats",
513 .data = NULL,
514 .maxlen = sizeof(unsigned int),
515 .mode = 0644,
516 .proc_handler = sysctl_schedstats,
517 .extra1 = &zero,
518 .extra2 = &one,
519 },
520#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200521#endif /* CONFIG_SMP */
522#ifdef CONFIG_NUMA_BALANCING
523 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200524 .procname = "numa_balancing_scan_delay_ms",
525 .data = &sysctl_numa_balancing_scan_delay,
526 .maxlen = sizeof(unsigned int),
527 .mode = 0644,
528 .proc_handler = proc_dointvec,
529 },
530 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200531 .procname = "numa_balancing_scan_period_min_ms",
532 .data = &sysctl_numa_balancing_scan_period_min,
533 .maxlen = sizeof(unsigned int),
534 .mode = 0644,
535 .proc_handler = proc_dointvec,
536 },
537 {
538 .procname = "numa_balancing_scan_period_max_ms",
539 .data = &sysctl_numa_balancing_scan_period_max,
540 .maxlen = sizeof(unsigned int),
541 .mode = 0644,
542 .proc_handler = proc_dointvec,
543 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200544 {
545 .procname = "numa_balancing_scan_size_mb",
546 .data = &sysctl_numa_balancing_scan_size,
547 .maxlen = sizeof(unsigned int),
548 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400549 .proc_handler = proc_dointvec_minmax,
550 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200551 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100552 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800553 .procname = "numa_balancing",
554 .data = NULL, /* filled in by handler */
555 .maxlen = sizeof(unsigned int),
556 .mode = 0644,
557 .proc_handler = sysctl_numa_balancing,
558 .extra1 = &zero,
559 .extra2 = &one,
560 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200561#endif /* CONFIG_NUMA_BALANCING */
562#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200563 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100564 .procname = "sched_rt_period_us",
565 .data = &sysctl_sched_rt_period,
566 .maxlen = sizeof(unsigned int),
567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800568 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100569 },
570 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100571 .procname = "sched_rt_runtime_us",
572 .data = &sysctl_sched_rt_runtime,
573 .maxlen = sizeof(int),
574 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800575 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100576 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600577 {
578 .procname = "sched_rr_timeslice_ms",
Shile Zhang0c199342017-01-28 22:00:49 +0800579 .data = &sysctl_sched_rr_timeslice,
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600580 .maxlen = sizeof(int),
581 .mode = 0644,
582 .proc_handler = sched_rr_handler,
583 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100584#ifdef CONFIG_SCHED_AUTOGROUP
585 {
586 .procname = "sched_autogroup_enabled",
587 .data = &sysctl_sched_autogroup_enabled,
588 .maxlen = sizeof(unsigned int),
589 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800590 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100591 .extra1 = &zero,
592 .extra2 = &one,
593 },
594#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700595#ifdef CONFIG_CFS_BANDWIDTH
596 {
597 .procname = "sched_cfs_bandwidth_slice_us",
598 .data = &sysctl_sched_cfs_bandwidth_slice,
599 .maxlen = sizeof(unsigned int),
600 .mode = 0644,
601 .proc_handler = proc_dointvec_minmax,
602 .extra1 = &one,
603 },
604#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100605#ifdef CONFIG_SCHED_TUNE
606 {
607 .procname = "sched_cfs_boost",
608 .data = &sysctl_sched_cfs_boost,
609 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100610#ifdef CONFIG_CGROUP_SCHEDTUNE
611 .mode = 0444,
612#else
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100613 .mode = 0644,
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100614#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100615 .proc_handler = &sysctl_sched_cfs_boost_handler,
616 .extra1 = &zero,
617 .extra2 = &one_hundred,
618 },
619#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700620#ifdef CONFIG_PROVE_LOCKING
621 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700622 .procname = "prove_locking",
623 .data = &prove_locking,
624 .maxlen = sizeof(int),
625 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800626 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700627 },
628#endif
629#ifdef CONFIG_LOCK_STAT
630 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700631 .procname = "lock_stat",
632 .data = &lock_stat,
633 .maxlen = sizeof(int),
634 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800635 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700636 },
637#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200638 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .procname = "panic",
640 .data = &panic_timeout,
641 .maxlen = sizeof(int),
642 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800643 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 },
Alex Kelly046d6622012-10-04 17:15:23 -0700645#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 .procname = "core_uses_pid",
648 .data = &core_uses_pid,
649 .maxlen = sizeof(int),
650 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800651 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 },
653 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .procname = "core_pattern",
655 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700656 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700658 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 },
Neil Hormana2939802009-09-23 15:56:56 -0700660 {
Neil Hormana2939802009-09-23 15:56:56 -0700661 .procname = "core_pipe_limit",
662 .data = &core_pipe_limit,
663 .maxlen = sizeof(unsigned int),
664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700666 },
Alex Kelly046d6622012-10-04 17:15:23 -0700667#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800668#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700671 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700675 {
676 .procname = "sysctl_writes_strict",
677 .data = &sysctl_writes_strict,
678 .maxlen = sizeof(int),
679 .mode = 0644,
680 .proc_handler = proc_dointvec_minmax,
681 .extra1 = &neg_one,
682 .extra2 = &one,
683 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800684#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100685#ifdef CONFIG_LATENCYTOP
686 {
687 .procname = "latencytop",
688 .data = &latencytop_enabled,
689 .maxlen = sizeof(int),
690 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000691 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100692 },
693#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694#ifdef CONFIG_BLK_DEV_INITRD
695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 .procname = "real-root-dev",
697 .data = &real_root_dev,
698 .maxlen = sizeof(int),
699 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800700 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 },
702#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700703 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700704 .procname = "print-fatal-signals",
705 .data = &print_fatal_signals,
706 .maxlen = sizeof(int),
707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700709 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700710#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .procname = "reboot-cmd",
713 .data = reboot_command,
714 .maxlen = 256,
715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800716 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 },
718 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .procname = "stop-a",
720 .data = &stop_a_enabled,
721 .maxlen = sizeof (int),
722 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800723 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 },
725 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 .procname = "scons-poweroff",
727 .data = &scons_pwroff,
728 .maxlen = sizeof (int),
729 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800730 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 },
732#endif
David S. Miller08714202008-11-16 23:49:24 -0800733#ifdef CONFIG_SPARC64
734 {
David S. Miller08714202008-11-16 23:49:24 -0800735 .procname = "tsb-ratio",
736 .data = &sysctl_tsb_ratio,
737 .maxlen = sizeof (int),
738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800740 },
741#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742#ifdef __hppa__
743 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .procname = "soft-power",
745 .data = &pwrsw_enabled,
746 .maxlen = sizeof (int),
747 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800748 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530750#endif
751#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 .procname = "unaligned-trap",
754 .data = &unaligned_enabled,
755 .maxlen = sizeof (int),
756 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800757 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 },
759#endif
760 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 .procname = "ctrl-alt-del",
762 .data = &C_A_D,
763 .maxlen = sizeof(int),
764 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800765 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400767#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200768 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200769 .procname = "ftrace_enabled",
770 .data = &ftrace_enabled,
771 .maxlen = sizeof(int),
772 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800773 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200774 },
775#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500776#ifdef CONFIG_STACK_TRACER
777 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500778 .procname = "stack_tracer_enabled",
779 .data = &stack_tracer_enabled,
780 .maxlen = sizeof(int),
781 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800782 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500783 },
784#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400785#ifdef CONFIG_TRACING
786 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100787 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400788 .data = &ftrace_dump_on_oops,
789 .maxlen = sizeof(int),
790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800791 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400792 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400793 {
794 .procname = "traceoff_on_warning",
795 .data = &__disable_trace_on_warning,
796 .maxlen = sizeof(__disable_trace_on_warning),
797 .mode = 0644,
798 .proc_handler = proc_dointvec,
799 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500800 {
801 .procname = "tracepoint_printk",
802 .data = &tracepoint_printk,
803 .maxlen = sizeof(tracepoint_printk),
804 .mode = 0644,
805 .proc_handler = proc_dointvec,
806 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400807#endif
Dave Young2965faa2015-09-09 15:38:55 -0700808#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800809 {
810 .procname = "kexec_load_disabled",
811 .data = &kexec_load_disabled,
812 .maxlen = sizeof(int),
813 .mode = 0644,
814 /* only handle a transition from default "0" to "1" */
815 .proc_handler = proc_dointvec_minmax,
816 .extra1 = &one,
817 .extra2 = &one,
818 },
819#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200820#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 .procname = "modprobe",
823 .data = &modprobe_path,
824 .maxlen = KMOD_PATH_LEN,
825 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800826 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 },
Kees Cook3d433212009-04-02 15:49:29 -0700828 {
Kees Cook3d433212009-04-02 15:49:29 -0700829 .procname = "modules_disabled",
830 .data = &modules_disabled,
831 .maxlen = sizeof(int),
832 .mode = 0644,
833 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800834 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700835 .extra1 = &one,
836 .extra2 = &one,
837 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700839#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100842 .data = &uevent_helper,
843 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800845 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 },
Michael Marineau86d56132014-04-10 14:09:31 -0700847#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848#ifdef CONFIG_CHR_DEV_SG
849 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 .procname = "sg-big-buff",
851 .data = &sg_big_buff,
852 .maxlen = sizeof (int),
853 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800854 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 },
856#endif
857#ifdef CONFIG_BSD_PROCESS_ACCT
858 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 .procname = "acct",
860 .data = &acct_parm,
861 .maxlen = 3*sizeof(int),
862 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800863 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 },
865#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866#ifdef CONFIG_MAGIC_SYSRQ
867 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800869 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 .maxlen = sizeof (int),
871 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700872 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 },
874#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700875#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700878 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 .maxlen = sizeof (int),
880 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800881 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700883#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700886 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 .maxlen = sizeof(int),
888 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700889 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 },
891 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 .procname = "random",
893 .mode = 0555,
894 .child = random_table,
895 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 {
Eric Paris17f60a72011-04-01 17:07:50 -0400897 .procname = "usermodehelper",
898 .mode = 0555,
899 .child = usermodehelper_table,
900 },
901 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 .procname = "overflowuid",
903 .data = &overflowuid,
904 .maxlen = sizeof(int),
905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800906 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 .extra1 = &minolduid,
908 .extra2 = &maxolduid,
909 },
910 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 .procname = "overflowgid",
912 .data = &overflowgid,
913 .maxlen = sizeof(int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 .extra1 = &minolduid,
917 .extra2 = &maxolduid,
918 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800919#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920#ifdef CONFIG_MATHEMU
921 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922 .procname = "ieee_emulation_warnings",
923 .data = &sysctl_ieee_emulation_warnings,
924 .maxlen = sizeof(int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 },
928#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200931 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 .maxlen = sizeof(int),
933 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800934 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 },
936#endif
937 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 .procname = "pid_max",
939 .data = &pid_max,
940 .maxlen = sizeof (int),
941 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800942 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 .extra1 = &pid_max_min,
944 .extra2 = &pid_max_max,
945 },
946 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 .procname = "panic_on_oops",
948 .data = &panic_on_oops,
949 .maxlen = sizeof(int),
950 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800951 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800953#if defined CONFIG_PRINTK
954 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800955 .procname = "printk",
956 .data = &console_loglevel,
957 .maxlen = 4*sizeof(int),
958 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800959 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800960 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700963 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 .maxlen = sizeof(int),
965 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800966 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967 },
968 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700970 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 .maxlen = sizeof(int),
972 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800973 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 },
Dave Youngaf913222009-09-22 16:43:33 -0700975 {
Dave Youngaf913222009-09-22 16:43:33 -0700976 .procname = "printk_delay",
977 .data = &printk_delay_msec,
978 .maxlen = sizeof(int),
979 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800980 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700981 .extra1 = &zero,
982 .extra2 = &ten_thousand,
983 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700985 .procname = "printk_devkmsg",
986 .data = devkmsg_log_str,
987 .maxlen = DEVKMSG_STR_MAX_SIZE,
988 .mode = 0644,
989 .proc_handler = devkmsg_sysctl_set_loglvl,
990 },
991 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800992 .procname = "dmesg_restrict",
993 .data = &dmesg_restrict,
994 .maxlen = sizeof(int),
995 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700996 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800997 .extra1 = &zero,
998 .extra2 = &one,
999 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -08001000 {
1001 .procname = "kptr_restrict",
1002 .data = &kptr_restrict,
1003 .maxlen = sizeof(int),
1004 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -07001005 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -08001006 .extra1 = &zero,
1007 .extra2 = &two,
1008 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -08001009#endif
Daniel Micay15169fa2017-05-16 17:51:48 -04001010#ifdef CONFIG_USB
1011 {
1012 .procname = "deny_new_usb",
1013 .data = &deny_new_usb,
1014 .maxlen = sizeof(int),
1015 .mode = 0644,
1016 .proc_handler = proc_dointvec_minmax_sysadmin,
1017 .extra1 = &zero,
1018 .extra2 = &one,
1019 },
1020#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -08001021 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001022 .procname = "ngroups_max",
1023 .data = &ngroups_max,
1024 .maxlen = sizeof (int),
1025 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001026 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 },
Dan Ballard73efc032011-10-31 17:11:20 -07001028 {
1029 .procname = "cap_last_cap",
1030 .data = (void *)&cap_last_cap,
1031 .maxlen = sizeof(int),
1032 .mode = 0444,
1033 .proc_handler = proc_dointvec,
1034 },
Don Zickus58687ac2010-05-07 17:11:44 -04001035#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -05001036 {
Don Zickus58687ac2010-05-07 17:11:44 -04001037 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +02001038 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -05001039 .maxlen = sizeof (int),
1040 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001041 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001042 .extra1 = &zero,
1043 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -04001044 },
1045 {
1046 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001047 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -04001048 .maxlen = sizeof(int),
1049 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001050 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +08001051 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -04001052 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -05001053 },
Don Zickus2508ce12010-05-07 17:11:46 -04001054 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001055 .procname = "nmi_watchdog",
1056 .data = &nmi_watchdog_enabled,
1057 .maxlen = sizeof (int),
1058 .mode = 0644,
1059 .proc_handler = proc_nmi_watchdog,
1060 .extra1 = &zero,
1061#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
1062 .extra2 = &one,
1063#else
1064 .extra2 = &zero,
1065#endif
1066 },
1067 {
1068 .procname = "soft_watchdog",
1069 .data = &soft_watchdog_enabled,
1070 .maxlen = sizeof (int),
1071 .mode = 0644,
1072 .proc_handler = proc_soft_watchdog,
1073 .extra1 = &zero,
1074 .extra2 = &one,
1075 },
1076 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001077 .procname = "watchdog_cpumask",
1078 .data = &watchdog_cpumask_bits,
1079 .maxlen = NR_CPUS,
1080 .mode = 0644,
1081 .proc_handler = proc_watchdog_cpumask,
1082 },
1083 {
Don Zickus2508ce12010-05-07 17:11:46 -04001084 .procname = "softlockup_panic",
1085 .data = &softlockup_panic,
1086 .maxlen = sizeof(int),
1087 .mode = 0644,
1088 .proc_handler = proc_dointvec_minmax,
1089 .extra1 = &zero,
1090 .extra2 = &one,
1091 },
Don Zickusac1f5912015-11-05 18:44:44 -08001092#ifdef CONFIG_HARDLOCKUP_DETECTOR
1093 {
1094 .procname = "hardlockup_panic",
1095 .data = &hardlockup_panic,
1096 .maxlen = sizeof(int),
1097 .mode = 0644,
1098 .proc_handler = proc_dointvec_minmax,
1099 .extra1 = &zero,
1100 .extra2 = &one,
1101 },
1102#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001103#ifdef CONFIG_SMP
1104 {
1105 .procname = "softlockup_all_cpu_backtrace",
1106 .data = &sysctl_softlockup_all_cpu_backtrace,
1107 .maxlen = sizeof(int),
1108 .mode = 0644,
1109 .proc_handler = proc_dointvec_minmax,
1110 .extra1 = &zero,
1111 .extra2 = &one,
1112 },
Jiri Kosina55537872015-11-05 18:44:41 -08001113 {
1114 .procname = "hardlockup_all_cpu_backtrace",
1115 .data = &sysctl_hardlockup_all_cpu_backtrace,
1116 .maxlen = sizeof(int),
1117 .mode = 0644,
1118 .proc_handler = proc_dointvec_minmax,
1119 .extra1 = &zero,
1120 .extra2 = &one,
1121 },
Aaron Tomlined235872014-06-23 13:22:05 -07001122#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001123#endif
1124#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1125 {
1126 .procname = "unknown_nmi_panic",
1127 .data = &unknown_nmi_panic,
1128 .maxlen = sizeof (int),
1129 .mode = 0644,
1130 .proc_handler = proc_dointvec,
1131 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001132#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133#if defined(CONFIG_X86)
1134 {
Don Zickus8da5add2006-09-26 10:52:27 +02001135 .procname = "panic_on_unrecovered_nmi",
1136 .data = &panic_on_unrecovered_nmi,
1137 .maxlen = sizeof(int),
1138 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001139 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001140 },
1141 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001142 .procname = "panic_on_io_nmi",
1143 .data = &panic_on_io_nmi,
1144 .maxlen = sizeof(int),
1145 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001146 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001147 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001148#ifdef CONFIG_DEBUG_STACKOVERFLOW
1149 {
1150 .procname = "panic_on_stackoverflow",
1151 .data = &sysctl_panic_on_stackoverflow,
1152 .maxlen = sizeof(int),
1153 .mode = 0644,
1154 .proc_handler = proc_dointvec,
1155 },
1156#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001157 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 .procname = "bootloader_type",
1159 .data = &bootloader_type,
1160 .maxlen = sizeof (int),
1161 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001162 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001164 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001165 .procname = "bootloader_version",
1166 .data = &bootloader_version,
1167 .maxlen = sizeof (int),
1168 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001169 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001170 },
1171 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001172 .procname = "kstack_depth_to_print",
1173 .data = &kstack_depth_to_print,
1174 .maxlen = sizeof(int),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001177 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001178 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001179 .procname = "io_delay_type",
1180 .data = &io_delay_type,
1181 .maxlen = sizeof(int),
1182 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001183 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001184 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001186#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 .procname = "randomize_va_space",
1189 .data = &randomize_va_space,
1190 .maxlen = sizeof(int),
1191 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001192 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001194#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001195#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001196 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001197 .procname = "spin_retry",
1198 .data = &spin_retry,
1199 .maxlen = sizeof (int),
1200 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001201 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001202 },
1203#endif
Len Brown673d5b42007-07-28 03:33:16 -04001204#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001205 {
Pavel Machekc255d842006-02-20 18:27:58 -08001206 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001207 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001208 .maxlen = sizeof (unsigned long),
1209 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001210 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001211 },
1212#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301213#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001214 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001215 .procname = "ignore-unaligned-usertrap",
1216 .data = &no_unaligned_warning,
1217 .maxlen = sizeof (int),
1218 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001219 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001220 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301221#endif
1222#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001223 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001224 .procname = "unaligned-dump-stack",
1225 .data = &unaligned_dump_stack,
1226 .maxlen = sizeof (int),
1227 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001228 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001229 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001230#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001231#ifdef CONFIG_DETECT_HUNG_TASK
1232 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001233 .procname = "hung_task_panic",
1234 .data = &sysctl_hung_task_panic,
1235 .maxlen = sizeof(int),
1236 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001237 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001238 .extra1 = &zero,
1239 .extra2 = &one,
1240 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001241 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001242 .procname = "hung_task_check_count",
1243 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001244 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001245 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001246 .proc_handler = proc_dointvec_minmax,
1247 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001248 },
1249 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001250 .procname = "hung_task_timeout_secs",
1251 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001252 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001255 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001256 },
1257 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001258 .procname = "hung_task_warnings",
1259 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001260 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001261 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001262 .proc_handler = proc_dointvec_minmax,
1263 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001264 },
Imran Khana9788f42017-09-18 15:48:30 +05301265 {
1266 .procname = "hung_task_selective_monitoring",
1267 .data = &sysctl_hung_task_selective_monitoring,
1268 .maxlen = sizeof(int),
1269 .mode = 0644,
1270 .proc_handler = proc_dointvec_minmax,
1271 .extra1 = &zero,
1272 .extra2 = &one,
1273 },
1274
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001275#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001276#ifdef CONFIG_RT_MUTEXES
1277 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001278 .procname = "max_lock_depth",
1279 .data = &max_lock_depth,
1280 .maxlen = sizeof(int),
1281 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001282 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001283 },
1284#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001285 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001286 .procname = "poweroff_cmd",
1287 .data = &poweroff_cmd,
1288 .maxlen = POWEROFF_CMD_PATH_LEN,
1289 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001290 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001291 },
David Howells0b77f5b2008-04-29 01:01:32 -07001292#ifdef CONFIG_KEYS
1293 {
David Howells0b77f5b2008-04-29 01:01:32 -07001294 .procname = "keys",
1295 .mode = 0555,
1296 .child = key_sysctls,
1297 },
1298#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001299#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001300 /*
1301 * User-space scripts rely on the existence of this file
1302 * as a feature check for perf_events being enabled.
1303 *
1304 * So it's an ABI, do not remove!
1305 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001306 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001307 .procname = "perf_event_paranoid",
1308 .data = &sysctl_perf_event_paranoid,
1309 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001310 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001311 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001312 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001313 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001314 .procname = "perf_event_mlock_kb",
1315 .data = &sysctl_perf_event_mlock,
1316 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001319 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001320 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001321 .procname = "perf_event_max_sample_rate",
1322 .data = &sysctl_perf_event_sample_rate,
1323 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001324 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001325 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001326 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001327 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001328 {
1329 .procname = "perf_cpu_time_max_percent",
1330 .data = &sysctl_perf_cpu_time_max_percent,
1331 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1332 .mode = 0644,
1333 .proc_handler = perf_cpu_time_max_percent_handler,
1334 .extra1 = &zero,
1335 .extra2 = &one_hundred,
1336 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001337 {
1338 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001339 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001340 .maxlen = sizeof(sysctl_perf_event_max_stack),
1341 .mode = 0644,
1342 .proc_handler = perf_event_max_stack_handler,
1343 .extra1 = &zero,
1344 .extra2 = &six_hundred_forty_kb,
1345 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001346 {
1347 .procname = "perf_event_max_contexts_per_stack",
1348 .data = &sysctl_perf_event_max_contexts_per_stack,
1349 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1350 .mode = 0644,
1351 .proc_handler = perf_event_max_stack_handler,
1352 .extra1 = &zero,
1353 .extra2 = &one_thousand,
1354 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001355#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001356#ifdef CONFIG_KMEMCHECK
1357 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001358 .procname = "kmemcheck",
1359 .data = &kmemcheck_enabled,
1360 .maxlen = sizeof(int),
1361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001362 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001363 },
1364#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001365 {
1366 .procname = "panic_on_warn",
1367 .data = &panic_on_warn,
1368 .maxlen = sizeof(int),
1369 .mode = 0644,
1370 .proc_handler = proc_dointvec_minmax,
1371 .extra1 = &zero,
1372 .extra2 = &one,
1373 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001374#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1375 {
1376 .procname = "timer_migration",
1377 .data = &sysctl_timer_migration,
1378 .maxlen = sizeof(unsigned int),
1379 .mode = 0644,
1380 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001381 .extra1 = &zero,
1382 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001383 },
1384#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001385#ifdef CONFIG_BPF_SYSCALL
1386 {
1387 .procname = "unprivileged_bpf_disabled",
1388 .data = &sysctl_unprivileged_bpf_disabled,
1389 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1390 .mode = 0644,
Daniel Borkmannb6ef4bc2021-05-11 22:35:17 +02001391 .proc_handler = bpf_unpriv_handler,
1392 .extra1 = &zero,
1393 .extra2 = &two,
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001394 },
1395#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001396#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1397 {
1398 .procname = "panic_on_rcu_stall",
1399 .data = &sysctl_panic_on_rcu_stall,
1400 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1401 .mode = 0644,
1402 .proc_handler = proc_dointvec_minmax,
1403 .extra1 = &zero,
1404 .extra2 = &one,
1405 },
1406#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001407#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001408 {
1409 .procname = "boot_reason",
1410 .data = &boot_reason,
1411 .maxlen = sizeof(int),
1412 .mode = 0444,
1413 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001414 },
1415
1416 {
1417 .procname = "cold_boot",
1418 .data = &cold_boot,
1419 .maxlen = sizeof(int),
1420 .mode = 0444,
1421 .proc_handler = proc_dointvec,
1422 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001423#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001424 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425};
1426
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001427static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429 .procname = "overcommit_memory",
1430 .data = &sysctl_overcommit_memory,
1431 .maxlen = sizeof(sysctl_overcommit_memory),
1432 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001433 .proc_handler = proc_dointvec_minmax,
1434 .extra1 = &zero,
1435 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 },
1437 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001438 .procname = "panic_on_oom",
1439 .data = &sysctl_panic_on_oom,
1440 .maxlen = sizeof(sysctl_panic_on_oom),
1441 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001442 .proc_handler = proc_dointvec_minmax,
1443 .extra1 = &zero,
1444 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001445 },
1446 {
David Rientjesfe071d72007-10-16 23:25:56 -07001447 .procname = "oom_kill_allocating_task",
1448 .data = &sysctl_oom_kill_allocating_task,
1449 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001451 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001452 },
1453 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001454 .procname = "oom_dump_tasks",
1455 .data = &sysctl_oom_dump_tasks,
1456 .maxlen = sizeof(sysctl_oom_dump_tasks),
1457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001458 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001459 },
1460 {
Charan Teja Reddyf9920cf2018-05-01 20:20:20 +05301461 .procname = "reap_mem_on_sigkill",
1462 .data = &sysctl_reap_mem_on_sigkill,
1463 .maxlen = sizeof(sysctl_reap_mem_on_sigkill),
1464 .mode = 0644,
1465 .proc_handler = proc_dointvec,
1466 },
1467 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 .procname = "overcommit_ratio",
1469 .data = &sysctl_overcommit_ratio,
1470 .maxlen = sizeof(sysctl_overcommit_ratio),
1471 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001472 .proc_handler = overcommit_ratio_handler,
1473 },
1474 {
1475 .procname = "overcommit_kbytes",
1476 .data = &sysctl_overcommit_kbytes,
1477 .maxlen = sizeof(sysctl_overcommit_kbytes),
1478 .mode = 0644,
1479 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 },
1481 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 .procname = "page-cluster",
1483 .data = &page_cluster,
1484 .maxlen = sizeof(int),
1485 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001486 .proc_handler = proc_dointvec_minmax,
1487 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 },
1489 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 .procname = "dirty_background_ratio",
1491 .data = &dirty_background_ratio,
1492 .maxlen = sizeof(dirty_background_ratio),
1493 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001494 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .extra1 = &zero,
1496 .extra2 = &one_hundred,
1497 },
1498 {
David Rientjes2da02992009-01-06 14:39:31 -08001499 .procname = "dirty_background_bytes",
1500 .data = &dirty_background_bytes,
1501 .maxlen = sizeof(dirty_background_bytes),
1502 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001503 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001504 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001505 },
1506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 .procname = "dirty_ratio",
1508 .data = &vm_dirty_ratio,
1509 .maxlen = sizeof(vm_dirty_ratio),
1510 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001511 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 .extra1 = &zero,
1513 .extra2 = &one_hundred,
1514 },
1515 {
David Rientjes2da02992009-01-06 14:39:31 -08001516 .procname = "dirty_bytes",
1517 .data = &vm_dirty_bytes,
1518 .maxlen = sizeof(vm_dirty_bytes),
1519 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001520 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001521 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001522 },
1523 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001525 .data = &dirty_writeback_interval,
1526 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001528 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529 },
1530 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001531 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001532 .data = &dirty_expire_interval,
1533 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001535 .proc_handler = proc_dointvec_minmax,
1536 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 },
1538 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001539 .procname = "dirtytime_expire_seconds",
1540 .data = &dirtytime_expire_interval,
1541 .maxlen = sizeof(dirty_expire_interval),
1542 .mode = 0644,
1543 .proc_handler = dirtytime_interval_handler,
1544 .extra1 = &zero,
1545 },
1546 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001547 .procname = "nr_pdflush_threads",
1548 .mode = 0444 /* read-only */,
1549 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550 },
1551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552 .procname = "swappiness",
1553 .data = &vm_swappiness,
1554 .maxlen = sizeof(vm_swappiness),
1555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001556 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 .extra1 = &zero,
1558 .extra2 = &one_hundred,
1559 },
Vinayak Menonb9e4cc2b2018-06-11 18:58:39 +05301560 {
1561 .procname = "want_old_faultaround_pte",
1562 .data = &want_old_faultaround_pte,
1563 .maxlen = sizeof(want_old_faultaround_pte),
1564 .mode = 0644,
1565 .proc_handler = proc_dointvec_minmax,
1566 .extra1 = &zero,
1567 .extra2 = &one,
1568 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001570 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001571 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001572 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 .maxlen = sizeof(unsigned long),
1574 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001575 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001576 },
1577#ifdef CONFIG_NUMA
1578 {
1579 .procname = "nr_hugepages_mempolicy",
1580 .data = NULL,
1581 .maxlen = sizeof(unsigned long),
1582 .mode = 0644,
1583 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001584 },
1585#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 .procname = "hugetlb_shm_group",
1588 .data = &sysctl_hugetlb_shm_group,
1589 .maxlen = sizeof(gid_t),
1590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001591 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 },
Mel Gorman396faf02007-07-17 04:03:13 -07001593 {
Mel Gorman396faf02007-07-17 04:03:13 -07001594 .procname = "hugepages_treat_as_movable",
1595 .data = &hugepages_treat_as_movable,
1596 .maxlen = sizeof(int),
1597 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001598 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001599 },
Adam Litke54f9f802007-10-16 01:26:20 -07001600 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001601 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001602 .data = NULL,
1603 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001604 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001605 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001606 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607#endif
1608 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001609 .procname = "lowmem_reserve_ratio",
1610 .data = &sysctl_lowmem_reserve_ratio,
1611 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1612 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001613 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001614 },
1615 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001616 .procname = "drop_caches",
1617 .data = &sysctl_drop_caches,
1618 .maxlen = sizeof(int),
Johannes Weinerb231f9d2019-11-30 17:56:08 -08001619 .mode = 0200,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001620 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001621 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001622 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001623 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001624#ifdef CONFIG_COMPACTION
1625 {
1626 .procname = "compact_memory",
1627 .data = &sysctl_compact_memory,
1628 .maxlen = sizeof(int),
1629 .mode = 0200,
1630 .proc_handler = sysctl_compaction_handler,
1631 },
Mel Gorman5e771902010-05-24 14:32:31 -07001632 {
1633 .procname = "extfrag_threshold",
1634 .data = &sysctl_extfrag_threshold,
1635 .maxlen = sizeof(int),
1636 .mode = 0644,
1637 .proc_handler = sysctl_extfrag_handler,
1638 .extra1 = &min_extfrag_threshold,
1639 .extra2 = &max_extfrag_threshold,
1640 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001641 {
1642 .procname = "compact_unevictable_allowed",
1643 .data = &sysctl_compact_unevictable_allowed,
1644 .maxlen = sizeof(int),
1645 .mode = 0644,
1646 .proc_handler = proc_dointvec,
1647 .extra1 = &zero,
1648 .extra2 = &one,
1649 },
Mel Gorman5e771902010-05-24 14:32:31 -07001650
Mel Gorman76ab0f52010-05-24 14:32:28 -07001651#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001652 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653 .procname = "min_free_kbytes",
1654 .data = &min_free_kbytes,
1655 .maxlen = sizeof(min_free_kbytes),
1656 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001657 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 .extra1 = &zero,
1659 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001660 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001661 .procname = "watermark_scale_factor",
1662 .data = &watermark_scale_factor,
1663 .maxlen = sizeof(watermark_scale_factor),
1664 .mode = 0644,
1665 .proc_handler = watermark_scale_factor_sysctl_handler,
Rik van Riel12462752011-09-01 15:26:50 -04001666 .extra1 = &zero,
1667 .extra2 = &zero,
1668 },
1669 {
1670 .procname = "extra_free_kbytes",
1671 .data = &extra_free_kbytes,
1672 .maxlen = sizeof(extra_free_kbytes),
1673 .mode = 0644,
1674 .proc_handler = min_free_kbytes_sysctl_handler,
1675 .extra1 = &zero,
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001676 },
1677 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001678 .procname = "percpu_pagelist_fraction",
1679 .data = &percpu_pagelist_fraction,
1680 .maxlen = sizeof(percpu_pagelist_fraction),
1681 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001682 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001683 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001684 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685#ifdef CONFIG_MMU
1686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 .procname = "max_map_count",
1688 .data = &sysctl_max_map_count,
1689 .maxlen = sizeof(sysctl_max_map_count),
1690 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001691 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001692 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001693 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001694#else
1695 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001696 .procname = "nr_trim_pages",
1697 .data = &sysctl_nr_trim_pages,
1698 .maxlen = sizeof(sysctl_nr_trim_pages),
1699 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001700 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001701 .extra1 = &zero,
1702 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703#endif
1704 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705 .procname = "laptop_mode",
1706 .data = &laptop_mode,
1707 .maxlen = sizeof(laptop_mode),
1708 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001709 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710 },
1711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712 .procname = "block_dump",
1713 .data = &block_dump,
1714 .maxlen = sizeof(block_dump),
1715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001716 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717 .extra1 = &zero,
1718 },
1719 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720 .procname = "vfs_cache_pressure",
1721 .data = &sysctl_vfs_cache_pressure,
1722 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1723 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001724 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 .extra1 = &zero,
1726 },
1727#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1728 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 .procname = "legacy_va_layout",
1730 .data = &sysctl_legacy_va_layout,
1731 .maxlen = sizeof(sysctl_legacy_va_layout),
1732 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001733 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 .extra1 = &zero,
1735 },
1736#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001737#ifdef CONFIG_NUMA
1738 {
Christoph Lameter17436602006-01-18 17:42:32 -08001739 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001740 .data = &node_reclaim_mode,
1741 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001742 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001743 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001744 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001745 },
Christoph Lameter96146342006-07-03 00:24:13 -07001746 {
Christoph Lameter96146342006-07-03 00:24:13 -07001747 .procname = "min_unmapped_ratio",
1748 .data = &sysctl_min_unmapped_ratio,
1749 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1750 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001751 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001752 .extra1 = &zero,
1753 .extra2 = &one_hundred,
1754 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001755 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001756 .procname = "min_slab_ratio",
1757 .data = &sysctl_min_slab_ratio,
1758 .maxlen = sizeof(sysctl_min_slab_ratio),
1759 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001760 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001761 .extra1 = &zero,
1762 .extra2 = &one_hundred,
1763 },
Christoph Lameter17436602006-01-18 17:42:32 -08001764#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001765#ifdef CONFIG_SMP
1766 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001767 .procname = "stat_interval",
1768 .data = &sysctl_stat_interval,
1769 .maxlen = sizeof(sysctl_stat_interval),
1770 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001771 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001772 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001773 {
1774 .procname = "stat_refresh",
1775 .data = NULL,
1776 .maxlen = 0,
1777 .mode = 0600,
1778 .proc_handler = vmstat_refresh,
1779 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001780#endif
David Howells6e141542009-12-15 19:27:45 +00001781#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001782 {
Eric Parised032182007-06-28 15:55:21 -04001783 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001784 .data = &dac_mmap_min_addr,
1785 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001786 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001787 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001788 },
David Howells6e141542009-12-15 19:27:45 +00001789#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001790#ifdef CONFIG_NUMA
1791 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001792 .procname = "numa_zonelist_order",
1793 .data = &numa_zonelist_order,
1794 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1795 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001796 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001797 },
1798#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001799#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001800 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001801 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001802 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001803#ifdef CONFIG_X86_32
1804 .data = &vdso32_enabled,
1805 .maxlen = sizeof(vdso32_enabled),
1806#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001807 .data = &vdso_enabled,
1808 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001809#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001810 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001811 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001812 .extra1 = &zero,
1813 },
1814#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001815#ifdef CONFIG_HIGHMEM
1816 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001817 .procname = "highmem_is_dirtyable",
1818 .data = &vm_highmem_is_dirtyable,
1819 .maxlen = sizeof(vm_highmem_is_dirtyable),
1820 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001821 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001822 .extra1 = &zero,
1823 .extra2 = &one,
1824 },
1825#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001826#ifdef CONFIG_MEMORY_FAILURE
1827 {
Andi Kleen6a460792009-09-16 11:50:15 +02001828 .procname = "memory_failure_early_kill",
1829 .data = &sysctl_memory_failure_early_kill,
1830 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1831 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001832 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001833 .extra1 = &zero,
1834 .extra2 = &one,
1835 },
1836 {
Andi Kleen6a460792009-09-16 11:50:15 +02001837 .procname = "memory_failure_recovery",
1838 .data = &sysctl_memory_failure_recovery,
1839 .maxlen = sizeof(sysctl_memory_failure_recovery),
1840 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001841 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001842 .extra1 = &zero,
1843 .extra2 = &one,
1844 },
1845#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001846 {
1847 .procname = "user_reserve_kbytes",
1848 .data = &sysctl_user_reserve_kbytes,
1849 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1850 .mode = 0644,
1851 .proc_handler = proc_doulongvec_minmax,
1852 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001853 {
1854 .procname = "admin_reserve_kbytes",
1855 .data = &sysctl_admin_reserve_kbytes,
1856 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1857 .mode = 0644,
1858 .proc_handler = proc_doulongvec_minmax,
1859 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001860#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1861 {
1862 .procname = "mmap_rnd_bits",
1863 .data = &mmap_rnd_bits,
1864 .maxlen = sizeof(mmap_rnd_bits),
1865 .mode = 0600,
1866 .proc_handler = proc_dointvec_minmax,
1867 .extra1 = (void *)&mmap_rnd_bits_min,
1868 .extra2 = (void *)&mmap_rnd_bits_max,
1869 },
1870#endif
1871#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1872 {
1873 .procname = "mmap_rnd_compat_bits",
1874 .data = &mmap_rnd_compat_bits,
1875 .maxlen = sizeof(mmap_rnd_compat_bits),
1876 .mode = 0600,
1877 .proc_handler = proc_dointvec_minmax,
1878 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1879 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1880 },
1881#endif
Vinayak Menonc1c6a992015-12-21 13:00:58 +05301882#ifdef CONFIG_SWAP
1883 {
1884 .procname = "swap_ratio",
1885 .data = &sysctl_swap_ratio,
1886 .maxlen = sizeof(sysctl_swap_ratio),
1887 .mode = 0644,
1888 .proc_handler = proc_dointvec_minmax,
1889 },
1890 {
1891 .procname = "swap_ratio_enable",
1892 .data = &sysctl_swap_ratio_enable,
1893 .maxlen = sizeof(sysctl_swap_ratio_enable),
1894 .mode = 0644,
1895 .proc_handler = proc_dointvec_minmax,
1896 },
1897#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001898 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899};
1900
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001901static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903 .procname = "inode-nr",
1904 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001905 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001907 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908 },
1909 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001910 .procname = "inode-state",
1911 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001912 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001914 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001915 },
1916 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001917 .procname = "file-nr",
1918 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001919 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001921 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001922 },
1923 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924 .procname = "file-max",
1925 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001926 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001927 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001928 .proc_handler = proc_doulongvec_minmax,
Will Deacon3141fcc2019-04-05 18:39:38 -07001929 .extra1 = &zero_ul,
Christian Brauner6b65c262019-03-07 16:29:43 -08001930 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001931 },
1932 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001933 .procname = "nr_open",
1934 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001935 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001936 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001937 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001938 .extra1 = &sysctl_nr_open_min,
1939 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001940 },
1941 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942 .procname = "dentry-state",
1943 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001944 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001945 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001946 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 },
1948 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001949 .procname = "overflowuid",
1950 .data = &fs_overflowuid,
1951 .maxlen = sizeof(int),
1952 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001953 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954 .extra1 = &minolduid,
1955 .extra2 = &maxolduid,
1956 },
1957 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958 .procname = "overflowgid",
1959 .data = &fs_overflowgid,
1960 .maxlen = sizeof(int),
1961 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001962 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963 .extra1 = &minolduid,
1964 .extra2 = &maxolduid,
1965 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001966#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001967 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968 .procname = "leases-enable",
1969 .data = &leases_enable,
1970 .maxlen = sizeof(int),
1971 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001972 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001974#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975#ifdef CONFIG_DNOTIFY
1976 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977 .procname = "dir-notify-enable",
1978 .data = &dir_notify_enable,
1979 .maxlen = sizeof(int),
1980 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001981 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001982 },
1983#endif
1984#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001985#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987 .procname = "lease-break-time",
1988 .data = &lease_break_time,
1989 .maxlen = sizeof(int),
1990 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001991 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001992 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001993#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001994#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001995 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001996 .procname = "aio-nr",
1997 .data = &aio_nr,
1998 .maxlen = sizeof(aio_nr),
1999 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08002000 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002001 },
2002 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002003 .procname = "aio-max-nr",
2004 .data = &aio_max_nr,
2005 .maxlen = sizeof(aio_max_nr),
2006 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08002007 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002008 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07002009#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07002010#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04002011 {
Robert Love0399cb02005-07-13 12:38:18 -04002012 .procname = "inotify",
2013 .mode = 0555,
2014 .child = inotify_table,
2015 },
2016#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08002017#ifdef CONFIG_EPOLL
2018 {
2019 .procname = "epoll",
2020 .mode = 0555,
2021 .child = epoll_table,
2022 },
2023#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002024#endif
Alan Coxd6e71142005-06-23 00:09:43 -07002025 {
Kees Cook800179c2012-07-25 17:29:07 -07002026 .procname = "protected_symlinks",
2027 .data = &sysctl_protected_symlinks,
2028 .maxlen = sizeof(int),
2029 .mode = 0600,
2030 .proc_handler = proc_dointvec_minmax,
2031 .extra1 = &zero,
2032 .extra2 = &one,
2033 },
2034 {
2035 .procname = "protected_hardlinks",
2036 .data = &sysctl_protected_hardlinks,
2037 .maxlen = sizeof(int),
2038 .mode = 0600,
2039 .proc_handler = proc_dointvec_minmax,
2040 .extra1 = &zero,
2041 .extra2 = &one,
2042 },
2043 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07002044 .procname = "protected_fifos",
2045 .data = &sysctl_protected_fifos,
2046 .maxlen = sizeof(int),
2047 .mode = 0600,
2048 .proc_handler = proc_dointvec_minmax,
2049 .extra1 = &zero,
2050 .extra2 = &two,
2051 },
2052 {
2053 .procname = "protected_regular",
2054 .data = &sysctl_protected_regular,
2055 .maxlen = sizeof(int),
2056 .mode = 0600,
2057 .proc_handler = proc_dointvec_minmax,
2058 .extra1 = &zero,
2059 .extra2 = &two,
2060 },
2061 {
Alan Coxd6e71142005-06-23 00:09:43 -07002062 .procname = "suid_dumpable",
2063 .data = &suid_dumpable,
2064 .maxlen = sizeof(int),
2065 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07002066 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07002067 .extra1 = &zero,
2068 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07002069 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002070#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
2071 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002072 .procname = "binfmt_misc",
2073 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05002074 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002075 },
2076#endif
Jens Axboeb492e952010-05-19 21:03:16 +02002077 {
Jens Axboeff9da692010-06-03 14:54:39 +02002078 .procname = "pipe-max-size",
2079 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002080 .maxlen = sizeof(int),
2081 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02002082 .proc_handler = &pipe_proc_fn,
2083 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002084 },
Willy Tarreau759c0112016-01-18 16:36:09 +01002085 {
2086 .procname = "pipe-user-pages-hard",
2087 .data = &pipe_user_pages_hard,
2088 .maxlen = sizeof(pipe_user_pages_hard),
2089 .mode = 0644,
2090 .proc_handler = proc_doulongvec_minmax,
2091 },
2092 {
2093 .procname = "pipe-user-pages-soft",
2094 .data = &pipe_user_pages_soft,
2095 .maxlen = sizeof(pipe_user_pages_soft),
2096 .mode = 0644,
2097 .proc_handler = proc_doulongvec_minmax,
2098 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05002099 {
2100 .procname = "mount-max",
2101 .data = &sysctl_mount_max,
2102 .maxlen = sizeof(unsigned int),
2103 .mode = 0644,
2104 .proc_handler = proc_dointvec_minmax,
2105 .extra1 = &one,
2106 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002107 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108};
2109
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002110static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07002111#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002112 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002113 .procname = "exception-trace",
2114 .data = &show_unhandled_signals,
2115 .maxlen = sizeof(int),
2116 .mode = 0644,
2117 .proc_handler = proc_dointvec
2118 },
2119#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002120#if defined(CONFIG_OPTPROBES)
2121 {
2122 .procname = "kprobes-optimization",
2123 .data = &sysctl_kprobes_optimization,
2124 .maxlen = sizeof(int),
2125 .mode = 0644,
2126 .proc_handler = proc_kprobes_optimization_handler,
2127 .extra1 = &zero,
2128 .extra2 = &one,
2129 },
2130#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002131 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002132};
2133
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002134static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002135 { }
Robert Love0eeca282005-07-12 17:06:03 -04002136};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002138int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002139{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002140 struct ctl_table_header *hdr;
2141
2142 hdr = register_sysctl_table(sysctl_base_table);
2143 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002144 return 0;
2145}
2146
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002147#endif /* CONFIG_SYSCTL */
2148
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149/*
2150 * /proc/sys support
2151 */
2152
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002153#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154
Kees Cookf8808302014-06-06 14:37:17 -07002155static int _proc_do_string(char *data, int maxlen, int write,
2156 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002157 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002158{
2159 size_t len;
2160 char __user *p;
2161 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002162
2163 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002164 *lenp = 0;
2165 return 0;
2166 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002167
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002168 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002169 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2170 /* Only continue writes not past the end of buffer. */
2171 len = strlen(data);
2172 if (len > maxlen - 1)
2173 len = maxlen - 1;
2174
2175 if (*ppos > len)
2176 return 0;
2177 len = *ppos;
2178 } else {
2179 /* Start writing from beginning of buffer. */
2180 len = 0;
2181 }
2182
Kees Cook2ca9bb42014-06-06 14:37:18 -07002183 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002184 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002185 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002186 if (get_user(c, p++))
2187 return -EFAULT;
2188 if (c == 0 || c == '\n')
2189 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002190 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002191 }
Kees Cookf8808302014-06-06 14:37:17 -07002192 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002193 } else {
2194 len = strlen(data);
2195 if (len > maxlen)
2196 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002197
2198 if (*ppos > len) {
2199 *lenp = 0;
2200 return 0;
2201 }
2202
2203 data += *ppos;
2204 len -= *ppos;
2205
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002206 if (len > *lenp)
2207 len = *lenp;
2208 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002209 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002210 return -EFAULT;
2211 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002212 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002213 return -EFAULT;
2214 len++;
2215 }
2216 *lenp = len;
2217 *ppos += len;
2218 }
2219 return 0;
2220}
2221
Kees Cookf4aacea2014-06-06 14:37:19 -07002222static void warn_sysctl_write(struct ctl_table *table)
2223{
2224 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2225 "This will not be supported in the future. To silence this\n"
2226 "warning, set kernel.sysctl_writes_strict = -1\n",
2227 current->comm, table->procname);
2228}
2229
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230/**
2231 * proc_dostring - read a string sysctl
2232 * @table: the sysctl table
2233 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234 * @buffer: the user buffer
2235 * @lenp: the size of the user buffer
2236 * @ppos: file position
2237 *
2238 * Reads/writes a string from/to the user buffer. If the kernel
2239 * buffer provided is not large enough to hold the string, the
2240 * string is truncated. The copied string is %NULL-terminated.
2241 * If the string is being read by the user process, it is copied
2242 * and a newline '\n' is added. It is truncated if the buffer is
2243 * not large enough.
2244 *
2245 * Returns 0 on success.
2246 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002247int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248 void __user *buffer, size_t *lenp, loff_t *ppos)
2249{
Kees Cookf4aacea2014-06-06 14:37:19 -07002250 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2251 warn_sysctl_write(table);
2252
Kees Cookf8808302014-06-06 14:37:17 -07002253 return _proc_do_string((char *)(table->data), table->maxlen, write,
2254 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255}
2256
Amerigo Wang00b7c332010-05-05 00:26:45 +00002257static size_t proc_skip_spaces(char **buf)
2258{
2259 size_t ret;
2260 char *tmp = skip_spaces(*buf);
2261 ret = tmp - *buf;
2262 *buf = tmp;
2263 return ret;
2264}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002266static void proc_skip_char(char **buf, size_t *size, const char v)
2267{
2268 while (*size) {
2269 if (**buf != v)
2270 break;
2271 (*size)--;
2272 (*buf)++;
2273 }
2274}
2275
Amerigo Wang00b7c332010-05-05 00:26:45 +00002276#define TMPBUFLEN 22
2277/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002278 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002279 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002280 * @buf: a kernel buffer
2281 * @size: size of the kernel buffer
2282 * @val: this is where the number will be stored
2283 * @neg: set to %TRUE if number is negative
2284 * @perm_tr: a vector which contains the allowed trailers
2285 * @perm_tr_len: size of the perm_tr vector
2286 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002287 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002288 * In case of success %0 is returned and @buf and @size are updated with
2289 * the amount of bytes read. If @tr is non-NULL and a trailing
2290 * character exists (size is non-zero after returning from this
2291 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002292 */
2293static int proc_get_long(char **buf, size_t *size,
2294 unsigned long *val, bool *neg,
2295 const char *perm_tr, unsigned perm_tr_len, char *tr)
2296{
2297 int len;
2298 char *p, tmp[TMPBUFLEN];
2299
2300 if (!*size)
2301 return -EINVAL;
2302
2303 len = *size;
2304 if (len > TMPBUFLEN - 1)
2305 len = TMPBUFLEN - 1;
2306
2307 memcpy(tmp, *buf, len);
2308
2309 tmp[len] = 0;
2310 p = tmp;
2311 if (*p == '-' && *size > 1) {
2312 *neg = true;
2313 p++;
2314 } else
2315 *neg = false;
2316 if (!isdigit(*p))
2317 return -EINVAL;
2318
2319 *val = simple_strtoul(p, &p, 0);
2320
2321 len = p - tmp;
2322
2323 /* We don't know if the next char is whitespace thus we may accept
2324 * invalid integers (e.g. 1234...a) or two integers instead of one
2325 * (e.g. 123...1). So lets not allow such large numbers. */
2326 if (len == TMPBUFLEN - 1)
2327 return -EINVAL;
2328
2329 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2330 return -EINVAL;
2331
2332 if (tr && (len < *size))
2333 *tr = *p;
2334
2335 *buf += len;
2336 *size -= len;
2337
2338 return 0;
2339}
2340
2341/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002342 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002343 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002344 * @buf: the user buffer
2345 * @size: the size of the user buffer
2346 * @val: the integer to be converted
2347 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002348 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002349 * In case of success %0 is returned and @buf and @size are updated with
2350 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002351 */
2352static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2353 bool neg)
2354{
2355 int len;
2356 char tmp[TMPBUFLEN], *p = tmp;
2357
2358 sprintf(p, "%s%lu", neg ? "-" : "", val);
2359 len = strlen(tmp);
2360 if (len > *size)
2361 len = *size;
2362 if (copy_to_user(*buf, tmp, len))
2363 return -EFAULT;
2364 *size -= len;
2365 *buf += len;
2366 return 0;
2367}
2368#undef TMPBUFLEN
2369
2370static int proc_put_char(void __user **buf, size_t *size, char c)
2371{
2372 if (*size) {
2373 char __user **buffer = (char __user **)buf;
2374 if (put_user(c, *buffer))
2375 return -EFAULT;
2376 (*size)--, (*buffer)++;
2377 *buf = *buffer;
2378 }
2379 return 0;
2380}
2381
2382static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 int *valp,
2384 int write, void *data)
2385{
2386 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002387 if (*negp) {
2388 if (*lvalp > (unsigned long) INT_MAX + 1)
2389 return -EINVAL;
2390 *valp = -*lvalp;
2391 } else {
2392 if (*lvalp > (unsigned long) INT_MAX)
2393 return -EINVAL;
2394 *valp = *lvalp;
2395 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 } else {
2397 int val = *valp;
2398 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002399 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002400 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002402 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 *lvalp = (unsigned long)val;
2404 }
2405 }
2406 return 0;
2407}
2408
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002409static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2410 int *valp,
2411 int write, void *data)
2412{
2413 if (write) {
2414 if (*negp)
2415 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002416 if (*lvalp > UINT_MAX)
2417 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002418 *valp = *lvalp;
2419 } else {
2420 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002421 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002422 *lvalp = (unsigned long)val;
2423 }
2424 return 0;
2425}
2426
Amerigo Wang00b7c332010-05-05 00:26:45 +00002427static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2428
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002429static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002430 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002431 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002432 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 int write, void *data),
2434 void *data)
2435{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002436 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002437 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002438 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439
Amerigo Wang00b7c332010-05-05 00:26:45 +00002440 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441 *lenp = 0;
2442 return 0;
2443 }
2444
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002445 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002446 vleft = table->maxlen / sizeof(*i);
2447 left = *lenp;
2448
2449 if (!conv)
2450 conv = do_proc_dointvec_conv;
2451
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002453 if (*ppos) {
2454 switch (sysctl_writes_strict) {
2455 case SYSCTL_WRITES_STRICT:
2456 goto out;
2457 case SYSCTL_WRITES_WARN:
2458 warn_sysctl_write(table);
2459 break;
2460 default:
2461 break;
2462 }
2463 }
2464
Amerigo Wang00b7c332010-05-05 00:26:45 +00002465 if (left > PAGE_SIZE - 1)
2466 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002467 p = kbuf = memdup_user_nul(buffer, left);
2468 if (IS_ERR(kbuf))
2469 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002470 }
2471
2472 for (; left && vleft--; i++, first=0) {
2473 unsigned long lval;
2474 bool neg;
2475
2476 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002477 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002478
J. R. Okajima563b0462010-05-25 16:10:14 -07002479 if (!left)
2480 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002481 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002482 proc_wspace_sep,
2483 sizeof(proc_wspace_sep), NULL);
2484 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002486 if (conv(&neg, &lval, i, 1, data)) {
2487 err = -EINVAL;
2488 break;
2489 }
2490 } else {
2491 if (conv(&neg, &lval, i, 0, data)) {
2492 err = -EINVAL;
2493 break;
2494 }
2495 if (!first)
2496 err = proc_put_char(&buffer, &left, '\t');
2497 if (err)
2498 break;
2499 err = proc_put_long(&buffer, &left, lval, neg);
2500 if (err)
2501 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502 }
2503 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002504
2505 if (!write && !first && left && !err)
2506 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002507 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002508 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002509 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002510 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002511 if (first)
2512 return err ? : -EINVAL;
2513 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002515out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002517 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002518}
2519
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002520static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002521 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002522 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002523 int write, void *data),
2524 void *data)
2525{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002526 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002527 buffer, lenp, ppos, conv, data);
2528}
2529
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530/**
2531 * proc_dointvec - read a vector of integers
2532 * @table: the sysctl table
2533 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534 * @buffer: the user buffer
2535 * @lenp: the size of the user buffer
2536 * @ppos: file position
2537 *
2538 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2539 * values from/to the user buffer, treated as an ASCII string.
2540 *
2541 * Returns 0 on success.
2542 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002543int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544 void __user *buffer, size_t *lenp, loff_t *ppos)
2545{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002546 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2547}
2548
2549/**
2550 * proc_douintvec - read a vector of unsigned integers
2551 * @table: the sysctl table
2552 * @write: %TRUE if this is a write to the sysctl file
2553 * @buffer: the user buffer
2554 * @lenp: the size of the user buffer
2555 * @ppos: file position
2556 *
2557 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2558 * values from/to the user buffer, treated as an ASCII string.
2559 *
2560 * Returns 0 on success.
2561 */
2562int proc_douintvec(struct ctl_table *table, int write,
2563 void __user *buffer, size_t *lenp, loff_t *ppos)
2564{
2565 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2566 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567}
2568
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002569/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002570 * Taint values can only be increased
2571 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002572 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002573static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002574 void __user *buffer, size_t *lenp, loff_t *ppos)
2575{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002576 struct ctl_table t;
2577 unsigned long tmptaint = get_taint();
2578 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002579
Bastian Blank91fcd412007-04-23 14:41:14 -07002580 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002581 return -EPERM;
2582
Andi Kleen25ddbb12008-10-15 22:01:41 -07002583 t = *table;
2584 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002585 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002586 if (err < 0)
2587 return err;
2588
2589 if (write) {
2590 /*
2591 * Poor man's atomic or. Not worth adding a primitive
2592 * to everyone's atomic.h for this
2593 */
2594 int i;
2595 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2596 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302597 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002598 }
2599 }
2600
2601 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002602}
2603
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002604#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002605static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002606 void __user *buffer, size_t *lenp, loff_t *ppos)
2607{
2608 if (write && !capable(CAP_SYS_ADMIN))
2609 return -EPERM;
2610
2611 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2612}
2613#endif
2614
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615struct do_proc_dointvec_minmax_conv_param {
2616 int *min;
2617 int *max;
2618};
2619
Amerigo Wang00b7c332010-05-05 00:26:45 +00002620static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2621 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 int write, void *data)
2623{
2624 struct do_proc_dointvec_minmax_conv_param *param = data;
2625 if (write) {
Zev Weiss45a67f12019-03-11 23:28:02 -07002626 int val;
2627 if (*negp) {
2628 if (*lvalp > (unsigned long) INT_MAX + 1)
2629 return -EINVAL;
2630 val = -*lvalp;
2631 } else {
2632 if (*lvalp > (unsigned long) INT_MAX)
2633 return -EINVAL;
2634 val = *lvalp;
2635 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002636 if ((param->min && *param->min > val) ||
2637 (param->max && *param->max < val))
2638 return -EINVAL;
2639 *valp = val;
2640 } else {
2641 int val = *valp;
2642 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002643 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002644 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002646 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647 *lvalp = (unsigned long)val;
2648 }
2649 }
2650 return 0;
2651}
2652
2653/**
2654 * proc_dointvec_minmax - read a vector of integers with min/max values
2655 * @table: the sysctl table
2656 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 * @buffer: the user buffer
2658 * @lenp: the size of the user buffer
2659 * @ppos: file position
2660 *
2661 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2662 * values from/to the user buffer, treated as an ASCII string.
2663 *
2664 * This routine will ensure the values are within the range specified by
2665 * table->extra1 (min) and table->extra2 (max).
2666 *
2667 * Returns 0 on success.
2668 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002669int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 void __user *buffer, size_t *lenp, loff_t *ppos)
2671{
2672 struct do_proc_dointvec_minmax_conv_param param = {
2673 .min = (int *) table->extra1,
2674 .max = (int *) table->extra2,
2675 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002676 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 do_proc_dointvec_minmax_conv, &param);
2678}
2679
Kees Cook54b50192012-07-30 14:39:18 -07002680static void validate_coredump_safety(void)
2681{
Alex Kelly046d6622012-10-04 17:15:23 -07002682#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002683 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002684 core_pattern[0] != '/' && core_pattern[0] != '|') {
2685 printk(KERN_WARNING "Unsafe core_pattern used with "\
2686 "suid_dumpable=2. Pipe handler or fully qualified "\
2687 "core dump path required.\n");
2688 }
Alex Kelly046d6622012-10-04 17:15:23 -07002689#endif
Kees Cook54b50192012-07-30 14:39:18 -07002690}
2691
2692static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2693 void __user *buffer, size_t *lenp, loff_t *ppos)
2694{
2695 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2696 if (!error)
2697 validate_coredump_safety();
2698 return error;
2699}
2700
Alex Kelly046d6622012-10-04 17:15:23 -07002701#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002702static int proc_dostring_coredump(struct ctl_table *table, int write,
2703 void __user *buffer, size_t *lenp, loff_t *ppos)
2704{
2705 int error = proc_dostring(table, write, buffer, lenp, ppos);
2706 if (!error)
2707 validate_coredump_safety();
2708 return error;
2709}
Alex Kelly046d6622012-10-04 17:15:23 -07002710#endif
Kees Cook54b50192012-07-30 14:39:18 -07002711
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002712static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713 void __user *buffer,
2714 size_t *lenp, loff_t *ppos,
2715 unsigned long convmul,
2716 unsigned long convdiv)
2717{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002718 unsigned long *i, *min, *max;
2719 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002720 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002721 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002722
2723 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002724 *lenp = 0;
2725 return 0;
2726 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002727
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002728 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002729 min = (unsigned long *) table->extra1;
2730 max = (unsigned long *) table->extra2;
2731 vleft = table->maxlen / sizeof(unsigned long);
2732 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002733
2734 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002735 if (*ppos) {
2736 switch (sysctl_writes_strict) {
2737 case SYSCTL_WRITES_STRICT:
2738 goto out;
2739 case SYSCTL_WRITES_WARN:
2740 warn_sysctl_write(table);
2741 break;
2742 default:
2743 break;
2744 }
2745 }
2746
Amerigo Wang00b7c332010-05-05 00:26:45 +00002747 if (left > PAGE_SIZE - 1)
2748 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002749 p = kbuf = memdup_user_nul(buffer, left);
2750 if (IS_ERR(kbuf))
2751 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002752 }
2753
Eric Dumazet27b3d802010-10-07 12:59:29 -07002754 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002755 unsigned long val;
2756
Linus Torvalds1da177e2005-04-16 15:20:36 -07002757 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002758 bool neg;
2759
Al Viro70f6cbb2015-12-24 00:13:10 -05002760 left -= proc_skip_spaces(&p);
Cheng Lin0e5c7502019-01-03 15:26:13 -08002761 if (!left)
2762 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002763
Al Viro70f6cbb2015-12-24 00:13:10 -05002764 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002765 proc_wspace_sep,
2766 sizeof(proc_wspace_sep), NULL);
2767 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768 break;
2769 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002770 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002771 val = convmul * val / convdiv;
Christian Brauner726f69d2019-05-14 15:44:55 -07002772 if ((min && val < *min) || (max && val > *max)) {
2773 err = -EINVAL;
2774 break;
2775 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002776 *i = val;
2777 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002778 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002779 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002780 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002781 if (err)
2782 break;
2783 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002784 err = proc_put_long(&buffer, &left, val, false);
2785 if (err)
2786 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002787 }
2788 }
2789
Amerigo Wang00b7c332010-05-05 00:26:45 +00002790 if (!write && !first && left && !err)
2791 err = proc_put_char(&buffer, &left, '\n');
2792 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002793 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002794 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002795 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002796 if (first)
2797 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002798 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002799 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002800out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002801 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002802 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002803}
2804
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002805static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002806 void __user *buffer,
2807 size_t *lenp, loff_t *ppos,
2808 unsigned long convmul,
2809 unsigned long convdiv)
2810{
2811 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002812 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002813}
2814
Linus Torvalds1da177e2005-04-16 15:20:36 -07002815/**
2816 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2817 * @table: the sysctl table
2818 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002819 * @buffer: the user buffer
2820 * @lenp: the size of the user buffer
2821 * @ppos: file position
2822 *
2823 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2824 * values from/to the user buffer, treated as an ASCII string.
2825 *
2826 * This routine will ensure the values are within the range specified by
2827 * table->extra1 (min) and table->extra2 (max).
2828 *
2829 * Returns 0 on success.
2830 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002831int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002832 void __user *buffer, size_t *lenp, loff_t *ppos)
2833{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002834 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002835}
2836
2837/**
2838 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2839 * @table: the sysctl table
2840 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002841 * @buffer: the user buffer
2842 * @lenp: the size of the user buffer
2843 * @ppos: file position
2844 *
2845 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2846 * values from/to the user buffer, treated as an ASCII string. The values
2847 * are treated as milliseconds, and converted to jiffies when they are stored.
2848 *
2849 * This routine will ensure the values are within the range specified by
2850 * table->extra1 (min) and table->extra2 (max).
2851 *
2852 * Returns 0 on success.
2853 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002854int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002855 void __user *buffer,
2856 size_t *lenp, loff_t *ppos)
2857{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002858 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002859 lenp, ppos, HZ, 1000l);
2860}
2861
2862
Amerigo Wang00b7c332010-05-05 00:26:45 +00002863static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864 int *valp,
2865 int write, void *data)
2866{
2867 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002868 if (*lvalp > LONG_MAX / HZ)
2869 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002870 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2871 } else {
2872 int val = *valp;
2873 unsigned long lval;
2874 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002875 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002876 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002877 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002878 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002879 lval = (unsigned long)val;
2880 }
2881 *lvalp = lval / HZ;
2882 }
2883 return 0;
2884}
2885
Amerigo Wang00b7c332010-05-05 00:26:45 +00002886static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002887 int *valp,
2888 int write, void *data)
2889{
2890 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002891 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2892 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002893 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2894 } else {
2895 int val = *valp;
2896 unsigned long lval;
2897 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002898 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002899 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002900 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002901 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002902 lval = (unsigned long)val;
2903 }
2904 *lvalp = jiffies_to_clock_t(lval);
2905 }
2906 return 0;
2907}
2908
Amerigo Wang00b7c332010-05-05 00:26:45 +00002909static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002910 int *valp,
2911 int write, void *data)
2912{
2913 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002914 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2915
2916 if (jif > INT_MAX)
2917 return 1;
2918 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002919 } else {
2920 int val = *valp;
2921 unsigned long lval;
2922 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002923 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002924 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002925 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002926 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002927 lval = (unsigned long)val;
2928 }
2929 *lvalp = jiffies_to_msecs(lval);
2930 }
2931 return 0;
2932}
2933
2934/**
2935 * proc_dointvec_jiffies - read a vector of integers as seconds
2936 * @table: the sysctl table
2937 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938 * @buffer: the user buffer
2939 * @lenp: the size of the user buffer
2940 * @ppos: file position
2941 *
2942 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2943 * values from/to the user buffer, treated as an ASCII string.
2944 * The values read are assumed to be in seconds, and are converted into
2945 * jiffies.
2946 *
2947 * Returns 0 on success.
2948 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002949int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950 void __user *buffer, size_t *lenp, loff_t *ppos)
2951{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002952 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953 do_proc_dointvec_jiffies_conv,NULL);
2954}
2955
2956/**
2957 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2958 * @table: the sysctl table
2959 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002960 * @buffer: the user buffer
2961 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002962 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002963 *
2964 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2965 * values from/to the user buffer, treated as an ASCII string.
2966 * The values read are assumed to be in 1/USER_HZ seconds, and
2967 * are converted into jiffies.
2968 *
2969 * Returns 0 on success.
2970 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002971int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 void __user *buffer, size_t *lenp, loff_t *ppos)
2973{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002974 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002975 do_proc_dointvec_userhz_jiffies_conv,NULL);
2976}
2977
2978/**
2979 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2980 * @table: the sysctl table
2981 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982 * @buffer: the user buffer
2983 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002984 * @ppos: file position
2985 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002986 *
2987 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2988 * values from/to the user buffer, treated as an ASCII string.
2989 * The values read are assumed to be in 1/1000 seconds, and
2990 * are converted into jiffies.
2991 *
2992 * Returns 0 on success.
2993 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002994int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002995 void __user *buffer, size_t *lenp, loff_t *ppos)
2996{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002997 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002998 do_proc_dointvec_ms_jiffies_conv, NULL);
2999}
3000
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003001static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003002 void __user *buffer, size_t *lenp, loff_t *ppos)
3003{
3004 struct pid *new_pid;
3005 pid_t tmp;
3006 int r;
3007
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08003008 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003009
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003010 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003011 lenp, ppos, NULL, NULL);
3012 if (r || !write)
3013 return r;
3014
3015 new_pid = find_get_pid(tmp);
3016 if (!new_pid)
3017 return -ESRCH;
3018
3019 put_pid(xchg(&cad_pid, new_pid));
3020 return 0;
3021}
3022
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003023/**
3024 * proc_do_large_bitmap - read/write from/to a large bitmap
3025 * @table: the sysctl table
3026 * @write: %TRUE if this is a write to the sysctl file
3027 * @buffer: the user buffer
3028 * @lenp: the size of the user buffer
3029 * @ppos: file position
3030 *
3031 * The bitmap is stored at table->data and the bitmap length (in bits)
3032 * in table->maxlen.
3033 *
3034 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3035 * large bitmaps may be represented in a compact manner. Writing into
3036 * the file will clear the bitmap then update it with the given input.
3037 *
3038 * Returns 0 on success.
3039 */
3040int proc_do_large_bitmap(struct ctl_table *table, int write,
3041 void __user *buffer, size_t *lenp, loff_t *ppos)
3042{
3043 int err = 0;
3044 bool first = 1;
3045 size_t left = *lenp;
3046 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07003047 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003048 unsigned long *tmp_bitmap = NULL;
3049 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3050
WANG Cong122ff242014-05-12 16:04:53 -07003051 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003052 *lenp = 0;
3053 return 0;
3054 }
3055
3056 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003057 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003058
3059 if (left > PAGE_SIZE - 1)
3060 left = PAGE_SIZE - 1;
3061
Al Viro70f6cbb2015-12-24 00:13:10 -05003062 p = kbuf = memdup_user_nul(buffer, left);
3063 if (IS_ERR(kbuf))
3064 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003065
3066 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
3067 GFP_KERNEL);
3068 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003069 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003070 return -ENOMEM;
3071 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003072 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003073 while (!err && left) {
3074 unsigned long val_a, val_b;
3075 bool neg;
3076
Al Viro70f6cbb2015-12-24 00:13:10 -05003077 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003078 sizeof(tr_a), &c);
3079 if (err)
3080 break;
3081 if (val_a >= bitmap_len || neg) {
3082 err = -EINVAL;
3083 break;
3084 }
3085
3086 val_b = val_a;
3087 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003088 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003089 left--;
3090 }
3091
3092 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05003093 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003094 &neg, tr_b, sizeof(tr_b),
3095 &c);
3096 if (err)
3097 break;
3098 if (val_b >= bitmap_len || neg ||
3099 val_a > val_b) {
3100 err = -EINVAL;
3101 break;
3102 }
3103 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003104 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003105 left--;
3106 }
3107 }
3108
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003109 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003110 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003111 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003112 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003113 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003114 } else {
3115 unsigned long bit_a, bit_b = 0;
3116
3117 while (left) {
3118 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3119 if (bit_a >= bitmap_len)
3120 break;
3121 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3122 bit_a + 1) - 1;
3123
3124 if (!first) {
3125 err = proc_put_char(&buffer, &left, ',');
3126 if (err)
3127 break;
3128 }
3129 err = proc_put_long(&buffer, &left, bit_a, false);
3130 if (err)
3131 break;
3132 if (bit_a != bit_b) {
3133 err = proc_put_char(&buffer, &left, '-');
3134 if (err)
3135 break;
3136 err = proc_put_long(&buffer, &left, bit_b, false);
3137 if (err)
3138 break;
3139 }
3140
3141 first = 0; bit_b++;
3142 }
3143 if (!err)
3144 err = proc_put_char(&buffer, &left, '\n');
3145 }
3146
3147 if (!err) {
3148 if (write) {
3149 if (*ppos)
3150 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3151 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003152 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003153 }
3154 kfree(tmp_bitmap);
3155 *lenp -= left;
3156 *ppos += *lenp;
3157 return 0;
3158 } else {
3159 kfree(tmp_bitmap);
3160 return err;
3161 }
3162}
3163
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003164static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp,
3165 int *valp, int write, void *data)
3166{
3167 if (write) {
Satya Durga Srinivasu Prabhala3929bf02018-08-24 12:23:08 -07003168 if (*negp || *lvalp == 0)
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003169 return -EINVAL;
3170 *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp;
3171 } else {
3172 *negp = false;
3173 *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp;
3174 }
3175
3176 return 0;
3177}
3178
3179/**
3180 * proc_douintvec_capacity - read a vector of integers in percentage and convert
3181 * into sched capacity
3182 * @table: the sysctl table
3183 * @write: %TRUE if this is a write to the sysctl file
3184 * @buffer: the user buffer
3185 * @lenp: the size of the user buffer
3186 * @ppos: file position
3187 *
3188 * Returns 0 on success.
3189 */
3190int proc_douintvec_capacity(struct ctl_table *table, int write,
3191 void __user *buffer, size_t *lenp, loff_t *ppos)
3192{
3193 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3194 do_proc_douintvec_capacity_conv, NULL);
3195}
3196
Jovi Zhang55610502011-01-12 17:00:45 -08003197#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003198
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003199int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003200 void __user *buffer, size_t *lenp, loff_t *ppos)
3201{
3202 return -ENOSYS;
3203}
3204
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003205int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003206 void __user *buffer, size_t *lenp, loff_t *ppos)
3207{
3208 return -ENOSYS;
3209}
3210
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003211int proc_douintvec(struct ctl_table *table, int write,
3212 void __user *buffer, size_t *lenp, loff_t *ppos)
3213{
3214 return -ENOSYS;
3215}
3216
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003217int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003218 void __user *buffer, size_t *lenp, loff_t *ppos)
3219{
3220 return -ENOSYS;
3221}
3222
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003223int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003224 void __user *buffer, size_t *lenp, loff_t *ppos)
3225{
3226 return -ENOSYS;
3227}
3228
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003229int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003230 void __user *buffer, size_t *lenp, loff_t *ppos)
3231{
3232 return -ENOSYS;
3233}
3234
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003235int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003236 void __user *buffer, size_t *lenp, loff_t *ppos)
3237{
3238 return -ENOSYS;
3239}
3240
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003241int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003242 void __user *buffer, size_t *lenp, loff_t *ppos)
3243{
3244 return -ENOSYS;
3245}
3246
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003247int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003248 void __user *buffer,
3249 size_t *lenp, loff_t *ppos)
3250{
3251 return -ENOSYS;
3252}
3253
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003254int proc_douintvec_capacity(struct ctl_table *table, int write,
3255 void __user *buffer, size_t *lenp, loff_t *ppos)
3256{
3257 return -ENOSYS;
3258}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003259
Jovi Zhang55610502011-01-12 17:00:45 -08003260#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003261
Linus Torvalds1da177e2005-04-16 15:20:36 -07003262/*
3263 * No sense putting this after each symbol definition, twice,
3264 * exception granted :-)
3265 */
3266EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003267EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003268EXPORT_SYMBOL(proc_dointvec_jiffies);
3269EXPORT_SYMBOL(proc_dointvec_minmax);
3270EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3271EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3272EXPORT_SYMBOL(proc_dostring);
3273EXPORT_SYMBOL(proc_doulongvec_minmax);
3274EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);