blob: 6efdb67d6db72e47b443bc05cb27d01976617af0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080022#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070027#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080028#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080029#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070031#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020033#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080066#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070067#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050068#include <linux/mount.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#include <asm/uaccess.h>
71#include <asm/processor.h>
72
Andi Kleen29cbc782006-09-30 01:47:55 +020073#ifdef CONFIG_X86
74#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010075#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010076#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020077#endif
David Howellsd550bbd2012-03-28 18:30:03 +010078#ifdef CONFIG_SPARC
79#include <asm/setup.h>
80#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080081#ifdef CONFIG_BSD_PROCESS_ACCT
82#include <linux/acct.h>
83#endif
Dave Young4f0e0562010-03-10 15:24:09 -080084#ifdef CONFIG_RT_MUTEXES
85#include <linux/rtmutex.h>
86#endif
Dave Young2edf5e42010-03-10 15:24:10 -080087#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88#include <linux/lockdep.h>
89#endif
Dave Young15485a42010-03-10 15:24:07 -080090#ifdef CONFIG_CHR_DEV_SG
91#include <scsi/sg.h>
92#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020093
Don Zickus58687ac2010-05-07 17:11:44 -040094#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050095#include <linux/nmi.h>
96#endif
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#if defined(CONFIG_SYSCTL)
99
100/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300111extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400117#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118static int sixty = 60;
119#endif
120
Aaron Tomlin270750db2014-01-20 17:34:13 +0000121static int __maybe_unused neg_one = -1;
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700126static int __maybe_unused three = 3;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700127static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800128static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129static int one_hundred = 100;
Rik van Riel12462752011-09-01 15:26:50 -0400130#ifdef CONFIG_PERF_EVENTS
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700131static int one_thousand = 1000;
Rik van Riel12462752011-09-01 15:26:50 -0400132#endif
Dave Youngaf913222009-09-22 16:43:33 -0700133#ifdef CONFIG_PRINTK
134static int ten_thousand = 10000;
135#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300136#ifdef CONFIG_PERF_EVENTS
137static int six_hundred_forty_kb = 640 * 1024;
138#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700139
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700140/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
141static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
144static int maxolduid = 65535;
145static int minolduid;
146
147static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700148static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Liu Hua80df2842014-04-07 15:38:57 -0700150/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
151#ifdef CONFIG_DETECT_HUNG_TASK
152static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
153#endif
154
Dave Youngd14f1722010-02-25 20:28:57 -0500155#ifdef CONFIG_INOTIFY_USER
156#include <linux/inotify.h>
157#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700158#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#endif
160
161#ifdef __hppa__
162extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530163#endif
164
165#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166extern int unaligned_enabled;
167#endif
168
Jes Sorensend2b176e2006-02-28 09:42:23 -0800169#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800170extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800171#endif
172
Vineet Guptab6fca722013-01-09 20:06:28 +0530173#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
174extern int no_unaligned_warning;
175#endif
176
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700177#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700178
179#define SYSCTL_WRITES_LEGACY -1
180#define SYSCTL_WRITES_WARN 0
181#define SYSCTL_WRITES_STRICT 1
182
Kees Cook41662f52016-01-20 15:00:45 -0800183static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700184
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700185static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700186 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700187static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800188 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700189#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700190
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700191#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700192static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700193 void __user *buffer, size_t *lenp, loff_t *ppos);
194#endif
195
Kees Cook54b50192012-07-30 14:39:18 -0700196static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
197 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700198#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700199static int proc_dostring_coredump(struct ctl_table *table, int write,
200 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700201#endif
Kees Cook54b50192012-07-30 14:39:18 -0700202
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700203#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800204/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100205static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700206
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700207static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700208 void __user *buffer, size_t *lenp,
209 loff_t *ppos)
210{
211 int error;
212
213 error = proc_dointvec(table, write, buffer, lenp, ppos);
214 if (error)
215 return error;
216
217 if (write)
218 sysrq_toggle_support(__sysrq_enabled);
219
220 return 0;
221}
222
223#endif
224
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700225static struct ctl_table kern_table[];
226static struct ctl_table vm_table[];
227static struct ctl_table fs_table[];
228static struct ctl_table debug_table[];
229static struct ctl_table dev_table[];
230extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800231#ifdef CONFIG_EPOLL
232extern struct ctl_table epoll_table[];
233#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
235#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
236int sysctl_legacy_va_layout;
237#endif
238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239/* The default sysctl tables: */
240
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800241static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .procname = "kernel",
244 .mode = 0555,
245 .child = kern_table,
246 },
247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .procname = "vm",
249 .mode = 0555,
250 .child = vm_table,
251 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 .procname = "fs",
254 .mode = 0555,
255 .child = fs_table,
256 },
257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 .procname = "debug",
259 .mode = 0555,
260 .child = debug_table,
261 },
262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 .procname = "dev",
264 .mode = 0555,
265 .child = dev_table,
266 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700267 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268};
269
Ingo Molnar77e54a12007-07-09 18:52:00 +0200270#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100271static int min_sched_granularity_ns = 100000; /* 100 usecs */
272static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
273static int min_wakeup_granularity_ns; /* 0 usecs */
274static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200275#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100276static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
277static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200278#endif /* CONFIG_SMP */
279#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200280
Mel Gorman5e771902010-05-24 14:32:31 -0700281#ifdef CONFIG_COMPACTION
282static int min_extfrag_threshold;
283static int max_extfrag_threshold = 1000;
284#endif
285
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700286static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200287 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200288 .procname = "sched_child_runs_first",
289 .data = &sysctl_sched_child_runs_first,
290 .maxlen = sizeof(unsigned int),
291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800292 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200293 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530294#if defined(CONFIG_PREEMPT_TRACER) || defined(CONFIG_IRQSOFF_TRACER)
295 {
296 .procname = "preemptoff_tracing_threshold_ns",
297 .data = &sysctl_preemptoff_tracing_threshold_ns,
298 .maxlen = sizeof(unsigned int),
299 .mode = 0644,
300 .proc_handler = proc_dointvec,
301 },
Pavankumar Kondeti0d2621b2018-03-26 15:56:26 +0530302 {
303 .procname = "irqsoff_tracing_threshold_ns",
304 .data = &sysctl_irqsoff_tracing_threshold_ns,
305 .maxlen = sizeof(unsigned int),
306 .mode = 0644,
307 .proc_handler = proc_dointvec,
308 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530309#endif
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800310#ifdef CONFIG_SCHED_WALT
311 {
312 .procname = "sched_cpu_high_irqload",
313 .data = &sysctl_sched_cpu_high_irqload,
314 .maxlen = sizeof(unsigned int),
315 .mode = 0644,
316 .proc_handler = proc_dointvec,
317 },
Joonwoo Park6f188472017-06-16 11:32:17 -0700318 {
319 .procname = "sched_group_upmigrate",
320 .data = &sysctl_sched_group_upmigrate_pct,
321 .maxlen = sizeof(unsigned int),
322 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700323 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700324 .extra1 = &sysctl_sched_group_downmigrate_pct,
325 },
326 {
327 .procname = "sched_group_downmigrate",
328 .data = &sysctl_sched_group_downmigrate_pct,
329 .maxlen = sizeof(unsigned int),
330 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700331 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700332 .extra1 = &zero,
333 .extra2 = &sysctl_sched_group_upmigrate_pct,
334 },
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530335 {
336 .procname = "sched_boost",
337 .data = &sysctl_sched_boost,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
340 .proc_handler = sched_boost_handler,
341 .extra1 = &zero,
342 .extra2 = &three,
343 },
Pavankumar Kondeti4e13d112018-01-25 01:12:08 +0530344 {
345 .procname = "sched_walt_rotate_big_tasks",
346 .data = &sysctl_sched_walt_rotate_big_tasks,
347 .maxlen = sizeof(unsigned int),
348 .mode = 0644,
349 .proc_handler = proc_dointvec_minmax,
350 .extra1 = &zero,
351 .extra2 = &one,
352 },
Lingutla Chandrasekhar57eb0712018-03-12 10:20:08 +0530353 {
354 .procname = "sched_initial_task_util",
355 .data = &sysctl_sched_init_task_load_pct,
356 .maxlen = sizeof(unsigned int),
357 .mode = 0644,
358 .proc_handler = proc_dointvec,
359 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800360#endif
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530361 {
362 .procname = "sched_upmigrate",
363 .data = &sysctl_sched_capacity_margin,
364 .maxlen = sizeof(unsigned int),
365 .mode = 0644,
366 .proc_handler = sched_updown_migrate_handler,
367 },
368 {
369 .procname = "sched_downmigrate",
370 .data = &sysctl_sched_capacity_margin_down,
371 .maxlen = sizeof(unsigned int),
372 .mode = 0644,
373 .proc_handler = sched_updown_migrate_handler,
374 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200375#ifdef CONFIG_SCHED_DEBUG
376 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100377 .procname = "sched_min_granularity_ns",
378 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200379 .maxlen = sizeof(unsigned int),
380 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800381 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100382 .extra1 = &min_sched_granularity_ns,
383 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200384 },
385 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200386 .procname = "sched_latency_ns",
387 .data = &sysctl_sched_latency,
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800390 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200391 .extra1 = &min_sched_granularity_ns,
392 .extra2 = &max_sched_granularity_ns,
393 },
394 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000395 .procname = "sched_sync_hint_enable",
396 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100397 .maxlen = sizeof(unsigned int),
398 .mode = 0644,
399 .proc_handler = proc_dointvec,
400 },
401 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100402 .procname = "sched_cstate_aware",
403 .data = &sysctl_sched_cstate_aware,
404 .maxlen = sizeof(unsigned int),
405 .mode = 0644,
406 .proc_handler = proc_dointvec,
407 },
408 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200409 .procname = "sched_wakeup_granularity_ns",
410 .data = &sysctl_sched_wakeup_granularity,
411 .maxlen = sizeof(unsigned int),
412 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800413 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200414 .extra1 = &min_wakeup_granularity_ns,
415 .extra2 = &max_wakeup_granularity_ns,
416 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200417#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200418 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100419 .procname = "sched_tunable_scaling",
420 .data = &sysctl_sched_tunable_scaling,
421 .maxlen = sizeof(enum sched_tunable_scaling),
422 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800423 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100424 .extra1 = &min_sched_tunable_scaling,
425 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200426 },
427 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900428 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200429 .data = &sysctl_sched_migration_cost,
430 .maxlen = sizeof(unsigned int),
431 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800432 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200433 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100434 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100435 .procname = "sched_nr_migrate",
436 .data = &sysctl_sched_nr_migrate,
437 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100438 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800439 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100440 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530441 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900442 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200443 .data = &sysctl_sched_time_avg,
444 .maxlen = sizeof(unsigned int),
445 .mode = 0644,
Pavankumar Kondeti12939492017-02-02 14:24:34 +0530446 .proc_handler = proc_dointvec_minmax,
447 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200448 },
449 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900450 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800451 .data = &sysctl_sched_shares_window,
452 .maxlen = sizeof(unsigned int),
453 .mode = 0644,
454 .proc_handler = proc_dointvec,
455 },
Mel Gormancb251762016-02-05 09:08:36 +0000456#ifdef CONFIG_SCHEDSTATS
457 {
458 .procname = "sched_schedstats",
459 .data = NULL,
460 .maxlen = sizeof(unsigned int),
461 .mode = 0644,
462 .proc_handler = sysctl_schedstats,
463 .extra1 = &zero,
464 .extra2 = &one,
465 },
466#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200467#endif /* CONFIG_SMP */
468#ifdef CONFIG_NUMA_BALANCING
469 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200470 .procname = "numa_balancing_scan_delay_ms",
471 .data = &sysctl_numa_balancing_scan_delay,
472 .maxlen = sizeof(unsigned int),
473 .mode = 0644,
474 .proc_handler = proc_dointvec,
475 },
476 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200477 .procname = "numa_balancing_scan_period_min_ms",
478 .data = &sysctl_numa_balancing_scan_period_min,
479 .maxlen = sizeof(unsigned int),
480 .mode = 0644,
481 .proc_handler = proc_dointvec,
482 },
483 {
484 .procname = "numa_balancing_scan_period_max_ms",
485 .data = &sysctl_numa_balancing_scan_period_max,
486 .maxlen = sizeof(unsigned int),
487 .mode = 0644,
488 .proc_handler = proc_dointvec,
489 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200490 {
491 .procname = "numa_balancing_scan_size_mb",
492 .data = &sysctl_numa_balancing_scan_size,
493 .maxlen = sizeof(unsigned int),
494 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400495 .proc_handler = proc_dointvec_minmax,
496 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200497 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100498 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800499 .procname = "numa_balancing",
500 .data = NULL, /* filled in by handler */
501 .maxlen = sizeof(unsigned int),
502 .mode = 0644,
503 .proc_handler = sysctl_numa_balancing,
504 .extra1 = &zero,
505 .extra2 = &one,
506 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200507#endif /* CONFIG_NUMA_BALANCING */
508#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200509 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100510 .procname = "sched_rt_period_us",
511 .data = &sysctl_sched_rt_period,
512 .maxlen = sizeof(unsigned int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100515 },
516 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100517 .procname = "sched_rt_runtime_us",
518 .data = &sysctl_sched_rt_runtime,
519 .maxlen = sizeof(int),
520 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800521 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100522 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600523 {
524 .procname = "sched_rr_timeslice_ms",
525 .data = &sched_rr_timeslice,
526 .maxlen = sizeof(int),
527 .mode = 0644,
528 .proc_handler = sched_rr_handler,
529 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100530#ifdef CONFIG_SCHED_AUTOGROUP
531 {
532 .procname = "sched_autogroup_enabled",
533 .data = &sysctl_sched_autogroup_enabled,
534 .maxlen = sizeof(unsigned int),
535 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800536 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100537 .extra1 = &zero,
538 .extra2 = &one,
539 },
540#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700541#ifdef CONFIG_CFS_BANDWIDTH
542 {
543 .procname = "sched_cfs_bandwidth_slice_us",
544 .data = &sysctl_sched_cfs_bandwidth_slice,
545 .maxlen = sizeof(unsigned int),
546 .mode = 0644,
547 .proc_handler = proc_dointvec_minmax,
548 .extra1 = &one,
549 },
550#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100551#ifdef CONFIG_SCHED_TUNE
552 {
553 .procname = "sched_cfs_boost",
554 .data = &sysctl_sched_cfs_boost,
555 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100556#ifdef CONFIG_CGROUP_SCHEDTUNE
557 .mode = 0444,
558#else
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100559 .mode = 0644,
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100560#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100561 .proc_handler = &sysctl_sched_cfs_boost_handler,
562 .extra1 = &zero,
563 .extra2 = &one_hundred,
564 },
565#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700566#ifdef CONFIG_PROVE_LOCKING
567 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700568 .procname = "prove_locking",
569 .data = &prove_locking,
570 .maxlen = sizeof(int),
571 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800572 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700573 },
574#endif
575#ifdef CONFIG_LOCK_STAT
576 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700577 .procname = "lock_stat",
578 .data = &lock_stat,
579 .maxlen = sizeof(int),
580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700582 },
583#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200584 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 .procname = "panic",
586 .data = &panic_timeout,
587 .maxlen = sizeof(int),
588 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800589 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 },
Alex Kelly046d6622012-10-04 17:15:23 -0700591#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 .procname = "core_uses_pid",
594 .data = &core_uses_pid,
595 .maxlen = sizeof(int),
596 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800597 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 },
599 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 .procname = "core_pattern",
601 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700602 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700604 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 },
Neil Hormana2939802009-09-23 15:56:56 -0700606 {
Neil Hormana2939802009-09-23 15:56:56 -0700607 .procname = "core_pipe_limit",
608 .data = &core_pipe_limit,
609 .maxlen = sizeof(unsigned int),
610 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800611 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700612 },
Alex Kelly046d6622012-10-04 17:15:23 -0700613#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800614#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700617 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800618 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800619 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700621 {
622 .procname = "sysctl_writes_strict",
623 .data = &sysctl_writes_strict,
624 .maxlen = sizeof(int),
625 .mode = 0644,
626 .proc_handler = proc_dointvec_minmax,
627 .extra1 = &neg_one,
628 .extra2 = &one,
629 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800630#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100631#ifdef CONFIG_LATENCYTOP
632 {
633 .procname = "latencytop",
634 .data = &latencytop_enabled,
635 .maxlen = sizeof(int),
636 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000637 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100638 },
639#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640#ifdef CONFIG_BLK_DEV_INITRD
641 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .procname = "real-root-dev",
643 .data = &real_root_dev,
644 .maxlen = sizeof(int),
645 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800646 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 },
648#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700649 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700650 .procname = "print-fatal-signals",
651 .data = &print_fatal_signals,
652 .maxlen = sizeof(int),
653 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800654 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700655 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700656#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .procname = "reboot-cmd",
659 .data = reboot_command,
660 .maxlen = 256,
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 },
664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "stop-a",
666 .data = &stop_a_enabled,
667 .maxlen = sizeof (int),
668 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800669 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 },
671 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 .procname = "scons-poweroff",
673 .data = &scons_pwroff,
674 .maxlen = sizeof (int),
675 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800676 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 },
678#endif
David S. Miller08714202008-11-16 23:49:24 -0800679#ifdef CONFIG_SPARC64
680 {
David S. Miller08714202008-11-16 23:49:24 -0800681 .procname = "tsb-ratio",
682 .data = &sysctl_tsb_ratio,
683 .maxlen = sizeof (int),
684 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800685 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800686 },
687#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688#ifdef __hppa__
689 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 .procname = "soft-power",
691 .data = &pwrsw_enabled,
692 .maxlen = sizeof (int),
693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800694 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530696#endif
697#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 .procname = "unaligned-trap",
700 .data = &unaligned_enabled,
701 .maxlen = sizeof (int),
702 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800703 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 },
705#endif
706 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 .procname = "ctrl-alt-del",
708 .data = &C_A_D,
709 .maxlen = sizeof(int),
710 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800711 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400713#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200714 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200715 .procname = "ftrace_enabled",
716 .data = &ftrace_enabled,
717 .maxlen = sizeof(int),
718 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800719 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200720 },
721#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500722#ifdef CONFIG_STACK_TRACER
723 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500724 .procname = "stack_tracer_enabled",
725 .data = &stack_tracer_enabled,
726 .maxlen = sizeof(int),
727 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800728 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500729 },
730#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400731#ifdef CONFIG_TRACING
732 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100733 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400734 .data = &ftrace_dump_on_oops,
735 .maxlen = sizeof(int),
736 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800737 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400738 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400739 {
740 .procname = "traceoff_on_warning",
741 .data = &__disable_trace_on_warning,
742 .maxlen = sizeof(__disable_trace_on_warning),
743 .mode = 0644,
744 .proc_handler = proc_dointvec,
745 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500746 {
747 .procname = "tracepoint_printk",
748 .data = &tracepoint_printk,
749 .maxlen = sizeof(tracepoint_printk),
750 .mode = 0644,
751 .proc_handler = proc_dointvec,
752 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400753#endif
Dave Young2965faa2015-09-09 15:38:55 -0700754#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800755 {
756 .procname = "kexec_load_disabled",
757 .data = &kexec_load_disabled,
758 .maxlen = sizeof(int),
759 .mode = 0644,
760 /* only handle a transition from default "0" to "1" */
761 .proc_handler = proc_dointvec_minmax,
762 .extra1 = &one,
763 .extra2 = &one,
764 },
765#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200766#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 .procname = "modprobe",
769 .data = &modprobe_path,
770 .maxlen = KMOD_PATH_LEN,
771 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800772 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 },
Kees Cook3d433212009-04-02 15:49:29 -0700774 {
Kees Cook3d433212009-04-02 15:49:29 -0700775 .procname = "modules_disabled",
776 .data = &modules_disabled,
777 .maxlen = sizeof(int),
778 .mode = 0644,
779 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800780 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700781 .extra1 = &one,
782 .extra2 = &one,
783 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700785#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100788 .data = &uevent_helper,
789 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800791 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 },
Michael Marineau86d56132014-04-10 14:09:31 -0700793#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794#ifdef CONFIG_CHR_DEV_SG
795 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 .procname = "sg-big-buff",
797 .data = &sg_big_buff,
798 .maxlen = sizeof (int),
799 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800800 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 },
802#endif
803#ifdef CONFIG_BSD_PROCESS_ACCT
804 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 .procname = "acct",
806 .data = &acct_parm,
807 .maxlen = 3*sizeof(int),
808 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800809 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 },
811#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812#ifdef CONFIG_MAGIC_SYSRQ
813 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800815 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 .maxlen = sizeof (int),
817 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700818 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 },
820#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700821#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700824 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 .maxlen = sizeof (int),
826 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800827 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700829#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700832 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 .maxlen = sizeof(int),
834 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700835 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 },
837 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 .procname = "random",
839 .mode = 0555,
840 .child = random_table,
841 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 {
Eric Paris17f60a72011-04-01 17:07:50 -0400843 .procname = "usermodehelper",
844 .mode = 0555,
845 .child = usermodehelper_table,
846 },
847 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 .procname = "overflowuid",
849 .data = &overflowuid,
850 .maxlen = sizeof(int),
851 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800852 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 .extra1 = &minolduid,
854 .extra2 = &maxolduid,
855 },
856 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 .procname = "overflowgid",
858 .data = &overflowgid,
859 .maxlen = sizeof(int),
860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 .extra1 = &minolduid,
863 .extra2 = &maxolduid,
864 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800865#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866#ifdef CONFIG_MATHEMU
867 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 .procname = "ieee_emulation_warnings",
869 .data = &sysctl_ieee_emulation_warnings,
870 .maxlen = sizeof(int),
871 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800872 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 },
874#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200877 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 .maxlen = sizeof(int),
879 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800880 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 },
882#endif
883 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 .procname = "pid_max",
885 .data = &pid_max,
886 .maxlen = sizeof (int),
887 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800888 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 .extra1 = &pid_max_min,
890 .extra2 = &pid_max_max,
891 },
892 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 .procname = "panic_on_oops",
894 .data = &panic_on_oops,
895 .maxlen = sizeof(int),
896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800899#if defined CONFIG_PRINTK
900 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800901 .procname = "printk",
902 .data = &console_loglevel,
903 .maxlen = 4*sizeof(int),
904 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800905 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800906 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700909 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 .maxlen = sizeof(int),
911 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800912 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 },
914 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700916 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 .maxlen = sizeof(int),
918 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800919 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 },
Dave Youngaf913222009-09-22 16:43:33 -0700921 {
Dave Youngaf913222009-09-22 16:43:33 -0700922 .procname = "printk_delay",
923 .data = &printk_delay_msec,
924 .maxlen = sizeof(int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700927 .extra1 = &zero,
928 .extra2 = &ten_thousand,
929 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700931 .procname = "printk_devkmsg",
932 .data = devkmsg_log_str,
933 .maxlen = DEVKMSG_STR_MAX_SIZE,
934 .mode = 0644,
935 .proc_handler = devkmsg_sysctl_set_loglvl,
936 },
937 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800938 .procname = "dmesg_restrict",
939 .data = &dmesg_restrict,
940 .maxlen = sizeof(int),
941 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700942 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800943 .extra1 = &zero,
944 .extra2 = &one,
945 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800946 {
947 .procname = "kptr_restrict",
948 .data = &kptr_restrict,
949 .maxlen = sizeof(int),
950 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700951 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800952 .extra1 = &zero,
953 .extra2 = &two,
954 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800955#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800956 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 .procname = "ngroups_max",
958 .data = &ngroups_max,
959 .maxlen = sizeof (int),
960 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 },
Dan Ballard73efc032011-10-31 17:11:20 -0700963 {
964 .procname = "cap_last_cap",
965 .data = (void *)&cap_last_cap,
966 .maxlen = sizeof(int),
967 .mode = 0444,
968 .proc_handler = proc_dointvec,
969 },
Don Zickus58687ac2010-05-07 17:11:44 -0400970#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500971 {
Don Zickus58687ac2010-05-07 17:11:44 -0400972 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200973 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500974 .maxlen = sizeof (int),
975 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700976 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700977 .extra1 = &zero,
978 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400979 },
980 {
981 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700982 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400983 .maxlen = sizeof(int),
984 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700985 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800986 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400987 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500988 },
Don Zickus2508ce12010-05-07 17:11:46 -0400989 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700990 .procname = "nmi_watchdog",
991 .data = &nmi_watchdog_enabled,
992 .maxlen = sizeof (int),
993 .mode = 0644,
994 .proc_handler = proc_nmi_watchdog,
995 .extra1 = &zero,
996#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
997 .extra2 = &one,
998#else
999 .extra2 = &zero,
1000#endif
1001 },
1002 {
1003 .procname = "soft_watchdog",
1004 .data = &soft_watchdog_enabled,
1005 .maxlen = sizeof (int),
1006 .mode = 0644,
1007 .proc_handler = proc_soft_watchdog,
1008 .extra1 = &zero,
1009 .extra2 = &one,
1010 },
1011 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001012 .procname = "watchdog_cpumask",
1013 .data = &watchdog_cpumask_bits,
1014 .maxlen = NR_CPUS,
1015 .mode = 0644,
1016 .proc_handler = proc_watchdog_cpumask,
1017 },
1018 {
Don Zickus2508ce12010-05-07 17:11:46 -04001019 .procname = "softlockup_panic",
1020 .data = &softlockup_panic,
1021 .maxlen = sizeof(int),
1022 .mode = 0644,
1023 .proc_handler = proc_dointvec_minmax,
1024 .extra1 = &zero,
1025 .extra2 = &one,
1026 },
Don Zickusac1f5912015-11-05 18:44:44 -08001027#ifdef CONFIG_HARDLOCKUP_DETECTOR
1028 {
1029 .procname = "hardlockup_panic",
1030 .data = &hardlockup_panic,
1031 .maxlen = sizeof(int),
1032 .mode = 0644,
1033 .proc_handler = proc_dointvec_minmax,
1034 .extra1 = &zero,
1035 .extra2 = &one,
1036 },
1037#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001038#ifdef CONFIG_SMP
1039 {
1040 .procname = "softlockup_all_cpu_backtrace",
1041 .data = &sysctl_softlockup_all_cpu_backtrace,
1042 .maxlen = sizeof(int),
1043 .mode = 0644,
1044 .proc_handler = proc_dointvec_minmax,
1045 .extra1 = &zero,
1046 .extra2 = &one,
1047 },
Jiri Kosina55537872015-11-05 18:44:41 -08001048 {
1049 .procname = "hardlockup_all_cpu_backtrace",
1050 .data = &sysctl_hardlockup_all_cpu_backtrace,
1051 .maxlen = sizeof(int),
1052 .mode = 0644,
1053 .proc_handler = proc_dointvec_minmax,
1054 .extra1 = &zero,
1055 .extra2 = &one,
1056 },
Aaron Tomlined235872014-06-23 13:22:05 -07001057#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001058#endif
1059#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1060 {
1061 .procname = "unknown_nmi_panic",
1062 .data = &unknown_nmi_panic,
1063 .maxlen = sizeof (int),
1064 .mode = 0644,
1065 .proc_handler = proc_dointvec,
1066 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001067#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068#if defined(CONFIG_X86)
1069 {
Don Zickus8da5add2006-09-26 10:52:27 +02001070 .procname = "panic_on_unrecovered_nmi",
1071 .data = &panic_on_unrecovered_nmi,
1072 .maxlen = sizeof(int),
1073 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001074 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001075 },
1076 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001077 .procname = "panic_on_io_nmi",
1078 .data = &panic_on_io_nmi,
1079 .maxlen = sizeof(int),
1080 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001081 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001082 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001083#ifdef CONFIG_DEBUG_STACKOVERFLOW
1084 {
1085 .procname = "panic_on_stackoverflow",
1086 .data = &sysctl_panic_on_stackoverflow,
1087 .maxlen = sizeof(int),
1088 .mode = 0644,
1089 .proc_handler = proc_dointvec,
1090 },
1091#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001092 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 .procname = "bootloader_type",
1094 .data = &bootloader_type,
1095 .maxlen = sizeof (int),
1096 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001097 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001099 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001100 .procname = "bootloader_version",
1101 .data = &bootloader_version,
1102 .maxlen = sizeof (int),
1103 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001104 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001105 },
1106 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001107 .procname = "kstack_depth_to_print",
1108 .data = &kstack_depth_to_print,
1109 .maxlen = sizeof(int),
1110 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001112 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001113 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001114 .procname = "io_delay_type",
1115 .data = &io_delay_type,
1116 .maxlen = sizeof(int),
1117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001119 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001121#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 .procname = "randomize_va_space",
1124 .data = &randomize_va_space,
1125 .maxlen = sizeof(int),
1126 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001127 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001129#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001130#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001131 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001132 .procname = "spin_retry",
1133 .data = &spin_retry,
1134 .maxlen = sizeof (int),
1135 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001136 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001137 },
1138#endif
Len Brown673d5b42007-07-28 03:33:16 -04001139#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001140 {
Pavel Machekc255d842006-02-20 18:27:58 -08001141 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001142 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001143 .maxlen = sizeof (unsigned long),
1144 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001145 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001146 },
1147#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301148#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001149 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001150 .procname = "ignore-unaligned-usertrap",
1151 .data = &no_unaligned_warning,
1152 .maxlen = sizeof (int),
1153 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001154 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001155 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301156#endif
1157#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001158 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001159 .procname = "unaligned-dump-stack",
1160 .data = &unaligned_dump_stack,
1161 .maxlen = sizeof (int),
1162 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001163 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001164 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001165#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001166#ifdef CONFIG_DETECT_HUNG_TASK
1167 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001168 .procname = "hung_task_panic",
1169 .data = &sysctl_hung_task_panic,
1170 .maxlen = sizeof(int),
1171 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001172 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001173 .extra1 = &zero,
1174 .extra2 = &one,
1175 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001176 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001177 .procname = "hung_task_check_count",
1178 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001179 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001180 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001181 .proc_handler = proc_dointvec_minmax,
1182 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001183 },
1184 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001185 .procname = "hung_task_timeout_secs",
1186 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001187 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001188 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001189 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001190 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001191 },
1192 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001193 .procname = "hung_task_warnings",
1194 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001195 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001196 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001197 .proc_handler = proc_dointvec_minmax,
1198 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001199 },
Imran Khana9788f42017-09-18 15:48:30 +05301200 {
1201 .procname = "hung_task_selective_monitoring",
1202 .data = &sysctl_hung_task_selective_monitoring,
1203 .maxlen = sizeof(int),
1204 .mode = 0644,
1205 .proc_handler = proc_dointvec_minmax,
1206 .extra1 = &zero,
1207 .extra2 = &one,
1208 },
1209
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001210#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001211#ifdef CONFIG_RT_MUTEXES
1212 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001213 .procname = "max_lock_depth",
1214 .data = &max_lock_depth,
1215 .maxlen = sizeof(int),
1216 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001217 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001218 },
1219#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001220 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001221 .procname = "poweroff_cmd",
1222 .data = &poweroff_cmd,
1223 .maxlen = POWEROFF_CMD_PATH_LEN,
1224 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001225 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001226 },
David Howells0b77f5b2008-04-29 01:01:32 -07001227#ifdef CONFIG_KEYS
1228 {
David Howells0b77f5b2008-04-29 01:01:32 -07001229 .procname = "keys",
1230 .mode = 0555,
1231 .child = key_sysctls,
1232 },
1233#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001234#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001235 /*
1236 * User-space scripts rely on the existence of this file
1237 * as a feature check for perf_events being enabled.
1238 *
1239 * So it's an ABI, do not remove!
1240 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001241 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001242 .procname = "perf_event_paranoid",
1243 .data = &sysctl_perf_event_paranoid,
1244 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001245 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001246 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001247 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001248 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001249 .procname = "perf_event_mlock_kb",
1250 .data = &sysctl_perf_event_mlock,
1251 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001252 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001253 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001254 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001255 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001256 .procname = "perf_event_max_sample_rate",
1257 .data = &sysctl_perf_event_sample_rate,
1258 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001259 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001260 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001261 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001262 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001263 {
1264 .procname = "perf_cpu_time_max_percent",
1265 .data = &sysctl_perf_cpu_time_max_percent,
1266 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1267 .mode = 0644,
1268 .proc_handler = perf_cpu_time_max_percent_handler,
1269 .extra1 = &zero,
1270 .extra2 = &one_hundred,
1271 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001272 {
1273 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001274 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001275 .maxlen = sizeof(sysctl_perf_event_max_stack),
1276 .mode = 0644,
1277 .proc_handler = perf_event_max_stack_handler,
1278 .extra1 = &zero,
1279 .extra2 = &six_hundred_forty_kb,
1280 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001281 {
1282 .procname = "perf_event_max_contexts_per_stack",
1283 .data = &sysctl_perf_event_max_contexts_per_stack,
1284 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1285 .mode = 0644,
1286 .proc_handler = perf_event_max_stack_handler,
1287 .extra1 = &zero,
1288 .extra2 = &one_thousand,
1289 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001290#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001291#ifdef CONFIG_KMEMCHECK
1292 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001293 .procname = "kmemcheck",
1294 .data = &kmemcheck_enabled,
1295 .maxlen = sizeof(int),
1296 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001297 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001298 },
1299#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001300 {
1301 .procname = "panic_on_warn",
1302 .data = &panic_on_warn,
1303 .maxlen = sizeof(int),
1304 .mode = 0644,
1305 .proc_handler = proc_dointvec_minmax,
1306 .extra1 = &zero,
1307 .extra2 = &one,
1308 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001309#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1310 {
1311 .procname = "timer_migration",
1312 .data = &sysctl_timer_migration,
1313 .maxlen = sizeof(unsigned int),
1314 .mode = 0644,
1315 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001316 .extra1 = &zero,
1317 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001318 },
1319#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001320#ifdef CONFIG_BPF_SYSCALL
1321 {
1322 .procname = "unprivileged_bpf_disabled",
1323 .data = &sysctl_unprivileged_bpf_disabled,
1324 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1325 .mode = 0644,
1326 /* only handle a transition from default "0" to "1" */
1327 .proc_handler = proc_dointvec_minmax,
1328 .extra1 = &one,
1329 .extra2 = &one,
1330 },
1331#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001332#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1333 {
1334 .procname = "panic_on_rcu_stall",
1335 .data = &sysctl_panic_on_rcu_stall,
1336 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1337 .mode = 0644,
1338 .proc_handler = proc_dointvec_minmax,
1339 .extra1 = &zero,
1340 .extra2 = &one,
1341 },
1342#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001343#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001344 {
1345 .procname = "boot_reason",
1346 .data = &boot_reason,
1347 .maxlen = sizeof(int),
1348 .mode = 0444,
1349 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001350 },
1351
1352 {
1353 .procname = "cold_boot",
1354 .data = &cold_boot,
1355 .maxlen = sizeof(int),
1356 .mode = 0444,
1357 .proc_handler = proc_dointvec,
1358 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001359#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001360 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361};
1362
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001363static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001364 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 .procname = "overcommit_memory",
1366 .data = &sysctl_overcommit_memory,
1367 .maxlen = sizeof(sysctl_overcommit_memory),
1368 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001369 .proc_handler = proc_dointvec_minmax,
1370 .extra1 = &zero,
1371 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 },
1373 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001374 .procname = "panic_on_oom",
1375 .data = &sysctl_panic_on_oom,
1376 .maxlen = sizeof(sysctl_panic_on_oom),
1377 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001378 .proc_handler = proc_dointvec_minmax,
1379 .extra1 = &zero,
1380 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001381 },
1382 {
David Rientjesfe071d72007-10-16 23:25:56 -07001383 .procname = "oom_kill_allocating_task",
1384 .data = &sysctl_oom_kill_allocating_task,
1385 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001387 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001388 },
1389 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001390 .procname = "oom_dump_tasks",
1391 .data = &sysctl_oom_dump_tasks,
1392 .maxlen = sizeof(sysctl_oom_dump_tasks),
1393 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001394 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001395 },
1396 {
Charan Teja Reddyf9920cf2018-05-01 20:20:20 +05301397 .procname = "reap_mem_on_sigkill",
1398 .data = &sysctl_reap_mem_on_sigkill,
1399 .maxlen = sizeof(sysctl_reap_mem_on_sigkill),
1400 .mode = 0644,
1401 .proc_handler = proc_dointvec,
1402 },
1403 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 .procname = "overcommit_ratio",
1405 .data = &sysctl_overcommit_ratio,
1406 .maxlen = sizeof(sysctl_overcommit_ratio),
1407 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001408 .proc_handler = overcommit_ratio_handler,
1409 },
1410 {
1411 .procname = "overcommit_kbytes",
1412 .data = &sysctl_overcommit_kbytes,
1413 .maxlen = sizeof(sysctl_overcommit_kbytes),
1414 .mode = 0644,
1415 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416 },
1417 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418 .procname = "page-cluster",
1419 .data = &page_cluster,
1420 .maxlen = sizeof(int),
1421 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001422 .proc_handler = proc_dointvec_minmax,
1423 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 },
1425 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001426 .procname = "dirty_background_ratio",
1427 .data = &dirty_background_ratio,
1428 .maxlen = sizeof(dirty_background_ratio),
1429 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001430 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 .extra1 = &zero,
1432 .extra2 = &one_hundred,
1433 },
1434 {
David Rientjes2da02992009-01-06 14:39:31 -08001435 .procname = "dirty_background_bytes",
1436 .data = &dirty_background_bytes,
1437 .maxlen = sizeof(dirty_background_bytes),
1438 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001439 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001440 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001441 },
1442 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 .procname = "dirty_ratio",
1444 .data = &vm_dirty_ratio,
1445 .maxlen = sizeof(vm_dirty_ratio),
1446 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001447 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 .extra1 = &zero,
1449 .extra2 = &one_hundred,
1450 },
1451 {
David Rientjes2da02992009-01-06 14:39:31 -08001452 .procname = "dirty_bytes",
1453 .data = &vm_dirty_bytes,
1454 .maxlen = sizeof(vm_dirty_bytes),
1455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001456 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001457 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001458 },
1459 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001461 .data = &dirty_writeback_interval,
1462 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001464 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 },
1466 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001468 .data = &dirty_expire_interval,
1469 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001471 .proc_handler = proc_dointvec_minmax,
1472 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 },
1474 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001475 .procname = "dirtytime_expire_seconds",
1476 .data = &dirtytime_expire_interval,
1477 .maxlen = sizeof(dirty_expire_interval),
1478 .mode = 0644,
1479 .proc_handler = dirtytime_interval_handler,
1480 .extra1 = &zero,
1481 },
1482 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001483 .procname = "nr_pdflush_threads",
1484 .mode = 0444 /* read-only */,
1485 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 },
1487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .procname = "swappiness",
1489 .data = &vm_swappiness,
1490 .maxlen = sizeof(vm_swappiness),
1491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001492 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 .extra1 = &zero,
1494 .extra2 = &one_hundred,
1495 },
Vinayak Menonb9e4cc2b2018-06-11 18:58:39 +05301496 {
1497 .procname = "want_old_faultaround_pte",
1498 .data = &want_old_faultaround_pte,
1499 .maxlen = sizeof(want_old_faultaround_pte),
1500 .mode = 0644,
1501 .proc_handler = proc_dointvec_minmax,
1502 .extra1 = &zero,
1503 .extra2 = &one,
1504 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001508 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 .maxlen = sizeof(unsigned long),
1510 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001511 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001512 },
1513#ifdef CONFIG_NUMA
1514 {
1515 .procname = "nr_hugepages_mempolicy",
1516 .data = NULL,
1517 .maxlen = sizeof(unsigned long),
1518 .mode = 0644,
1519 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001520 },
1521#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 .procname = "hugetlb_shm_group",
1524 .data = &sysctl_hugetlb_shm_group,
1525 .maxlen = sizeof(gid_t),
1526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001527 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 },
Mel Gorman396faf02007-07-17 04:03:13 -07001529 {
Mel Gorman396faf02007-07-17 04:03:13 -07001530 .procname = "hugepages_treat_as_movable",
1531 .data = &hugepages_treat_as_movable,
1532 .maxlen = sizeof(int),
1533 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001534 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001535 },
Adam Litke54f9f802007-10-16 01:26:20 -07001536 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001537 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001538 .data = NULL,
1539 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001541 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001542 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543#endif
1544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545 .procname = "lowmem_reserve_ratio",
1546 .data = &sysctl_lowmem_reserve_ratio,
1547 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001549 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550 },
1551 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001552 .procname = "drop_caches",
1553 .data = &sysctl_drop_caches,
1554 .maxlen = sizeof(int),
1555 .mode = 0644,
1556 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001557 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001558 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001559 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001560#ifdef CONFIG_COMPACTION
1561 {
1562 .procname = "compact_memory",
1563 .data = &sysctl_compact_memory,
1564 .maxlen = sizeof(int),
1565 .mode = 0200,
1566 .proc_handler = sysctl_compaction_handler,
1567 },
Mel Gorman5e771902010-05-24 14:32:31 -07001568 {
1569 .procname = "extfrag_threshold",
1570 .data = &sysctl_extfrag_threshold,
1571 .maxlen = sizeof(int),
1572 .mode = 0644,
1573 .proc_handler = sysctl_extfrag_handler,
1574 .extra1 = &min_extfrag_threshold,
1575 .extra2 = &max_extfrag_threshold,
1576 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001577 {
1578 .procname = "compact_unevictable_allowed",
1579 .data = &sysctl_compact_unevictable_allowed,
1580 .maxlen = sizeof(int),
1581 .mode = 0644,
1582 .proc_handler = proc_dointvec,
1583 .extra1 = &zero,
1584 .extra2 = &one,
1585 },
Mel Gorman5e771902010-05-24 14:32:31 -07001586
Mel Gorman76ab0f52010-05-24 14:32:28 -07001587#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001588 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589 .procname = "min_free_kbytes",
1590 .data = &min_free_kbytes,
1591 .maxlen = sizeof(min_free_kbytes),
1592 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001593 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594 .extra1 = &zero,
1595 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001596 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001597 .procname = "watermark_scale_factor",
1598 .data = &watermark_scale_factor,
1599 .maxlen = sizeof(watermark_scale_factor),
1600 .mode = 0644,
1601 .proc_handler = watermark_scale_factor_sysctl_handler,
Rik van Riel12462752011-09-01 15:26:50 -04001602 .extra1 = &zero,
1603 .extra2 = &zero,
1604 },
1605 {
1606 .procname = "extra_free_kbytes",
1607 .data = &extra_free_kbytes,
1608 .maxlen = sizeof(extra_free_kbytes),
1609 .mode = 0644,
1610 .proc_handler = min_free_kbytes_sysctl_handler,
1611 .extra1 = &zero,
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001612 },
1613 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001614 .procname = "percpu_pagelist_fraction",
1615 .data = &percpu_pagelist_fraction,
1616 .maxlen = sizeof(percpu_pagelist_fraction),
1617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001618 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001619 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001620 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621#ifdef CONFIG_MMU
1622 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 .procname = "max_map_count",
1624 .data = &sysctl_max_map_count,
1625 .maxlen = sizeof(sysctl_max_map_count),
1626 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001627 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001628 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001629 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001630#else
1631 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001632 .procname = "nr_trim_pages",
1633 .data = &sysctl_nr_trim_pages,
1634 .maxlen = sizeof(sysctl_nr_trim_pages),
1635 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001636 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001637 .extra1 = &zero,
1638 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639#endif
1640 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641 .procname = "laptop_mode",
1642 .data = &laptop_mode,
1643 .maxlen = sizeof(laptop_mode),
1644 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001645 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646 },
1647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648 .procname = "block_dump",
1649 .data = &block_dump,
1650 .maxlen = sizeof(block_dump),
1651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001652 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653 .extra1 = &zero,
1654 },
1655 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001656 .procname = "vfs_cache_pressure",
1657 .data = &sysctl_vfs_cache_pressure,
1658 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1659 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001660 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661 .extra1 = &zero,
1662 },
1663#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665 .procname = "legacy_va_layout",
1666 .data = &sysctl_legacy_va_layout,
1667 .maxlen = sizeof(sysctl_legacy_va_layout),
1668 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001669 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001670 .extra1 = &zero,
1671 },
1672#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001673#ifdef CONFIG_NUMA
1674 {
Christoph Lameter17436602006-01-18 17:42:32 -08001675 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001676 .data = &node_reclaim_mode,
1677 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001678 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001679 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001680 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001681 },
Christoph Lameter96146342006-07-03 00:24:13 -07001682 {
Christoph Lameter96146342006-07-03 00:24:13 -07001683 .procname = "min_unmapped_ratio",
1684 .data = &sysctl_min_unmapped_ratio,
1685 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1686 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001687 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001688 .extra1 = &zero,
1689 .extra2 = &one_hundred,
1690 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001691 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001692 .procname = "min_slab_ratio",
1693 .data = &sysctl_min_slab_ratio,
1694 .maxlen = sizeof(sysctl_min_slab_ratio),
1695 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001696 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001697 .extra1 = &zero,
1698 .extra2 = &one_hundred,
1699 },
Christoph Lameter17436602006-01-18 17:42:32 -08001700#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001701#ifdef CONFIG_SMP
1702 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001703 .procname = "stat_interval",
1704 .data = &sysctl_stat_interval,
1705 .maxlen = sizeof(sysctl_stat_interval),
1706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001707 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001708 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001709 {
1710 .procname = "stat_refresh",
1711 .data = NULL,
1712 .maxlen = 0,
1713 .mode = 0600,
1714 .proc_handler = vmstat_refresh,
1715 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001716#endif
David Howells6e141542009-12-15 19:27:45 +00001717#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001718 {
Eric Parised032182007-06-28 15:55:21 -04001719 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001720 .data = &dac_mmap_min_addr,
1721 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001722 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001723 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001724 },
David Howells6e141542009-12-15 19:27:45 +00001725#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001726#ifdef CONFIG_NUMA
1727 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001728 .procname = "numa_zonelist_order",
1729 .data = &numa_zonelist_order,
1730 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1731 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001732 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001733 },
1734#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001735#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001736 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001737 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001738 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001739#ifdef CONFIG_X86_32
1740 .data = &vdso32_enabled,
1741 .maxlen = sizeof(vdso32_enabled),
1742#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001743 .data = &vdso_enabled,
1744 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001745#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001746 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001747 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001748 .extra1 = &zero,
1749 },
1750#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001751#ifdef CONFIG_HIGHMEM
1752 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001753 .procname = "highmem_is_dirtyable",
1754 .data = &vm_highmem_is_dirtyable,
1755 .maxlen = sizeof(vm_highmem_is_dirtyable),
1756 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001757 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001758 .extra1 = &zero,
1759 .extra2 = &one,
1760 },
1761#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001762#ifdef CONFIG_MEMORY_FAILURE
1763 {
Andi Kleen6a460792009-09-16 11:50:15 +02001764 .procname = "memory_failure_early_kill",
1765 .data = &sysctl_memory_failure_early_kill,
1766 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1767 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001768 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001769 .extra1 = &zero,
1770 .extra2 = &one,
1771 },
1772 {
Andi Kleen6a460792009-09-16 11:50:15 +02001773 .procname = "memory_failure_recovery",
1774 .data = &sysctl_memory_failure_recovery,
1775 .maxlen = sizeof(sysctl_memory_failure_recovery),
1776 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001777 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001778 .extra1 = &zero,
1779 .extra2 = &one,
1780 },
1781#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001782 {
1783 .procname = "user_reserve_kbytes",
1784 .data = &sysctl_user_reserve_kbytes,
1785 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1786 .mode = 0644,
1787 .proc_handler = proc_doulongvec_minmax,
1788 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001789 {
1790 .procname = "admin_reserve_kbytes",
1791 .data = &sysctl_admin_reserve_kbytes,
1792 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1793 .mode = 0644,
1794 .proc_handler = proc_doulongvec_minmax,
1795 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001796#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1797 {
1798 .procname = "mmap_rnd_bits",
1799 .data = &mmap_rnd_bits,
1800 .maxlen = sizeof(mmap_rnd_bits),
1801 .mode = 0600,
1802 .proc_handler = proc_dointvec_minmax,
1803 .extra1 = (void *)&mmap_rnd_bits_min,
1804 .extra2 = (void *)&mmap_rnd_bits_max,
1805 },
1806#endif
1807#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1808 {
1809 .procname = "mmap_rnd_compat_bits",
1810 .data = &mmap_rnd_compat_bits,
1811 .maxlen = sizeof(mmap_rnd_compat_bits),
1812 .mode = 0600,
1813 .proc_handler = proc_dointvec_minmax,
1814 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1815 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1816 },
1817#endif
Vinayak Menonc1c6a992015-12-21 13:00:58 +05301818#ifdef CONFIG_SWAP
1819 {
1820 .procname = "swap_ratio",
1821 .data = &sysctl_swap_ratio,
1822 .maxlen = sizeof(sysctl_swap_ratio),
1823 .mode = 0644,
1824 .proc_handler = proc_dointvec_minmax,
1825 },
1826 {
1827 .procname = "swap_ratio_enable",
1828 .data = &sysctl_swap_ratio_enable,
1829 .maxlen = sizeof(sysctl_swap_ratio_enable),
1830 .mode = 0644,
1831 .proc_handler = proc_dointvec_minmax,
1832 },
1833#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001834 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835};
1836
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001837static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839 .procname = "inode-nr",
1840 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001841 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001843 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844 },
1845 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 .procname = "inode-state",
1847 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001848 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001850 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001851 },
1852 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001853 .procname = "file-nr",
1854 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001855 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001856 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001857 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001858 },
1859 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 .procname = "file-max",
1861 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001862 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001864 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865 },
1866 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001867 .procname = "nr_open",
1868 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001869 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001870 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001871 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001872 .extra1 = &sysctl_nr_open_min,
1873 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001874 },
1875 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 .procname = "dentry-state",
1877 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001878 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001880 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 },
1882 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001883 .procname = "overflowuid",
1884 .data = &fs_overflowuid,
1885 .maxlen = sizeof(int),
1886 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001887 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 .extra1 = &minolduid,
1889 .extra2 = &maxolduid,
1890 },
1891 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 .procname = "overflowgid",
1893 .data = &fs_overflowgid,
1894 .maxlen = sizeof(int),
1895 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001896 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001897 .extra1 = &minolduid,
1898 .extra2 = &maxolduid,
1899 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001900#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 .procname = "leases-enable",
1903 .data = &leases_enable,
1904 .maxlen = sizeof(int),
1905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001906 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001908#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001909#ifdef CONFIG_DNOTIFY
1910 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911 .procname = "dir-notify-enable",
1912 .data = &dir_notify_enable,
1913 .maxlen = sizeof(int),
1914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001915 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 },
1917#endif
1918#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001919#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921 .procname = "lease-break-time",
1922 .data = &lease_break_time,
1923 .maxlen = sizeof(int),
1924 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001925 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001926 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001927#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001928#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001930 .procname = "aio-nr",
1931 .data = &aio_nr,
1932 .maxlen = sizeof(aio_nr),
1933 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001934 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001935 },
1936 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001937 .procname = "aio-max-nr",
1938 .data = &aio_max_nr,
1939 .maxlen = sizeof(aio_max_nr),
1940 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001941 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001943#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001944#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001945 {
Robert Love0399cb02005-07-13 12:38:18 -04001946 .procname = "inotify",
1947 .mode = 0555,
1948 .child = inotify_table,
1949 },
1950#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001951#ifdef CONFIG_EPOLL
1952 {
1953 .procname = "epoll",
1954 .mode = 0555,
1955 .child = epoll_table,
1956 },
1957#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001959 {
Kees Cook800179c2012-07-25 17:29:07 -07001960 .procname = "protected_symlinks",
1961 .data = &sysctl_protected_symlinks,
1962 .maxlen = sizeof(int),
1963 .mode = 0600,
1964 .proc_handler = proc_dointvec_minmax,
1965 .extra1 = &zero,
1966 .extra2 = &one,
1967 },
1968 {
1969 .procname = "protected_hardlinks",
1970 .data = &sysctl_protected_hardlinks,
1971 .maxlen = sizeof(int),
1972 .mode = 0600,
1973 .proc_handler = proc_dointvec_minmax,
1974 .extra1 = &zero,
1975 .extra2 = &one,
1976 },
1977 {
Alan Coxd6e71142005-06-23 00:09:43 -07001978 .procname = "suid_dumpable",
1979 .data = &suid_dumpable,
1980 .maxlen = sizeof(int),
1981 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001982 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001983 .extra1 = &zero,
1984 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001985 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001986#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1987 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001988 .procname = "binfmt_misc",
1989 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001990 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001991 },
1992#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001993 {
Jens Axboeff9da692010-06-03 14:54:39 +02001994 .procname = "pipe-max-size",
1995 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001996 .maxlen = sizeof(int),
1997 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001998 .proc_handler = &pipe_proc_fn,
1999 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002000 },
Willy Tarreau759c0112016-01-18 16:36:09 +01002001 {
2002 .procname = "pipe-user-pages-hard",
2003 .data = &pipe_user_pages_hard,
2004 .maxlen = sizeof(pipe_user_pages_hard),
2005 .mode = 0644,
2006 .proc_handler = proc_doulongvec_minmax,
2007 },
2008 {
2009 .procname = "pipe-user-pages-soft",
2010 .data = &pipe_user_pages_soft,
2011 .maxlen = sizeof(pipe_user_pages_soft),
2012 .mode = 0644,
2013 .proc_handler = proc_doulongvec_minmax,
2014 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05002015 {
2016 .procname = "mount-max",
2017 .data = &sysctl_mount_max,
2018 .maxlen = sizeof(unsigned int),
2019 .mode = 0644,
2020 .proc_handler = proc_dointvec_minmax,
2021 .extra1 = &one,
2022 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002023 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002024};
2025
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002026static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07002027#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002028 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002029 .procname = "exception-trace",
2030 .data = &show_unhandled_signals,
2031 .maxlen = sizeof(int),
2032 .mode = 0644,
2033 .proc_handler = proc_dointvec
2034 },
2035#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002036#if defined(CONFIG_OPTPROBES)
2037 {
2038 .procname = "kprobes-optimization",
2039 .data = &sysctl_kprobes_optimization,
2040 .maxlen = sizeof(int),
2041 .mode = 0644,
2042 .proc_handler = proc_kprobes_optimization_handler,
2043 .extra1 = &zero,
2044 .extra2 = &one,
2045 },
2046#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002047 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048};
2049
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002050static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002051 { }
Robert Love0eeca282005-07-12 17:06:03 -04002052};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002054int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002055{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002056 struct ctl_table_header *hdr;
2057
2058 hdr = register_sysctl_table(sysctl_base_table);
2059 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002060 return 0;
2061}
2062
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002063#endif /* CONFIG_SYSCTL */
2064
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065/*
2066 * /proc/sys support
2067 */
2068
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002069#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002070
Kees Cookf8808302014-06-06 14:37:17 -07002071static int _proc_do_string(char *data, int maxlen, int write,
2072 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002073 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002074{
2075 size_t len;
2076 char __user *p;
2077 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002078
2079 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002080 *lenp = 0;
2081 return 0;
2082 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002083
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002084 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002085 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2086 /* Only continue writes not past the end of buffer. */
2087 len = strlen(data);
2088 if (len > maxlen - 1)
2089 len = maxlen - 1;
2090
2091 if (*ppos > len)
2092 return 0;
2093 len = *ppos;
2094 } else {
2095 /* Start writing from beginning of buffer. */
2096 len = 0;
2097 }
2098
Kees Cook2ca9bb42014-06-06 14:37:18 -07002099 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002100 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002101 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002102 if (get_user(c, p++))
2103 return -EFAULT;
2104 if (c == 0 || c == '\n')
2105 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002106 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002107 }
Kees Cookf8808302014-06-06 14:37:17 -07002108 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002109 } else {
2110 len = strlen(data);
2111 if (len > maxlen)
2112 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002113
2114 if (*ppos > len) {
2115 *lenp = 0;
2116 return 0;
2117 }
2118
2119 data += *ppos;
2120 len -= *ppos;
2121
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002122 if (len > *lenp)
2123 len = *lenp;
2124 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002125 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002126 return -EFAULT;
2127 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002128 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002129 return -EFAULT;
2130 len++;
2131 }
2132 *lenp = len;
2133 *ppos += len;
2134 }
2135 return 0;
2136}
2137
Kees Cookf4aacea2014-06-06 14:37:19 -07002138static void warn_sysctl_write(struct ctl_table *table)
2139{
2140 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2141 "This will not be supported in the future. To silence this\n"
2142 "warning, set kernel.sysctl_writes_strict = -1\n",
2143 current->comm, table->procname);
2144}
2145
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146/**
2147 * proc_dostring - read a string sysctl
2148 * @table: the sysctl table
2149 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002150 * @buffer: the user buffer
2151 * @lenp: the size of the user buffer
2152 * @ppos: file position
2153 *
2154 * Reads/writes a string from/to the user buffer. If the kernel
2155 * buffer provided is not large enough to hold the string, the
2156 * string is truncated. The copied string is %NULL-terminated.
2157 * If the string is being read by the user process, it is copied
2158 * and a newline '\n' is added. It is truncated if the buffer is
2159 * not large enough.
2160 *
2161 * Returns 0 on success.
2162 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002163int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164 void __user *buffer, size_t *lenp, loff_t *ppos)
2165{
Kees Cookf4aacea2014-06-06 14:37:19 -07002166 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2167 warn_sysctl_write(table);
2168
Kees Cookf8808302014-06-06 14:37:17 -07002169 return _proc_do_string((char *)(table->data), table->maxlen, write,
2170 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171}
2172
Amerigo Wang00b7c332010-05-05 00:26:45 +00002173static size_t proc_skip_spaces(char **buf)
2174{
2175 size_t ret;
2176 char *tmp = skip_spaces(*buf);
2177 ret = tmp - *buf;
2178 *buf = tmp;
2179 return ret;
2180}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002181
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002182static void proc_skip_char(char **buf, size_t *size, const char v)
2183{
2184 while (*size) {
2185 if (**buf != v)
2186 break;
2187 (*size)--;
2188 (*buf)++;
2189 }
2190}
2191
Amerigo Wang00b7c332010-05-05 00:26:45 +00002192#define TMPBUFLEN 22
2193/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002194 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002195 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002196 * @buf: a kernel buffer
2197 * @size: size of the kernel buffer
2198 * @val: this is where the number will be stored
2199 * @neg: set to %TRUE if number is negative
2200 * @perm_tr: a vector which contains the allowed trailers
2201 * @perm_tr_len: size of the perm_tr vector
2202 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002204 * In case of success %0 is returned and @buf and @size are updated with
2205 * the amount of bytes read. If @tr is non-NULL and a trailing
2206 * character exists (size is non-zero after returning from this
2207 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002208 */
2209static int proc_get_long(char **buf, size_t *size,
2210 unsigned long *val, bool *neg,
2211 const char *perm_tr, unsigned perm_tr_len, char *tr)
2212{
2213 int len;
2214 char *p, tmp[TMPBUFLEN];
2215
2216 if (!*size)
2217 return -EINVAL;
2218
2219 len = *size;
2220 if (len > TMPBUFLEN - 1)
2221 len = TMPBUFLEN - 1;
2222
2223 memcpy(tmp, *buf, len);
2224
2225 tmp[len] = 0;
2226 p = tmp;
2227 if (*p == '-' && *size > 1) {
2228 *neg = true;
2229 p++;
2230 } else
2231 *neg = false;
2232 if (!isdigit(*p))
2233 return -EINVAL;
2234
2235 *val = simple_strtoul(p, &p, 0);
2236
2237 len = p - tmp;
2238
2239 /* We don't know if the next char is whitespace thus we may accept
2240 * invalid integers (e.g. 1234...a) or two integers instead of one
2241 * (e.g. 123...1). So lets not allow such large numbers. */
2242 if (len == TMPBUFLEN - 1)
2243 return -EINVAL;
2244
2245 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2246 return -EINVAL;
2247
2248 if (tr && (len < *size))
2249 *tr = *p;
2250
2251 *buf += len;
2252 *size -= len;
2253
2254 return 0;
2255}
2256
2257/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002258 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002259 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002260 * @buf: the user buffer
2261 * @size: the size of the user buffer
2262 * @val: the integer to be converted
2263 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002264 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002265 * In case of success %0 is returned and @buf and @size are updated with
2266 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002267 */
2268static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2269 bool neg)
2270{
2271 int len;
2272 char tmp[TMPBUFLEN], *p = tmp;
2273
2274 sprintf(p, "%s%lu", neg ? "-" : "", val);
2275 len = strlen(tmp);
2276 if (len > *size)
2277 len = *size;
2278 if (copy_to_user(*buf, tmp, len))
2279 return -EFAULT;
2280 *size -= len;
2281 *buf += len;
2282 return 0;
2283}
2284#undef TMPBUFLEN
2285
2286static int proc_put_char(void __user **buf, size_t *size, char c)
2287{
2288 if (*size) {
2289 char __user **buffer = (char __user **)buf;
2290 if (put_user(c, *buffer))
2291 return -EFAULT;
2292 (*size)--, (*buffer)++;
2293 *buf = *buffer;
2294 }
2295 return 0;
2296}
2297
2298static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 int *valp,
2300 int write, void *data)
2301{
2302 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002303 if (*negp) {
2304 if (*lvalp > (unsigned long) INT_MAX + 1)
2305 return -EINVAL;
2306 *valp = -*lvalp;
2307 } else {
2308 if (*lvalp > (unsigned long) INT_MAX)
2309 return -EINVAL;
2310 *valp = *lvalp;
2311 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 } else {
2313 int val = *valp;
2314 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002315 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002316 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002318 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 *lvalp = (unsigned long)val;
2320 }
2321 }
2322 return 0;
2323}
2324
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002325static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2326 int *valp,
2327 int write, void *data)
2328{
2329 if (write) {
2330 if (*negp)
2331 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002332 if (*lvalp > UINT_MAX)
2333 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002334 *valp = *lvalp;
2335 } else {
2336 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002337 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002338 *lvalp = (unsigned long)val;
2339 }
2340 return 0;
2341}
2342
Amerigo Wang00b7c332010-05-05 00:26:45 +00002343static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2344
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002345static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002346 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002347 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002348 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349 int write, void *data),
2350 void *data)
2351{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002352 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002353 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002354 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355
Amerigo Wang00b7c332010-05-05 00:26:45 +00002356 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 *lenp = 0;
2358 return 0;
2359 }
2360
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002361 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 vleft = table->maxlen / sizeof(*i);
2363 left = *lenp;
2364
2365 if (!conv)
2366 conv = do_proc_dointvec_conv;
2367
Linus Torvalds1da177e2005-04-16 15:20:36 -07002368 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002369 if (*ppos) {
2370 switch (sysctl_writes_strict) {
2371 case SYSCTL_WRITES_STRICT:
2372 goto out;
2373 case SYSCTL_WRITES_WARN:
2374 warn_sysctl_write(table);
2375 break;
2376 default:
2377 break;
2378 }
2379 }
2380
Amerigo Wang00b7c332010-05-05 00:26:45 +00002381 if (left > PAGE_SIZE - 1)
2382 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002383 p = kbuf = memdup_user_nul(buffer, left);
2384 if (IS_ERR(kbuf))
2385 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002386 }
2387
2388 for (; left && vleft--; i++, first=0) {
2389 unsigned long lval;
2390 bool neg;
2391
2392 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002393 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002394
J. R. Okajima563b0462010-05-25 16:10:14 -07002395 if (!left)
2396 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002397 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002398 proc_wspace_sep,
2399 sizeof(proc_wspace_sep), NULL);
2400 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002402 if (conv(&neg, &lval, i, 1, data)) {
2403 err = -EINVAL;
2404 break;
2405 }
2406 } else {
2407 if (conv(&neg, &lval, i, 0, data)) {
2408 err = -EINVAL;
2409 break;
2410 }
2411 if (!first)
2412 err = proc_put_char(&buffer, &left, '\t');
2413 if (err)
2414 break;
2415 err = proc_put_long(&buffer, &left, lval, neg);
2416 if (err)
2417 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418 }
2419 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002420
2421 if (!write && !first && left && !err)
2422 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002423 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002424 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002425 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002426 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002427 if (first)
2428 return err ? : -EINVAL;
2429 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002431out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002433 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434}
2435
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002436static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002437 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002438 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002439 int write, void *data),
2440 void *data)
2441{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002442 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002443 buffer, lenp, ppos, conv, data);
2444}
2445
Linus Torvalds1da177e2005-04-16 15:20:36 -07002446/**
2447 * proc_dointvec - read a vector of integers
2448 * @table: the sysctl table
2449 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 * @buffer: the user buffer
2451 * @lenp: the size of the user buffer
2452 * @ppos: file position
2453 *
2454 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2455 * values from/to the user buffer, treated as an ASCII string.
2456 *
2457 * Returns 0 on success.
2458 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002459int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002460 void __user *buffer, size_t *lenp, loff_t *ppos)
2461{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002462 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2463}
2464
2465/**
2466 * proc_douintvec - read a vector of unsigned integers
2467 * @table: the sysctl table
2468 * @write: %TRUE if this is a write to the sysctl file
2469 * @buffer: the user buffer
2470 * @lenp: the size of the user buffer
2471 * @ppos: file position
2472 *
2473 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2474 * values from/to the user buffer, treated as an ASCII string.
2475 *
2476 * Returns 0 on success.
2477 */
2478int proc_douintvec(struct ctl_table *table, int write,
2479 void __user *buffer, size_t *lenp, loff_t *ppos)
2480{
2481 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2482 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483}
2484
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002485/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002486 * Taint values can only be increased
2487 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002488 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002489static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002490 void __user *buffer, size_t *lenp, loff_t *ppos)
2491{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002492 struct ctl_table t;
2493 unsigned long tmptaint = get_taint();
2494 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002495
Bastian Blank91fcd412007-04-23 14:41:14 -07002496 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002497 return -EPERM;
2498
Andi Kleen25ddbb12008-10-15 22:01:41 -07002499 t = *table;
2500 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002501 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002502 if (err < 0)
2503 return err;
2504
2505 if (write) {
2506 /*
2507 * Poor man's atomic or. Not worth adding a primitive
2508 * to everyone's atomic.h for this
2509 */
2510 int i;
2511 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2512 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302513 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002514 }
2515 }
2516
2517 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002518}
2519
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002520#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002521static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002522 void __user *buffer, size_t *lenp, loff_t *ppos)
2523{
2524 if (write && !capable(CAP_SYS_ADMIN))
2525 return -EPERM;
2526
2527 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2528}
2529#endif
2530
Linus Torvalds1da177e2005-04-16 15:20:36 -07002531struct do_proc_dointvec_minmax_conv_param {
2532 int *min;
2533 int *max;
2534};
2535
Amerigo Wang00b7c332010-05-05 00:26:45 +00002536static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2537 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538 int write, void *data)
2539{
2540 struct do_proc_dointvec_minmax_conv_param *param = data;
2541 if (write) {
2542 int val = *negp ? -*lvalp : *lvalp;
2543 if ((param->min && *param->min > val) ||
2544 (param->max && *param->max < val))
2545 return -EINVAL;
2546 *valp = val;
2547 } else {
2548 int val = *valp;
2549 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002550 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002551 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002553 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002554 *lvalp = (unsigned long)val;
2555 }
2556 }
2557 return 0;
2558}
2559
2560/**
2561 * proc_dointvec_minmax - read a vector of integers with min/max values
2562 * @table: the sysctl table
2563 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564 * @buffer: the user buffer
2565 * @lenp: the size of the user buffer
2566 * @ppos: file position
2567 *
2568 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2569 * values from/to the user buffer, treated as an ASCII string.
2570 *
2571 * This routine will ensure the values are within the range specified by
2572 * table->extra1 (min) and table->extra2 (max).
2573 *
2574 * Returns 0 on success.
2575 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002576int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577 void __user *buffer, size_t *lenp, loff_t *ppos)
2578{
2579 struct do_proc_dointvec_minmax_conv_param param = {
2580 .min = (int *) table->extra1,
2581 .max = (int *) table->extra2,
2582 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002583 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 do_proc_dointvec_minmax_conv, &param);
2585}
2586
Kees Cook54b50192012-07-30 14:39:18 -07002587static void validate_coredump_safety(void)
2588{
Alex Kelly046d6622012-10-04 17:15:23 -07002589#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002590 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002591 core_pattern[0] != '/' && core_pattern[0] != '|') {
2592 printk(KERN_WARNING "Unsafe core_pattern used with "\
2593 "suid_dumpable=2. Pipe handler or fully qualified "\
2594 "core dump path required.\n");
2595 }
Alex Kelly046d6622012-10-04 17:15:23 -07002596#endif
Kees Cook54b50192012-07-30 14:39:18 -07002597}
2598
2599static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2600 void __user *buffer, size_t *lenp, loff_t *ppos)
2601{
2602 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2603 if (!error)
2604 validate_coredump_safety();
2605 return error;
2606}
2607
Alex Kelly046d6622012-10-04 17:15:23 -07002608#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002609static int proc_dostring_coredump(struct ctl_table *table, int write,
2610 void __user *buffer, size_t *lenp, loff_t *ppos)
2611{
2612 int error = proc_dostring(table, write, buffer, lenp, ppos);
2613 if (!error)
2614 validate_coredump_safety();
2615 return error;
2616}
Alex Kelly046d6622012-10-04 17:15:23 -07002617#endif
Kees Cook54b50192012-07-30 14:39:18 -07002618
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002619static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 void __user *buffer,
2621 size_t *lenp, loff_t *ppos,
2622 unsigned long convmul,
2623 unsigned long convdiv)
2624{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002625 unsigned long *i, *min, *max;
2626 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002627 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002628 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002629
2630 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 *lenp = 0;
2632 return 0;
2633 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002634
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002635 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002636 min = (unsigned long *) table->extra1;
2637 max = (unsigned long *) table->extra2;
2638 vleft = table->maxlen / sizeof(unsigned long);
2639 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002640
2641 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002642 if (*ppos) {
2643 switch (sysctl_writes_strict) {
2644 case SYSCTL_WRITES_STRICT:
2645 goto out;
2646 case SYSCTL_WRITES_WARN:
2647 warn_sysctl_write(table);
2648 break;
2649 default:
2650 break;
2651 }
2652 }
2653
Amerigo Wang00b7c332010-05-05 00:26:45 +00002654 if (left > PAGE_SIZE - 1)
2655 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002656 p = kbuf = memdup_user_nul(buffer, left);
2657 if (IS_ERR(kbuf))
2658 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002659 }
2660
Eric Dumazet27b3d802010-10-07 12:59:29 -07002661 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002662 unsigned long val;
2663
Linus Torvalds1da177e2005-04-16 15:20:36 -07002664 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002665 bool neg;
2666
Al Viro70f6cbb2015-12-24 00:13:10 -05002667 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002668
Al Viro70f6cbb2015-12-24 00:13:10 -05002669 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002670 proc_wspace_sep,
2671 sizeof(proc_wspace_sep), NULL);
2672 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 break;
2674 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002676 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 if ((min && val < *min) || (max && val > *max))
2678 continue;
2679 *i = val;
2680 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002681 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002682 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002683 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002684 if (err)
2685 break;
2686 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002687 err = proc_put_long(&buffer, &left, val, false);
2688 if (err)
2689 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690 }
2691 }
2692
Amerigo Wang00b7c332010-05-05 00:26:45 +00002693 if (!write && !first && left && !err)
2694 err = proc_put_char(&buffer, &left, '\n');
2695 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002696 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002698 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002699 if (first)
2700 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002701 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002703out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002704 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002705 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706}
2707
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002708static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002709 void __user *buffer,
2710 size_t *lenp, loff_t *ppos,
2711 unsigned long convmul,
2712 unsigned long convdiv)
2713{
2714 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002715 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002716}
2717
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718/**
2719 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2720 * @table: the sysctl table
2721 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002722 * @buffer: the user buffer
2723 * @lenp: the size of the user buffer
2724 * @ppos: file position
2725 *
2726 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2727 * values from/to the user buffer, treated as an ASCII string.
2728 *
2729 * This routine will ensure the values are within the range specified by
2730 * table->extra1 (min) and table->extra2 (max).
2731 *
2732 * Returns 0 on success.
2733 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002734int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002735 void __user *buffer, size_t *lenp, loff_t *ppos)
2736{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002737 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002738}
2739
2740/**
2741 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2742 * @table: the sysctl table
2743 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002744 * @buffer: the user buffer
2745 * @lenp: the size of the user buffer
2746 * @ppos: file position
2747 *
2748 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2749 * values from/to the user buffer, treated as an ASCII string. The values
2750 * are treated as milliseconds, and converted to jiffies when they are stored.
2751 *
2752 * This routine will ensure the values are within the range specified by
2753 * table->extra1 (min) and table->extra2 (max).
2754 *
2755 * Returns 0 on success.
2756 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002757int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002758 void __user *buffer,
2759 size_t *lenp, loff_t *ppos)
2760{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002761 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002762 lenp, ppos, HZ, 1000l);
2763}
2764
2765
Amerigo Wang00b7c332010-05-05 00:26:45 +00002766static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 int *valp,
2768 int write, void *data)
2769{
2770 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002771 if (*lvalp > LONG_MAX / HZ)
2772 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2774 } else {
2775 int val = *valp;
2776 unsigned long lval;
2777 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002778 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002779 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002780 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002781 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002782 lval = (unsigned long)val;
2783 }
2784 *lvalp = lval / HZ;
2785 }
2786 return 0;
2787}
2788
Amerigo Wang00b7c332010-05-05 00:26:45 +00002789static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002790 int *valp,
2791 int write, void *data)
2792{
2793 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002794 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2795 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002796 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2797 } else {
2798 int val = *valp;
2799 unsigned long lval;
2800 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002801 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002802 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002803 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002804 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002805 lval = (unsigned long)val;
2806 }
2807 *lvalp = jiffies_to_clock_t(lval);
2808 }
2809 return 0;
2810}
2811
Amerigo Wang00b7c332010-05-05 00:26:45 +00002812static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002813 int *valp,
2814 int write, void *data)
2815{
2816 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002817 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2818
2819 if (jif > INT_MAX)
2820 return 1;
2821 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002822 } else {
2823 int val = *valp;
2824 unsigned long lval;
2825 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002826 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002827 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002828 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002829 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002830 lval = (unsigned long)val;
2831 }
2832 *lvalp = jiffies_to_msecs(lval);
2833 }
2834 return 0;
2835}
2836
2837/**
2838 * proc_dointvec_jiffies - read a vector of integers as seconds
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 int) integer
2846 * values from/to the user buffer, treated as an ASCII string.
2847 * The values read are assumed to be in seconds, and are converted into
2848 * jiffies.
2849 *
2850 * Returns 0 on success.
2851 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002852int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002853 void __user *buffer, size_t *lenp, loff_t *ppos)
2854{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002855 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002856 do_proc_dointvec_jiffies_conv,NULL);
2857}
2858
2859/**
2860 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2861 * @table: the sysctl table
2862 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002863 * @buffer: the user buffer
2864 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002865 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002866 *
2867 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2868 * values from/to the user buffer, treated as an ASCII string.
2869 * The values read are assumed to be in 1/USER_HZ seconds, and
2870 * are converted into jiffies.
2871 *
2872 * Returns 0 on success.
2873 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002874int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002875 void __user *buffer, size_t *lenp, loff_t *ppos)
2876{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002877 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002878 do_proc_dointvec_userhz_jiffies_conv,NULL);
2879}
2880
2881/**
2882 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2883 * @table: the sysctl table
2884 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002885 * @buffer: the user buffer
2886 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002887 * @ppos: file position
2888 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002889 *
2890 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2891 * values from/to the user buffer, treated as an ASCII string.
2892 * The values read are assumed to be in 1/1000 seconds, and
2893 * are converted into jiffies.
2894 *
2895 * Returns 0 on success.
2896 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002897int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002898 void __user *buffer, size_t *lenp, loff_t *ppos)
2899{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002900 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002901 do_proc_dointvec_ms_jiffies_conv, NULL);
2902}
2903
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002904static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002905 void __user *buffer, size_t *lenp, loff_t *ppos)
2906{
2907 struct pid *new_pid;
2908 pid_t tmp;
2909 int r;
2910
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002911 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002912
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002913 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002914 lenp, ppos, NULL, NULL);
2915 if (r || !write)
2916 return r;
2917
2918 new_pid = find_get_pid(tmp);
2919 if (!new_pid)
2920 return -ESRCH;
2921
2922 put_pid(xchg(&cad_pid, new_pid));
2923 return 0;
2924}
2925
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002926/**
2927 * proc_do_large_bitmap - read/write from/to a large bitmap
2928 * @table: the sysctl table
2929 * @write: %TRUE if this is a write to the sysctl file
2930 * @buffer: the user buffer
2931 * @lenp: the size of the user buffer
2932 * @ppos: file position
2933 *
2934 * The bitmap is stored at table->data and the bitmap length (in bits)
2935 * in table->maxlen.
2936 *
2937 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2938 * large bitmaps may be represented in a compact manner. Writing into
2939 * the file will clear the bitmap then update it with the given input.
2940 *
2941 * Returns 0 on success.
2942 */
2943int proc_do_large_bitmap(struct ctl_table *table, int write,
2944 void __user *buffer, size_t *lenp, loff_t *ppos)
2945{
2946 int err = 0;
2947 bool first = 1;
2948 size_t left = *lenp;
2949 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002950 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002951 unsigned long *tmp_bitmap = NULL;
2952 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2953
WANG Cong122ff242014-05-12 16:04:53 -07002954 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002955 *lenp = 0;
2956 return 0;
2957 }
2958
2959 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002960 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002961
2962 if (left > PAGE_SIZE - 1)
2963 left = PAGE_SIZE - 1;
2964
Al Viro70f6cbb2015-12-24 00:13:10 -05002965 p = kbuf = memdup_user_nul(buffer, left);
2966 if (IS_ERR(kbuf))
2967 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002968
2969 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2970 GFP_KERNEL);
2971 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002972 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002973 return -ENOMEM;
2974 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002975 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002976 while (!err && left) {
2977 unsigned long val_a, val_b;
2978 bool neg;
2979
Al Viro70f6cbb2015-12-24 00:13:10 -05002980 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002981 sizeof(tr_a), &c);
2982 if (err)
2983 break;
2984 if (val_a >= bitmap_len || neg) {
2985 err = -EINVAL;
2986 break;
2987 }
2988
2989 val_b = val_a;
2990 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002991 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002992 left--;
2993 }
2994
2995 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002996 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002997 &neg, tr_b, sizeof(tr_b),
2998 &c);
2999 if (err)
3000 break;
3001 if (val_b >= bitmap_len || neg ||
3002 val_a > val_b) {
3003 err = -EINVAL;
3004 break;
3005 }
3006 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003007 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003008 left--;
3009 }
3010 }
3011
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003012 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003013 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003014 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003015 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003016 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003017 } else {
3018 unsigned long bit_a, bit_b = 0;
3019
3020 while (left) {
3021 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3022 if (bit_a >= bitmap_len)
3023 break;
3024 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3025 bit_a + 1) - 1;
3026
3027 if (!first) {
3028 err = proc_put_char(&buffer, &left, ',');
3029 if (err)
3030 break;
3031 }
3032 err = proc_put_long(&buffer, &left, bit_a, false);
3033 if (err)
3034 break;
3035 if (bit_a != bit_b) {
3036 err = proc_put_char(&buffer, &left, '-');
3037 if (err)
3038 break;
3039 err = proc_put_long(&buffer, &left, bit_b, false);
3040 if (err)
3041 break;
3042 }
3043
3044 first = 0; bit_b++;
3045 }
3046 if (!err)
3047 err = proc_put_char(&buffer, &left, '\n');
3048 }
3049
3050 if (!err) {
3051 if (write) {
3052 if (*ppos)
3053 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3054 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003055 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003056 }
3057 kfree(tmp_bitmap);
3058 *lenp -= left;
3059 *ppos += *lenp;
3060 return 0;
3061 } else {
3062 kfree(tmp_bitmap);
3063 return err;
3064 }
3065}
3066
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003067static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp,
3068 int *valp, int write, void *data)
3069{
3070 if (write) {
Satya Durga Srinivasu Prabhala3929bf02018-08-24 12:23:08 -07003071 if (*negp || *lvalp == 0)
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003072 return -EINVAL;
3073 *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp;
3074 } else {
3075 *negp = false;
3076 *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp;
3077 }
3078
3079 return 0;
3080}
3081
3082/**
3083 * proc_douintvec_capacity - read a vector of integers in percentage and convert
3084 * into sched capacity
3085 * @table: the sysctl table
3086 * @write: %TRUE if this is a write to the sysctl file
3087 * @buffer: the user buffer
3088 * @lenp: the size of the user buffer
3089 * @ppos: file position
3090 *
3091 * Returns 0 on success.
3092 */
3093int proc_douintvec_capacity(struct ctl_table *table, int write,
3094 void __user *buffer, size_t *lenp, loff_t *ppos)
3095{
3096 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3097 do_proc_douintvec_capacity_conv, NULL);
3098}
3099
Jovi Zhang55610502011-01-12 17:00:45 -08003100#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003101
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003102int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003103 void __user *buffer, size_t *lenp, loff_t *ppos)
3104{
3105 return -ENOSYS;
3106}
3107
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003108int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003109 void __user *buffer, size_t *lenp, loff_t *ppos)
3110{
3111 return -ENOSYS;
3112}
3113
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003114int proc_douintvec(struct ctl_table *table, int write,
3115 void __user *buffer, size_t *lenp, loff_t *ppos)
3116{
3117 return -ENOSYS;
3118}
3119
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003120int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003121 void __user *buffer, size_t *lenp, loff_t *ppos)
3122{
3123 return -ENOSYS;
3124}
3125
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003126int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003127 void __user *buffer, size_t *lenp, loff_t *ppos)
3128{
3129 return -ENOSYS;
3130}
3131
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003132int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003133 void __user *buffer, size_t *lenp, loff_t *ppos)
3134{
3135 return -ENOSYS;
3136}
3137
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003138int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003139 void __user *buffer, size_t *lenp, loff_t *ppos)
3140{
3141 return -ENOSYS;
3142}
3143
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003144int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003145 void __user *buffer, size_t *lenp, loff_t *ppos)
3146{
3147 return -ENOSYS;
3148}
3149
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003150int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003151 void __user *buffer,
3152 size_t *lenp, loff_t *ppos)
3153{
3154 return -ENOSYS;
3155}
3156
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003157int proc_douintvec_capacity(struct ctl_table *table, int write,
3158 void __user *buffer, size_t *lenp, loff_t *ppos)
3159{
3160 return -ENOSYS;
3161}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003162
Jovi Zhang55610502011-01-12 17:00:45 -08003163#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003164
Linus Torvalds1da177e2005-04-16 15:20:36 -07003165/*
3166 * No sense putting this after each symbol definition, twice,
3167 * exception granted :-)
3168 */
3169EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003170EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003171EXPORT_SYMBOL(proc_dointvec_jiffies);
3172EXPORT_SYMBOL(proc_dointvec_minmax);
3173EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3174EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3175EXPORT_SYMBOL(proc_dostring);
3176EXPORT_SYMBOL(proc_doulongvec_minmax);
3177EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);