blob: 1b880a1c8d654b0ed4ca1cb272d3a158b1806dfc [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;
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700130static int __maybe_unused one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700131#ifdef CONFIG_PRINTK
132static int ten_thousand = 10000;
133#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300134#ifdef CONFIG_PERF_EVENTS
135static int six_hundred_forty_kb = 640 * 1024;
136#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700137
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700138/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
139static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
142static int maxolduid = 65535;
143static int minolduid;
144
145static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700146static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Liu Hua80df2842014-04-07 15:38:57 -0700148/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
149#ifdef CONFIG_DETECT_HUNG_TASK
150static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
151#endif
152
Dave Youngd14f1722010-02-25 20:28:57 -0500153#ifdef CONFIG_INOTIFY_USER
154#include <linux/inotify.h>
155#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700156#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#endif
158
159#ifdef __hppa__
160extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530161#endif
162
163#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164extern int unaligned_enabled;
165#endif
166
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800168extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800169#endif
170
Vineet Guptab6fca722013-01-09 20:06:28 +0530171#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
172extern int no_unaligned_warning;
173#endif
174
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700175#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700176
177#define SYSCTL_WRITES_LEGACY -1
178#define SYSCTL_WRITES_WARN 0
179#define SYSCTL_WRITES_STRICT 1
180
Kees Cook41662f52016-01-20 15:00:45 -0800181static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700182
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700183static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700184 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700185static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800186 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700187#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700188
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700189#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700190static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700191 void __user *buffer, size_t *lenp, loff_t *ppos);
192#endif
193
Kees Cook54b50192012-07-30 14:39:18 -0700194static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
195 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700196#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700197static int proc_dostring_coredump(struct ctl_table *table, int write,
198 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700199#endif
Kees Cook54b50192012-07-30 14:39:18 -0700200
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700201#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800202/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100203static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700204
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700205static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700206 void __user *buffer, size_t *lenp,
207 loff_t *ppos)
208{
209 int error;
210
211 error = proc_dointvec(table, write, buffer, lenp, ppos);
212 if (error)
213 return error;
214
215 if (write)
216 sysrq_toggle_support(__sysrq_enabled);
217
218 return 0;
219}
220
221#endif
222
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700223static struct ctl_table kern_table[];
224static struct ctl_table vm_table[];
225static struct ctl_table fs_table[];
226static struct ctl_table debug_table[];
227static struct ctl_table dev_table[];
228extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800229#ifdef CONFIG_EPOLL
230extern struct ctl_table epoll_table[];
231#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
233#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
234int sysctl_legacy_va_layout;
235#endif
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237/* The default sysctl tables: */
238
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800239static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 .procname = "kernel",
242 .mode = 0555,
243 .child = kern_table,
244 },
245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .procname = "vm",
247 .mode = 0555,
248 .child = vm_table,
249 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 .procname = "fs",
252 .mode = 0555,
253 .child = fs_table,
254 },
255 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 .procname = "debug",
257 .mode = 0555,
258 .child = debug_table,
259 },
260 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 .procname = "dev",
262 .mode = 0555,
263 .child = dev_table,
264 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700265 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266};
267
Ingo Molnar77e54a12007-07-09 18:52:00 +0200268#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100269static int min_sched_granularity_ns = 100000; /* 100 usecs */
270static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
271static int min_wakeup_granularity_ns; /* 0 usecs */
272static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200273#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100274static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
275static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200276#endif /* CONFIG_SMP */
277#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200278
Mel Gorman5e771902010-05-24 14:32:31 -0700279#ifdef CONFIG_COMPACTION
280static int min_extfrag_threshold;
281static int max_extfrag_threshold = 1000;
282#endif
283
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700284static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200285 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200286 .procname = "sched_child_runs_first",
287 .data = &sysctl_sched_child_runs_first,
288 .maxlen = sizeof(unsigned int),
289 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800290 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200291 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530292#if defined(CONFIG_PREEMPT_TRACER) || defined(CONFIG_IRQSOFF_TRACER)
293 {
294 .procname = "preemptoff_tracing_threshold_ns",
295 .data = &sysctl_preemptoff_tracing_threshold_ns,
296 .maxlen = sizeof(unsigned int),
297 .mode = 0644,
298 .proc_handler = proc_dointvec,
299 },
Pavankumar Kondeti0d2621b2018-03-26 15:56:26 +0530300 {
301 .procname = "irqsoff_tracing_threshold_ns",
302 .data = &sysctl_irqsoff_tracing_threshold_ns,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
305 .proc_handler = proc_dointvec,
306 },
Pavankumar Kondeti97f08d42018-01-09 11:02:30 +0530307#endif
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800308#ifdef CONFIG_SCHED_WALT
309 {
310 .procname = "sched_cpu_high_irqload",
311 .data = &sysctl_sched_cpu_high_irqload,
312 .maxlen = sizeof(unsigned int),
313 .mode = 0644,
314 .proc_handler = proc_dointvec,
315 },
Joonwoo Park6f188472017-06-16 11:32:17 -0700316 {
317 .procname = "sched_group_upmigrate",
318 .data = &sysctl_sched_group_upmigrate_pct,
319 .maxlen = sizeof(unsigned int),
320 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700321 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700322 .extra1 = &sysctl_sched_group_downmigrate_pct,
323 },
324 {
325 .procname = "sched_group_downmigrate",
326 .data = &sysctl_sched_group_downmigrate_pct,
327 .maxlen = sizeof(unsigned int),
328 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700329 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700330 .extra1 = &zero,
331 .extra2 = &sysctl_sched_group_upmigrate_pct,
332 },
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530333 {
334 .procname = "sched_boost",
335 .data = &sysctl_sched_boost,
336 .maxlen = sizeof(unsigned int),
337 .mode = 0644,
338 .proc_handler = sched_boost_handler,
339 .extra1 = &zero,
340 .extra2 = &three,
341 },
Pavankumar Kondeti4e13d112018-01-25 01:12:08 +0530342 {
343 .procname = "sched_walt_rotate_big_tasks",
344 .data = &sysctl_sched_walt_rotate_big_tasks,
345 .maxlen = sizeof(unsigned int),
346 .mode = 0644,
347 .proc_handler = proc_dointvec_minmax,
348 .extra1 = &zero,
349 .extra2 = &one,
350 },
Lingutla Chandrasekhar57eb0712018-03-12 10:20:08 +0530351 {
352 .procname = "sched_initial_task_util",
353 .data = &sysctl_sched_init_task_load_pct,
354 .maxlen = sizeof(unsigned int),
355 .mode = 0644,
356 .proc_handler = proc_dointvec,
357 },
Abhijeet Dharmapurikar53ee4232018-06-15 09:34:34 -0700358 {
359 .procname = "sched_min_task_util_for_boost_colocation",
360 .data = &sysctl_sched_min_task_util_for_boost_colocation,
361 .maxlen = sizeof(unsigned int),
362 .mode = 0644,
363 .proc_handler = proc_dointvec_minmax,
364 .extra1 = &zero,
365 .extra2 = &one_thousand,
366 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800367#endif
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530368 {
369 .procname = "sched_upmigrate",
370 .data = &sysctl_sched_capacity_margin,
371 .maxlen = sizeof(unsigned int),
372 .mode = 0644,
373 .proc_handler = sched_updown_migrate_handler,
374 },
375 {
376 .procname = "sched_downmigrate",
377 .data = &sysctl_sched_capacity_margin_down,
378 .maxlen = sizeof(unsigned int),
379 .mode = 0644,
380 .proc_handler = sched_updown_migrate_handler,
381 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200382#ifdef CONFIG_SCHED_DEBUG
383 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100384 .procname = "sched_min_granularity_ns",
385 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200386 .maxlen = sizeof(unsigned int),
387 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800388 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100389 .extra1 = &min_sched_granularity_ns,
390 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200391 },
392 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200393 .procname = "sched_latency_ns",
394 .data = &sysctl_sched_latency,
395 .maxlen = sizeof(unsigned int),
396 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800397 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200398 .extra1 = &min_sched_granularity_ns,
399 .extra2 = &max_sched_granularity_ns,
400 },
401 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000402 .procname = "sched_sync_hint_enable",
403 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100404 .maxlen = sizeof(unsigned int),
405 .mode = 0644,
406 .proc_handler = proc_dointvec,
407 },
408 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100409 .procname = "sched_cstate_aware",
410 .data = &sysctl_sched_cstate_aware,
411 .maxlen = sizeof(unsigned int),
412 .mode = 0644,
413 .proc_handler = proc_dointvec,
414 },
415 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200416 .procname = "sched_wakeup_granularity_ns",
417 .data = &sysctl_sched_wakeup_granularity,
418 .maxlen = sizeof(unsigned int),
419 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800420 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200421 .extra1 = &min_wakeup_granularity_ns,
422 .extra2 = &max_wakeup_granularity_ns,
423 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200424#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200425 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100426 .procname = "sched_tunable_scaling",
427 .data = &sysctl_sched_tunable_scaling,
428 .maxlen = sizeof(enum sched_tunable_scaling),
429 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800430 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100431 .extra1 = &min_sched_tunable_scaling,
432 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200433 },
434 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900435 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200436 .data = &sysctl_sched_migration_cost,
437 .maxlen = sizeof(unsigned int),
438 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800439 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200440 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100441 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100442 .procname = "sched_nr_migrate",
443 .data = &sysctl_sched_nr_migrate,
444 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100445 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800446 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100447 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530448 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900449 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200450 .data = &sysctl_sched_time_avg,
451 .maxlen = sizeof(unsigned int),
452 .mode = 0644,
Pavankumar Kondeti12939492017-02-02 14:24:34 +0530453 .proc_handler = proc_dointvec_minmax,
454 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200455 },
456 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900457 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800458 .data = &sysctl_sched_shares_window,
459 .maxlen = sizeof(unsigned int),
460 .mode = 0644,
461 .proc_handler = proc_dointvec,
462 },
Mel Gormancb251762016-02-05 09:08:36 +0000463#ifdef CONFIG_SCHEDSTATS
464 {
465 .procname = "sched_schedstats",
466 .data = NULL,
467 .maxlen = sizeof(unsigned int),
468 .mode = 0644,
469 .proc_handler = sysctl_schedstats,
470 .extra1 = &zero,
471 .extra2 = &one,
472 },
473#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200474#endif /* CONFIG_SMP */
475#ifdef CONFIG_NUMA_BALANCING
476 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200477 .procname = "numa_balancing_scan_delay_ms",
478 .data = &sysctl_numa_balancing_scan_delay,
479 .maxlen = sizeof(unsigned int),
480 .mode = 0644,
481 .proc_handler = proc_dointvec,
482 },
483 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200484 .procname = "numa_balancing_scan_period_min_ms",
485 .data = &sysctl_numa_balancing_scan_period_min,
486 .maxlen = sizeof(unsigned int),
487 .mode = 0644,
488 .proc_handler = proc_dointvec,
489 },
490 {
491 .procname = "numa_balancing_scan_period_max_ms",
492 .data = &sysctl_numa_balancing_scan_period_max,
493 .maxlen = sizeof(unsigned int),
494 .mode = 0644,
495 .proc_handler = proc_dointvec,
496 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200497 {
498 .procname = "numa_balancing_scan_size_mb",
499 .data = &sysctl_numa_balancing_scan_size,
500 .maxlen = sizeof(unsigned int),
501 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400502 .proc_handler = proc_dointvec_minmax,
503 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200504 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100505 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800506 .procname = "numa_balancing",
507 .data = NULL, /* filled in by handler */
508 .maxlen = sizeof(unsigned int),
509 .mode = 0644,
510 .proc_handler = sysctl_numa_balancing,
511 .extra1 = &zero,
512 .extra2 = &one,
513 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200514#endif /* CONFIG_NUMA_BALANCING */
515#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200516 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100517 .procname = "sched_rt_period_us",
518 .data = &sysctl_sched_rt_period,
519 .maxlen = sizeof(unsigned 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 },
523 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100524 .procname = "sched_rt_runtime_us",
525 .data = &sysctl_sched_rt_runtime,
526 .maxlen = sizeof(int),
527 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800528 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100529 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600530 {
531 .procname = "sched_rr_timeslice_ms",
532 .data = &sched_rr_timeslice,
533 .maxlen = sizeof(int),
534 .mode = 0644,
535 .proc_handler = sched_rr_handler,
536 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100537#ifdef CONFIG_SCHED_AUTOGROUP
538 {
539 .procname = "sched_autogroup_enabled",
540 .data = &sysctl_sched_autogroup_enabled,
541 .maxlen = sizeof(unsigned int),
542 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800543 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100544 .extra1 = &zero,
545 .extra2 = &one,
546 },
547#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700548#ifdef CONFIG_CFS_BANDWIDTH
549 {
550 .procname = "sched_cfs_bandwidth_slice_us",
551 .data = &sysctl_sched_cfs_bandwidth_slice,
552 .maxlen = sizeof(unsigned int),
553 .mode = 0644,
554 .proc_handler = proc_dointvec_minmax,
555 .extra1 = &one,
556 },
557#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100558#ifdef CONFIG_SCHED_TUNE
559 {
560 .procname = "sched_cfs_boost",
561 .data = &sysctl_sched_cfs_boost,
562 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100563#ifdef CONFIG_CGROUP_SCHEDTUNE
564 .mode = 0444,
565#else
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100566 .mode = 0644,
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100567#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100568 .proc_handler = &sysctl_sched_cfs_boost_handler,
569 .extra1 = &zero,
570 .extra2 = &one_hundred,
571 },
572#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700573#ifdef CONFIG_PROVE_LOCKING
574 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700575 .procname = "prove_locking",
576 .data = &prove_locking,
577 .maxlen = sizeof(int),
578 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800579 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700580 },
581#endif
582#ifdef CONFIG_LOCK_STAT
583 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700584 .procname = "lock_stat",
585 .data = &lock_stat,
586 .maxlen = sizeof(int),
587 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800588 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700589 },
590#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200591 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 .procname = "panic",
593 .data = &panic_timeout,
594 .maxlen = sizeof(int),
595 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800596 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 },
Alex Kelly046d6622012-10-04 17:15:23 -0700598#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 .procname = "core_uses_pid",
601 .data = &core_uses_pid,
602 .maxlen = sizeof(int),
603 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800604 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 },
606 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 .procname = "core_pattern",
608 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700609 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700611 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 },
Neil Hormana2939802009-09-23 15:56:56 -0700613 {
Neil Hormana2939802009-09-23 15:56:56 -0700614 .procname = "core_pipe_limit",
615 .data = &core_pipe_limit,
616 .maxlen = sizeof(unsigned int),
617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700619 },
Alex Kelly046d6622012-10-04 17:15:23 -0700620#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800621#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700624 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800625 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800626 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700628 {
629 .procname = "sysctl_writes_strict",
630 .data = &sysctl_writes_strict,
631 .maxlen = sizeof(int),
632 .mode = 0644,
633 .proc_handler = proc_dointvec_minmax,
634 .extra1 = &neg_one,
635 .extra2 = &one,
636 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800637#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100638#ifdef CONFIG_LATENCYTOP
639 {
640 .procname = "latencytop",
641 .data = &latencytop_enabled,
642 .maxlen = sizeof(int),
643 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000644 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100645 },
646#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647#ifdef CONFIG_BLK_DEV_INITRD
648 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 .procname = "real-root-dev",
650 .data = &real_root_dev,
651 .maxlen = sizeof(int),
652 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800653 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 },
655#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700656 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700657 .procname = "print-fatal-signals",
658 .data = &print_fatal_signals,
659 .maxlen = sizeof(int),
660 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800661 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700662 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700663#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "reboot-cmd",
666 .data = reboot_command,
667 .maxlen = 256,
668 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800669 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 },
671 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 .procname = "stop-a",
673 .data = &stop_a_enabled,
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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .procname = "scons-poweroff",
680 .data = &scons_pwroff,
681 .maxlen = sizeof (int),
682 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 },
685#endif
David S. Miller08714202008-11-16 23:49:24 -0800686#ifdef CONFIG_SPARC64
687 {
David S. Miller08714202008-11-16 23:49:24 -0800688 .procname = "tsb-ratio",
689 .data = &sysctl_tsb_ratio,
690 .maxlen = sizeof (int),
691 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800692 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800693 },
694#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695#ifdef __hppa__
696 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 .procname = "soft-power",
698 .data = &pwrsw_enabled,
699 .maxlen = sizeof (int),
700 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800701 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530703#endif
704#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 .procname = "unaligned-trap",
707 .data = &unaligned_enabled,
708 .maxlen = sizeof (int),
709 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800710 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 },
712#endif
713 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 .procname = "ctrl-alt-del",
715 .data = &C_A_D,
716 .maxlen = sizeof(int),
717 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800718 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400720#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200721 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200722 .procname = "ftrace_enabled",
723 .data = &ftrace_enabled,
724 .maxlen = sizeof(int),
725 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800726 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200727 },
728#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500729#ifdef CONFIG_STACK_TRACER
730 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500731 .procname = "stack_tracer_enabled",
732 .data = &stack_tracer_enabled,
733 .maxlen = sizeof(int),
734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800735 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500736 },
737#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400738#ifdef CONFIG_TRACING
739 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100740 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400741 .data = &ftrace_dump_on_oops,
742 .maxlen = sizeof(int),
743 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800744 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400745 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400746 {
747 .procname = "traceoff_on_warning",
748 .data = &__disable_trace_on_warning,
749 .maxlen = sizeof(__disable_trace_on_warning),
750 .mode = 0644,
751 .proc_handler = proc_dointvec,
752 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500753 {
754 .procname = "tracepoint_printk",
755 .data = &tracepoint_printk,
756 .maxlen = sizeof(tracepoint_printk),
757 .mode = 0644,
758 .proc_handler = proc_dointvec,
759 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400760#endif
Dave Young2965faa2015-09-09 15:38:55 -0700761#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800762 {
763 .procname = "kexec_load_disabled",
764 .data = &kexec_load_disabled,
765 .maxlen = sizeof(int),
766 .mode = 0644,
767 /* only handle a transition from default "0" to "1" */
768 .proc_handler = proc_dointvec_minmax,
769 .extra1 = &one,
770 .extra2 = &one,
771 },
772#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200773#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 .procname = "modprobe",
776 .data = &modprobe_path,
777 .maxlen = KMOD_PATH_LEN,
778 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800779 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 },
Kees Cook3d433212009-04-02 15:49:29 -0700781 {
Kees Cook3d433212009-04-02 15:49:29 -0700782 .procname = "modules_disabled",
783 .data = &modules_disabled,
784 .maxlen = sizeof(int),
785 .mode = 0644,
786 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800787 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700788 .extra1 = &one,
789 .extra2 = &one,
790 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700792#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100795 .data = &uevent_helper,
796 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800798 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 },
Michael Marineau86d56132014-04-10 14:09:31 -0700800#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801#ifdef CONFIG_CHR_DEV_SG
802 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 .procname = "sg-big-buff",
804 .data = &sg_big_buff,
805 .maxlen = sizeof (int),
806 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800807 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 },
809#endif
810#ifdef CONFIG_BSD_PROCESS_ACCT
811 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 .procname = "acct",
813 .data = &acct_parm,
814 .maxlen = 3*sizeof(int),
815 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800816 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 },
818#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819#ifdef CONFIG_MAGIC_SYSRQ
820 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800822 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 .maxlen = sizeof (int),
824 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700825 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 },
827#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700828#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700831 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 .maxlen = sizeof (int),
833 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800834 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700836#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700839 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 .maxlen = sizeof(int),
841 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700842 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 },
844 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 .procname = "random",
846 .mode = 0555,
847 .child = random_table,
848 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 {
Eric Paris17f60a72011-04-01 17:07:50 -0400850 .procname = "usermodehelper",
851 .mode = 0555,
852 .child = usermodehelper_table,
853 },
854 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 .procname = "overflowuid",
856 .data = &overflowuid,
857 .maxlen = sizeof(int),
858 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800859 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 .extra1 = &minolduid,
861 .extra2 = &maxolduid,
862 },
863 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 .procname = "overflowgid",
865 .data = &overflowgid,
866 .maxlen = sizeof(int),
867 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800868 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 .extra1 = &minolduid,
870 .extra2 = &maxolduid,
871 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800872#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873#ifdef CONFIG_MATHEMU
874 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 .procname = "ieee_emulation_warnings",
876 .data = &sysctl_ieee_emulation_warnings,
877 .maxlen = sizeof(int),
878 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800879 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 },
881#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200884 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 .maxlen = sizeof(int),
886 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800887 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 },
889#endif
890 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 .procname = "pid_max",
892 .data = &pid_max,
893 .maxlen = sizeof (int),
894 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800895 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 .extra1 = &pid_max_min,
897 .extra2 = &pid_max_max,
898 },
899 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 .procname = "panic_on_oops",
901 .data = &panic_on_oops,
902 .maxlen = sizeof(int),
903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800906#if defined CONFIG_PRINTK
907 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800908 .procname = "printk",
909 .data = &console_loglevel,
910 .maxlen = 4*sizeof(int),
911 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800912 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800913 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700916 .data = &printk_ratelimit_state.interval,
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_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 },
921 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700923 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 .maxlen = sizeof(int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 },
Dave Youngaf913222009-09-22 16:43:33 -0700928 {
Dave Youngaf913222009-09-22 16:43:33 -0700929 .procname = "printk_delay",
930 .data = &printk_delay_msec,
931 .maxlen = sizeof(int),
932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800933 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700934 .extra1 = &zero,
935 .extra2 = &ten_thousand,
936 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700938 .procname = "printk_devkmsg",
939 .data = devkmsg_log_str,
940 .maxlen = DEVKMSG_STR_MAX_SIZE,
941 .mode = 0644,
942 .proc_handler = devkmsg_sysctl_set_loglvl,
943 },
944 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800945 .procname = "dmesg_restrict",
946 .data = &dmesg_restrict,
947 .maxlen = sizeof(int),
948 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700949 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800950 .extra1 = &zero,
951 .extra2 = &one,
952 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800953 {
954 .procname = "kptr_restrict",
955 .data = &kptr_restrict,
956 .maxlen = sizeof(int),
957 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700958 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800959 .extra1 = &zero,
960 .extra2 = &two,
961 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800962#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800963 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 .procname = "ngroups_max",
965 .data = &ngroups_max,
966 .maxlen = sizeof (int),
967 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800968 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 },
Dan Ballard73efc032011-10-31 17:11:20 -0700970 {
971 .procname = "cap_last_cap",
972 .data = (void *)&cap_last_cap,
973 .maxlen = sizeof(int),
974 .mode = 0444,
975 .proc_handler = proc_dointvec,
976 },
Don Zickus58687ac2010-05-07 17:11:44 -0400977#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500978 {
Don Zickus58687ac2010-05-07 17:11:44 -0400979 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200980 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500981 .maxlen = sizeof (int),
982 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700983 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700984 .extra1 = &zero,
985 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400986 },
987 {
988 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700989 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400990 .maxlen = sizeof(int),
991 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700992 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800993 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400994 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500995 },
Don Zickus2508ce12010-05-07 17:11:46 -0400996 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700997 .procname = "nmi_watchdog",
998 .data = &nmi_watchdog_enabled,
999 .maxlen = sizeof (int),
1000 .mode = 0644,
1001 .proc_handler = proc_nmi_watchdog,
1002 .extra1 = &zero,
1003#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
1004 .extra2 = &one,
1005#else
1006 .extra2 = &zero,
1007#endif
1008 },
1009 {
1010 .procname = "soft_watchdog",
1011 .data = &soft_watchdog_enabled,
1012 .maxlen = sizeof (int),
1013 .mode = 0644,
1014 .proc_handler = proc_soft_watchdog,
1015 .extra1 = &zero,
1016 .extra2 = &one,
1017 },
1018 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001019 .procname = "watchdog_cpumask",
1020 .data = &watchdog_cpumask_bits,
1021 .maxlen = NR_CPUS,
1022 .mode = 0644,
1023 .proc_handler = proc_watchdog_cpumask,
1024 },
1025 {
Don Zickus2508ce12010-05-07 17:11:46 -04001026 .procname = "softlockup_panic",
1027 .data = &softlockup_panic,
1028 .maxlen = sizeof(int),
1029 .mode = 0644,
1030 .proc_handler = proc_dointvec_minmax,
1031 .extra1 = &zero,
1032 .extra2 = &one,
1033 },
Don Zickusac1f5912015-11-05 18:44:44 -08001034#ifdef CONFIG_HARDLOCKUP_DETECTOR
1035 {
1036 .procname = "hardlockup_panic",
1037 .data = &hardlockup_panic,
1038 .maxlen = sizeof(int),
1039 .mode = 0644,
1040 .proc_handler = proc_dointvec_minmax,
1041 .extra1 = &zero,
1042 .extra2 = &one,
1043 },
1044#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001045#ifdef CONFIG_SMP
1046 {
1047 .procname = "softlockup_all_cpu_backtrace",
1048 .data = &sysctl_softlockup_all_cpu_backtrace,
1049 .maxlen = sizeof(int),
1050 .mode = 0644,
1051 .proc_handler = proc_dointvec_minmax,
1052 .extra1 = &zero,
1053 .extra2 = &one,
1054 },
Jiri Kosina55537872015-11-05 18:44:41 -08001055 {
1056 .procname = "hardlockup_all_cpu_backtrace",
1057 .data = &sysctl_hardlockup_all_cpu_backtrace,
1058 .maxlen = sizeof(int),
1059 .mode = 0644,
1060 .proc_handler = proc_dointvec_minmax,
1061 .extra1 = &zero,
1062 .extra2 = &one,
1063 },
Aaron Tomlined235872014-06-23 13:22:05 -07001064#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001065#endif
1066#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1067 {
1068 .procname = "unknown_nmi_panic",
1069 .data = &unknown_nmi_panic,
1070 .maxlen = sizeof (int),
1071 .mode = 0644,
1072 .proc_handler = proc_dointvec,
1073 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001074#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075#if defined(CONFIG_X86)
1076 {
Don Zickus8da5add2006-09-26 10:52:27 +02001077 .procname = "panic_on_unrecovered_nmi",
1078 .data = &panic_on_unrecovered_nmi,
1079 .maxlen = sizeof(int),
1080 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001081 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001082 },
1083 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001084 .procname = "panic_on_io_nmi",
1085 .data = &panic_on_io_nmi,
1086 .maxlen = sizeof(int),
1087 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001088 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001089 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001090#ifdef CONFIG_DEBUG_STACKOVERFLOW
1091 {
1092 .procname = "panic_on_stackoverflow",
1093 .data = &sysctl_panic_on_stackoverflow,
1094 .maxlen = sizeof(int),
1095 .mode = 0644,
1096 .proc_handler = proc_dointvec,
1097 },
1098#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001099 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 .procname = "bootloader_type",
1101 .data = &bootloader_type,
1102 .maxlen = sizeof (int),
1103 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001104 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001106 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001107 .procname = "bootloader_version",
1108 .data = &bootloader_version,
1109 .maxlen = sizeof (int),
1110 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001112 },
1113 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001114 .procname = "kstack_depth_to_print",
1115 .data = &kstack_depth_to_print,
1116 .maxlen = sizeof(int),
1117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001119 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001120 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001121 .procname = "io_delay_type",
1122 .data = &io_delay_type,
1123 .maxlen = sizeof(int),
1124 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001125 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001126 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001128#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 .procname = "randomize_va_space",
1131 .data = &randomize_va_space,
1132 .maxlen = sizeof(int),
1133 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001134 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001136#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001137#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001138 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001139 .procname = "spin_retry",
1140 .data = &spin_retry,
1141 .maxlen = sizeof (int),
1142 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001143 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001144 },
1145#endif
Len Brown673d5b42007-07-28 03:33:16 -04001146#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001147 {
Pavel Machekc255d842006-02-20 18:27:58 -08001148 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001149 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001150 .maxlen = sizeof (unsigned long),
1151 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001152 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001153 },
1154#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301155#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001156 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001157 .procname = "ignore-unaligned-usertrap",
1158 .data = &no_unaligned_warning,
1159 .maxlen = sizeof (int),
1160 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001161 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001162 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301163#endif
1164#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001165 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001166 .procname = "unaligned-dump-stack",
1167 .data = &unaligned_dump_stack,
1168 .maxlen = sizeof (int),
1169 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001170 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001171 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001172#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001173#ifdef CONFIG_DETECT_HUNG_TASK
1174 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001175 .procname = "hung_task_panic",
1176 .data = &sysctl_hung_task_panic,
1177 .maxlen = sizeof(int),
1178 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001179 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001180 .extra1 = &zero,
1181 .extra2 = &one,
1182 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001183 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001184 .procname = "hung_task_check_count",
1185 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001186 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001187 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001188 .proc_handler = proc_dointvec_minmax,
1189 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001190 },
1191 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001192 .procname = "hung_task_timeout_secs",
1193 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001194 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001195 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001196 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001197 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001198 },
1199 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001200 .procname = "hung_task_warnings",
1201 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001202 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001203 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001204 .proc_handler = proc_dointvec_minmax,
1205 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001206 },
Imran Khana9788f42017-09-18 15:48:30 +05301207 {
1208 .procname = "hung_task_selective_monitoring",
1209 .data = &sysctl_hung_task_selective_monitoring,
1210 .maxlen = sizeof(int),
1211 .mode = 0644,
1212 .proc_handler = proc_dointvec_minmax,
1213 .extra1 = &zero,
1214 .extra2 = &one,
1215 },
1216
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001217#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001218#ifdef CONFIG_RT_MUTEXES
1219 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001220 .procname = "max_lock_depth",
1221 .data = &max_lock_depth,
1222 .maxlen = sizeof(int),
1223 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001224 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001225 },
1226#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001227 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001228 .procname = "poweroff_cmd",
1229 .data = &poweroff_cmd,
1230 .maxlen = POWEROFF_CMD_PATH_LEN,
1231 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001232 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001233 },
David Howells0b77f5b2008-04-29 01:01:32 -07001234#ifdef CONFIG_KEYS
1235 {
David Howells0b77f5b2008-04-29 01:01:32 -07001236 .procname = "keys",
1237 .mode = 0555,
1238 .child = key_sysctls,
1239 },
1240#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001241#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001242 /*
1243 * User-space scripts rely on the existence of this file
1244 * as a feature check for perf_events being enabled.
1245 *
1246 * So it's an ABI, do not remove!
1247 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001248 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001249 .procname = "perf_event_paranoid",
1250 .data = &sysctl_perf_event_paranoid,
1251 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001252 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001253 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001254 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001255 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001256 .procname = "perf_event_mlock_kb",
1257 .data = &sysctl_perf_event_mlock,
1258 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001259 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001260 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001261 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001262 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001263 .procname = "perf_event_max_sample_rate",
1264 .data = &sysctl_perf_event_sample_rate,
1265 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001266 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001267 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001268 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001269 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001270 {
1271 .procname = "perf_cpu_time_max_percent",
1272 .data = &sysctl_perf_cpu_time_max_percent,
1273 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1274 .mode = 0644,
1275 .proc_handler = perf_cpu_time_max_percent_handler,
1276 .extra1 = &zero,
1277 .extra2 = &one_hundred,
1278 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001279 {
1280 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001281 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001282 .maxlen = sizeof(sysctl_perf_event_max_stack),
1283 .mode = 0644,
1284 .proc_handler = perf_event_max_stack_handler,
1285 .extra1 = &zero,
1286 .extra2 = &six_hundred_forty_kb,
1287 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001288 {
1289 .procname = "perf_event_max_contexts_per_stack",
1290 .data = &sysctl_perf_event_max_contexts_per_stack,
1291 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1292 .mode = 0644,
1293 .proc_handler = perf_event_max_stack_handler,
1294 .extra1 = &zero,
1295 .extra2 = &one_thousand,
1296 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001297#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001298#ifdef CONFIG_KMEMCHECK
1299 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001300 .procname = "kmemcheck",
1301 .data = &kmemcheck_enabled,
1302 .maxlen = sizeof(int),
1303 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001304 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001305 },
1306#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001307 {
1308 .procname = "panic_on_warn",
1309 .data = &panic_on_warn,
1310 .maxlen = sizeof(int),
1311 .mode = 0644,
1312 .proc_handler = proc_dointvec_minmax,
1313 .extra1 = &zero,
1314 .extra2 = &one,
1315 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001316#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1317 {
1318 .procname = "timer_migration",
1319 .data = &sysctl_timer_migration,
1320 .maxlen = sizeof(unsigned int),
1321 .mode = 0644,
1322 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001323 .extra1 = &zero,
1324 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001325 },
1326#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001327#ifdef CONFIG_BPF_SYSCALL
1328 {
1329 .procname = "unprivileged_bpf_disabled",
1330 .data = &sysctl_unprivileged_bpf_disabled,
1331 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1332 .mode = 0644,
1333 /* only handle a transition from default "0" to "1" */
1334 .proc_handler = proc_dointvec_minmax,
1335 .extra1 = &one,
1336 .extra2 = &one,
1337 },
1338#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001339#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1340 {
1341 .procname = "panic_on_rcu_stall",
1342 .data = &sysctl_panic_on_rcu_stall,
1343 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1344 .mode = 0644,
1345 .proc_handler = proc_dointvec_minmax,
1346 .extra1 = &zero,
1347 .extra2 = &one,
1348 },
1349#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001350#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001351 {
1352 .procname = "boot_reason",
1353 .data = &boot_reason,
1354 .maxlen = sizeof(int),
1355 .mode = 0444,
1356 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001357 },
1358
1359 {
1360 .procname = "cold_boot",
1361 .data = &cold_boot,
1362 .maxlen = sizeof(int),
1363 .mode = 0444,
1364 .proc_handler = proc_dointvec,
1365 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001366#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001367 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368};
1369
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001370static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 .procname = "overcommit_memory",
1373 .data = &sysctl_overcommit_memory,
1374 .maxlen = sizeof(sysctl_overcommit_memory),
1375 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001376 .proc_handler = proc_dointvec_minmax,
1377 .extra1 = &zero,
1378 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 },
1380 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001381 .procname = "panic_on_oom",
1382 .data = &sysctl_panic_on_oom,
1383 .maxlen = sizeof(sysctl_panic_on_oom),
1384 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001385 .proc_handler = proc_dointvec_minmax,
1386 .extra1 = &zero,
1387 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001388 },
1389 {
David Rientjesfe071d72007-10-16 23:25:56 -07001390 .procname = "oom_kill_allocating_task",
1391 .data = &sysctl_oom_kill_allocating_task,
1392 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1393 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001394 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001395 },
1396 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001397 .procname = "oom_dump_tasks",
1398 .data = &sysctl_oom_dump_tasks,
1399 .maxlen = sizeof(sysctl_oom_dump_tasks),
1400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001401 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001402 },
1403 {
Charan Teja Reddyf9920cf2018-05-01 20:20:20 +05301404 .procname = "reap_mem_on_sigkill",
1405 .data = &sysctl_reap_mem_on_sigkill,
1406 .maxlen = sizeof(sysctl_reap_mem_on_sigkill),
1407 .mode = 0644,
1408 .proc_handler = proc_dointvec,
1409 },
1410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .procname = "overcommit_ratio",
1412 .data = &sysctl_overcommit_ratio,
1413 .maxlen = sizeof(sysctl_overcommit_ratio),
1414 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001415 .proc_handler = overcommit_ratio_handler,
1416 },
1417 {
1418 .procname = "overcommit_kbytes",
1419 .data = &sysctl_overcommit_kbytes,
1420 .maxlen = sizeof(sysctl_overcommit_kbytes),
1421 .mode = 0644,
1422 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 },
1424 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425 .procname = "page-cluster",
1426 .data = &page_cluster,
1427 .maxlen = sizeof(int),
1428 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001429 .proc_handler = proc_dointvec_minmax,
1430 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 },
1432 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 .procname = "dirty_background_ratio",
1434 .data = &dirty_background_ratio,
1435 .maxlen = sizeof(dirty_background_ratio),
1436 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001437 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 .extra1 = &zero,
1439 .extra2 = &one_hundred,
1440 },
1441 {
David Rientjes2da02992009-01-06 14:39:31 -08001442 .procname = "dirty_background_bytes",
1443 .data = &dirty_background_bytes,
1444 .maxlen = sizeof(dirty_background_bytes),
1445 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001446 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001447 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001448 },
1449 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 .procname = "dirty_ratio",
1451 .data = &vm_dirty_ratio,
1452 .maxlen = sizeof(vm_dirty_ratio),
1453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 .extra1 = &zero,
1456 .extra2 = &one_hundred,
1457 },
1458 {
David Rientjes2da02992009-01-06 14:39:31 -08001459 .procname = "dirty_bytes",
1460 .data = &vm_dirty_bytes,
1461 .maxlen = sizeof(vm_dirty_bytes),
1462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001463 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001464 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001465 },
1466 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001468 .data = &dirty_writeback_interval,
1469 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001471 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472 },
1473 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001475 .data = &dirty_expire_interval,
1476 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001478 .proc_handler = proc_dointvec_minmax,
1479 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 },
1481 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001482 .procname = "dirtytime_expire_seconds",
1483 .data = &dirtytime_expire_interval,
1484 .maxlen = sizeof(dirty_expire_interval),
1485 .mode = 0644,
1486 .proc_handler = dirtytime_interval_handler,
1487 .extra1 = &zero,
1488 },
1489 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001490 .procname = "nr_pdflush_threads",
1491 .mode = 0444 /* read-only */,
1492 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 },
1494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .procname = "swappiness",
1496 .data = &vm_swappiness,
1497 .maxlen = sizeof(vm_swappiness),
1498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001499 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 .extra1 = &zero,
1501 .extra2 = &one_hundred,
1502 },
Vinayak Menonb9e4cc2b2018-06-11 18:58:39 +05301503 {
1504 .procname = "want_old_faultaround_pte",
1505 .data = &want_old_faultaround_pte,
1506 .maxlen = sizeof(want_old_faultaround_pte),
1507 .mode = 0644,
1508 .proc_handler = proc_dointvec_minmax,
1509 .extra1 = &zero,
1510 .extra2 = &one,
1511 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001513 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001515 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 .maxlen = sizeof(unsigned long),
1517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001518 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001519 },
1520#ifdef CONFIG_NUMA
1521 {
1522 .procname = "nr_hugepages_mempolicy",
1523 .data = NULL,
1524 .maxlen = sizeof(unsigned long),
1525 .mode = 0644,
1526 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001527 },
1528#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .procname = "hugetlb_shm_group",
1531 .data = &sysctl_hugetlb_shm_group,
1532 .maxlen = sizeof(gid_t),
1533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001534 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 },
Mel Gorman396faf02007-07-17 04:03:13 -07001536 {
Mel Gorman396faf02007-07-17 04:03:13 -07001537 .procname = "hugepages_treat_as_movable",
1538 .data = &hugepages_treat_as_movable,
1539 .maxlen = sizeof(int),
1540 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001541 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001542 },
Adam Litke54f9f802007-10-16 01:26:20 -07001543 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001544 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001545 .data = NULL,
1546 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001548 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001549 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550#endif
1551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552 .procname = "lowmem_reserve_ratio",
1553 .data = &sysctl_lowmem_reserve_ratio,
1554 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001556 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 },
1558 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001559 .procname = "drop_caches",
1560 .data = &sysctl_drop_caches,
1561 .maxlen = sizeof(int),
1562 .mode = 0644,
1563 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001564 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001565 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001566 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001567#ifdef CONFIG_COMPACTION
1568 {
1569 .procname = "compact_memory",
1570 .data = &sysctl_compact_memory,
1571 .maxlen = sizeof(int),
1572 .mode = 0200,
1573 .proc_handler = sysctl_compaction_handler,
1574 },
Mel Gorman5e771902010-05-24 14:32:31 -07001575 {
1576 .procname = "extfrag_threshold",
1577 .data = &sysctl_extfrag_threshold,
1578 .maxlen = sizeof(int),
1579 .mode = 0644,
1580 .proc_handler = sysctl_extfrag_handler,
1581 .extra1 = &min_extfrag_threshold,
1582 .extra2 = &max_extfrag_threshold,
1583 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001584 {
1585 .procname = "compact_unevictable_allowed",
1586 .data = &sysctl_compact_unevictable_allowed,
1587 .maxlen = sizeof(int),
1588 .mode = 0644,
1589 .proc_handler = proc_dointvec,
1590 .extra1 = &zero,
1591 .extra2 = &one,
1592 },
Mel Gorman5e771902010-05-24 14:32:31 -07001593
Mel Gorman76ab0f52010-05-24 14:32:28 -07001594#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001595 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 .procname = "min_free_kbytes",
1597 .data = &min_free_kbytes,
1598 .maxlen = sizeof(min_free_kbytes),
1599 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001600 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001601 .extra1 = &zero,
1602 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001603 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001604 .procname = "watermark_scale_factor",
1605 .data = &watermark_scale_factor,
1606 .maxlen = sizeof(watermark_scale_factor),
1607 .mode = 0644,
1608 .proc_handler = watermark_scale_factor_sysctl_handler,
Rik van Riel12462752011-09-01 15:26:50 -04001609 .extra1 = &zero,
1610 .extra2 = &zero,
1611 },
1612 {
1613 .procname = "extra_free_kbytes",
1614 .data = &extra_free_kbytes,
1615 .maxlen = sizeof(extra_free_kbytes),
1616 .mode = 0644,
1617 .proc_handler = min_free_kbytes_sysctl_handler,
1618 .extra1 = &zero,
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001619 },
1620 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001621 .procname = "percpu_pagelist_fraction",
1622 .data = &percpu_pagelist_fraction,
1623 .maxlen = sizeof(percpu_pagelist_fraction),
1624 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001625 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001626 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001627 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001628#ifdef CONFIG_MMU
1629 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630 .procname = "max_map_count",
1631 .data = &sysctl_max_map_count,
1632 .maxlen = sizeof(sysctl_max_map_count),
1633 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001634 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001635 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001637#else
1638 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001639 .procname = "nr_trim_pages",
1640 .data = &sysctl_nr_trim_pages,
1641 .maxlen = sizeof(sysctl_nr_trim_pages),
1642 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001643 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001644 .extra1 = &zero,
1645 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646#endif
1647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648 .procname = "laptop_mode",
1649 .data = &laptop_mode,
1650 .maxlen = sizeof(laptop_mode),
1651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001652 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653 },
1654 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 .procname = "block_dump",
1656 .data = &block_dump,
1657 .maxlen = sizeof(block_dump),
1658 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001659 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660 .extra1 = &zero,
1661 },
1662 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663 .procname = "vfs_cache_pressure",
1664 .data = &sysctl_vfs_cache_pressure,
1665 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1666 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001667 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668 .extra1 = &zero,
1669 },
1670#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1671 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001672 .procname = "legacy_va_layout",
1673 .data = &sysctl_legacy_va_layout,
1674 .maxlen = sizeof(sysctl_legacy_va_layout),
1675 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001676 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 .extra1 = &zero,
1678 },
1679#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001680#ifdef CONFIG_NUMA
1681 {
Christoph Lameter17436602006-01-18 17:42:32 -08001682 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001683 .data = &node_reclaim_mode,
1684 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001685 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001686 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001687 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001688 },
Christoph Lameter96146342006-07-03 00:24:13 -07001689 {
Christoph Lameter96146342006-07-03 00:24:13 -07001690 .procname = "min_unmapped_ratio",
1691 .data = &sysctl_min_unmapped_ratio,
1692 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001694 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001695 .extra1 = &zero,
1696 .extra2 = &one_hundred,
1697 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001698 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001699 .procname = "min_slab_ratio",
1700 .data = &sysctl_min_slab_ratio,
1701 .maxlen = sizeof(sysctl_min_slab_ratio),
1702 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001703 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001704 .extra1 = &zero,
1705 .extra2 = &one_hundred,
1706 },
Christoph Lameter17436602006-01-18 17:42:32 -08001707#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001708#ifdef CONFIG_SMP
1709 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001710 .procname = "stat_interval",
1711 .data = &sysctl_stat_interval,
1712 .maxlen = sizeof(sysctl_stat_interval),
1713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001714 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001715 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001716 {
1717 .procname = "stat_refresh",
1718 .data = NULL,
1719 .maxlen = 0,
1720 .mode = 0600,
1721 .proc_handler = vmstat_refresh,
1722 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001723#endif
David Howells6e141542009-12-15 19:27:45 +00001724#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001725 {
Eric Parised032182007-06-28 15:55:21 -04001726 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001727 .data = &dac_mmap_min_addr,
1728 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001729 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001730 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001731 },
David Howells6e141542009-12-15 19:27:45 +00001732#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001733#ifdef CONFIG_NUMA
1734 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001735 .procname = "numa_zonelist_order",
1736 .data = &numa_zonelist_order,
1737 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001739 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001740 },
1741#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001742#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001743 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001744 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001745 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001746#ifdef CONFIG_X86_32
1747 .data = &vdso32_enabled,
1748 .maxlen = sizeof(vdso32_enabled),
1749#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001750 .data = &vdso_enabled,
1751 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001752#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001753 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001754 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001755 .extra1 = &zero,
1756 },
1757#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001758#ifdef CONFIG_HIGHMEM
1759 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001760 .procname = "highmem_is_dirtyable",
1761 .data = &vm_highmem_is_dirtyable,
1762 .maxlen = sizeof(vm_highmem_is_dirtyable),
1763 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001764 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001765 .extra1 = &zero,
1766 .extra2 = &one,
1767 },
1768#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001769#ifdef CONFIG_MEMORY_FAILURE
1770 {
Andi Kleen6a460792009-09-16 11:50:15 +02001771 .procname = "memory_failure_early_kill",
1772 .data = &sysctl_memory_failure_early_kill,
1773 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1774 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001775 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001776 .extra1 = &zero,
1777 .extra2 = &one,
1778 },
1779 {
Andi Kleen6a460792009-09-16 11:50:15 +02001780 .procname = "memory_failure_recovery",
1781 .data = &sysctl_memory_failure_recovery,
1782 .maxlen = sizeof(sysctl_memory_failure_recovery),
1783 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001784 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001785 .extra1 = &zero,
1786 .extra2 = &one,
1787 },
1788#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001789 {
1790 .procname = "user_reserve_kbytes",
1791 .data = &sysctl_user_reserve_kbytes,
1792 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1793 .mode = 0644,
1794 .proc_handler = proc_doulongvec_minmax,
1795 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001796 {
1797 .procname = "admin_reserve_kbytes",
1798 .data = &sysctl_admin_reserve_kbytes,
1799 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1800 .mode = 0644,
1801 .proc_handler = proc_doulongvec_minmax,
1802 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001803#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1804 {
1805 .procname = "mmap_rnd_bits",
1806 .data = &mmap_rnd_bits,
1807 .maxlen = sizeof(mmap_rnd_bits),
1808 .mode = 0600,
1809 .proc_handler = proc_dointvec_minmax,
1810 .extra1 = (void *)&mmap_rnd_bits_min,
1811 .extra2 = (void *)&mmap_rnd_bits_max,
1812 },
1813#endif
1814#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1815 {
1816 .procname = "mmap_rnd_compat_bits",
1817 .data = &mmap_rnd_compat_bits,
1818 .maxlen = sizeof(mmap_rnd_compat_bits),
1819 .mode = 0600,
1820 .proc_handler = proc_dointvec_minmax,
1821 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1822 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1823 },
1824#endif
Vinayak Menonc1c6a992015-12-21 13:00:58 +05301825#ifdef CONFIG_SWAP
1826 {
1827 .procname = "swap_ratio",
1828 .data = &sysctl_swap_ratio,
1829 .maxlen = sizeof(sysctl_swap_ratio),
1830 .mode = 0644,
1831 .proc_handler = proc_dointvec_minmax,
1832 },
1833 {
1834 .procname = "swap_ratio_enable",
1835 .data = &sysctl_swap_ratio_enable,
1836 .maxlen = sizeof(sysctl_swap_ratio_enable),
1837 .mode = 0644,
1838 .proc_handler = proc_dointvec_minmax,
1839 },
1840#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001841 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842};
1843
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001844static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 .procname = "inode-nr",
1847 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001848 .maxlen = 2*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 = "inode-state",
1854 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001855 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001856 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001857 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001858 },
1859 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 .procname = "file-nr",
1861 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001862 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001864 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865 },
1866 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 .procname = "file-max",
1868 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001869 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001871 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872 },
1873 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001874 .procname = "nr_open",
1875 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001876 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001877 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001878 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001879 .extra1 = &sysctl_nr_open_min,
1880 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001881 },
1882 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001883 .procname = "dentry-state",
1884 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001885 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001887 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 },
1889 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001890 .procname = "overflowuid",
1891 .data = &fs_overflowuid,
1892 .maxlen = sizeof(int),
1893 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001894 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 .extra1 = &minolduid,
1896 .extra2 = &maxolduid,
1897 },
1898 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 .procname = "overflowgid",
1900 .data = &fs_overflowgid,
1901 .maxlen = sizeof(int),
1902 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001903 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904 .extra1 = &minolduid,
1905 .extra2 = &maxolduid,
1906 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001907#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001909 .procname = "leases-enable",
1910 .data = &leases_enable,
1911 .maxlen = sizeof(int),
1912 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001913 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001915#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916#ifdef CONFIG_DNOTIFY
1917 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918 .procname = "dir-notify-enable",
1919 .data = &dir_notify_enable,
1920 .maxlen = sizeof(int),
1921 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001922 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923 },
1924#endif
1925#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001926#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001927 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928 .procname = "lease-break-time",
1929 .data = &lease_break_time,
1930 .maxlen = sizeof(int),
1931 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001932 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001934#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001935#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001936 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001937 .procname = "aio-nr",
1938 .data = &aio_nr,
1939 .maxlen = sizeof(aio_nr),
1940 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001941 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942 },
1943 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944 .procname = "aio-max-nr",
1945 .data = &aio_max_nr,
1946 .maxlen = sizeof(aio_max_nr),
1947 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001948 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001949 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001950#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001951#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001952 {
Robert Love0399cb02005-07-13 12:38:18 -04001953 .procname = "inotify",
1954 .mode = 0555,
1955 .child = inotify_table,
1956 },
1957#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001958#ifdef CONFIG_EPOLL
1959 {
1960 .procname = "epoll",
1961 .mode = 0555,
1962 .child = epoll_table,
1963 },
1964#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001965#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001966 {
Kees Cook800179c2012-07-25 17:29:07 -07001967 .procname = "protected_symlinks",
1968 .data = &sysctl_protected_symlinks,
1969 .maxlen = sizeof(int),
1970 .mode = 0600,
1971 .proc_handler = proc_dointvec_minmax,
1972 .extra1 = &zero,
1973 .extra2 = &one,
1974 },
1975 {
1976 .procname = "protected_hardlinks",
1977 .data = &sysctl_protected_hardlinks,
1978 .maxlen = sizeof(int),
1979 .mode = 0600,
1980 .proc_handler = proc_dointvec_minmax,
1981 .extra1 = &zero,
1982 .extra2 = &one,
1983 },
1984 {
Alan Coxd6e71142005-06-23 00:09:43 -07001985 .procname = "suid_dumpable",
1986 .data = &suid_dumpable,
1987 .maxlen = sizeof(int),
1988 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001989 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001990 .extra1 = &zero,
1991 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001992 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001993#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1994 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001995 .procname = "binfmt_misc",
1996 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001997 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001998 },
1999#endif
Jens Axboeb492e952010-05-19 21:03:16 +02002000 {
Jens Axboeff9da692010-06-03 14:54:39 +02002001 .procname = "pipe-max-size",
2002 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002003 .maxlen = sizeof(int),
2004 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02002005 .proc_handler = &pipe_proc_fn,
2006 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002007 },
Willy Tarreau759c0112016-01-18 16:36:09 +01002008 {
2009 .procname = "pipe-user-pages-hard",
2010 .data = &pipe_user_pages_hard,
2011 .maxlen = sizeof(pipe_user_pages_hard),
2012 .mode = 0644,
2013 .proc_handler = proc_doulongvec_minmax,
2014 },
2015 {
2016 .procname = "pipe-user-pages-soft",
2017 .data = &pipe_user_pages_soft,
2018 .maxlen = sizeof(pipe_user_pages_soft),
2019 .mode = 0644,
2020 .proc_handler = proc_doulongvec_minmax,
2021 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05002022 {
2023 .procname = "mount-max",
2024 .data = &sysctl_mount_max,
2025 .maxlen = sizeof(unsigned int),
2026 .mode = 0644,
2027 .proc_handler = proc_dointvec_minmax,
2028 .extra1 = &one,
2029 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002030 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031};
2032
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002033static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07002034#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002035 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002036 .procname = "exception-trace",
2037 .data = &show_unhandled_signals,
2038 .maxlen = sizeof(int),
2039 .mode = 0644,
2040 .proc_handler = proc_dointvec
2041 },
2042#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002043#if defined(CONFIG_OPTPROBES)
2044 {
2045 .procname = "kprobes-optimization",
2046 .data = &sysctl_kprobes_optimization,
2047 .maxlen = sizeof(int),
2048 .mode = 0644,
2049 .proc_handler = proc_kprobes_optimization_handler,
2050 .extra1 = &zero,
2051 .extra2 = &one,
2052 },
2053#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002054 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055};
2056
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002057static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002058 { }
Robert Love0eeca282005-07-12 17:06:03 -04002059};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002061int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002062{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002063 struct ctl_table_header *hdr;
2064
2065 hdr = register_sysctl_table(sysctl_base_table);
2066 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002067 return 0;
2068}
2069
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002070#endif /* CONFIG_SYSCTL */
2071
Linus Torvalds1da177e2005-04-16 15:20:36 -07002072/*
2073 * /proc/sys support
2074 */
2075
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002076#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077
Kees Cookf8808302014-06-06 14:37:17 -07002078static int _proc_do_string(char *data, int maxlen, int write,
2079 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002080 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002081{
2082 size_t len;
2083 char __user *p;
2084 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002085
2086 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002087 *lenp = 0;
2088 return 0;
2089 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002090
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002091 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002092 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2093 /* Only continue writes not past the end of buffer. */
2094 len = strlen(data);
2095 if (len > maxlen - 1)
2096 len = maxlen - 1;
2097
2098 if (*ppos > len)
2099 return 0;
2100 len = *ppos;
2101 } else {
2102 /* Start writing from beginning of buffer. */
2103 len = 0;
2104 }
2105
Kees Cook2ca9bb42014-06-06 14:37:18 -07002106 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002107 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002108 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002109 if (get_user(c, p++))
2110 return -EFAULT;
2111 if (c == 0 || c == '\n')
2112 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002113 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002114 }
Kees Cookf8808302014-06-06 14:37:17 -07002115 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002116 } else {
2117 len = strlen(data);
2118 if (len > maxlen)
2119 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002120
2121 if (*ppos > len) {
2122 *lenp = 0;
2123 return 0;
2124 }
2125
2126 data += *ppos;
2127 len -= *ppos;
2128
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002129 if (len > *lenp)
2130 len = *lenp;
2131 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002132 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002133 return -EFAULT;
2134 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002135 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002136 return -EFAULT;
2137 len++;
2138 }
2139 *lenp = len;
2140 *ppos += len;
2141 }
2142 return 0;
2143}
2144
Kees Cookf4aacea2014-06-06 14:37:19 -07002145static void warn_sysctl_write(struct ctl_table *table)
2146{
2147 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2148 "This will not be supported in the future. To silence this\n"
2149 "warning, set kernel.sysctl_writes_strict = -1\n",
2150 current->comm, table->procname);
2151}
2152
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153/**
2154 * proc_dostring - read a string sysctl
2155 * @table: the sysctl table
2156 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157 * @buffer: the user buffer
2158 * @lenp: the size of the user buffer
2159 * @ppos: file position
2160 *
2161 * Reads/writes a string from/to the user buffer. If the kernel
2162 * buffer provided is not large enough to hold the string, the
2163 * string is truncated. The copied string is %NULL-terminated.
2164 * If the string is being read by the user process, it is copied
2165 * and a newline '\n' is added. It is truncated if the buffer is
2166 * not large enough.
2167 *
2168 * Returns 0 on success.
2169 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002170int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 void __user *buffer, size_t *lenp, loff_t *ppos)
2172{
Kees Cookf4aacea2014-06-06 14:37:19 -07002173 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2174 warn_sysctl_write(table);
2175
Kees Cookf8808302014-06-06 14:37:17 -07002176 return _proc_do_string((char *)(table->data), table->maxlen, write,
2177 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178}
2179
Amerigo Wang00b7c332010-05-05 00:26:45 +00002180static size_t proc_skip_spaces(char **buf)
2181{
2182 size_t ret;
2183 char *tmp = skip_spaces(*buf);
2184 ret = tmp - *buf;
2185 *buf = tmp;
2186 return ret;
2187}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002189static void proc_skip_char(char **buf, size_t *size, const char v)
2190{
2191 while (*size) {
2192 if (**buf != v)
2193 break;
2194 (*size)--;
2195 (*buf)++;
2196 }
2197}
2198
Amerigo Wang00b7c332010-05-05 00:26:45 +00002199#define TMPBUFLEN 22
2200/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002201 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002202 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002203 * @buf: a kernel buffer
2204 * @size: size of the kernel buffer
2205 * @val: this is where the number will be stored
2206 * @neg: set to %TRUE if number is negative
2207 * @perm_tr: a vector which contains the allowed trailers
2208 * @perm_tr_len: size of the perm_tr vector
2209 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002210 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002211 * In case of success %0 is returned and @buf and @size are updated with
2212 * the amount of bytes read. If @tr is non-NULL and a trailing
2213 * character exists (size is non-zero after returning from this
2214 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002215 */
2216static int proc_get_long(char **buf, size_t *size,
2217 unsigned long *val, bool *neg,
2218 const char *perm_tr, unsigned perm_tr_len, char *tr)
2219{
2220 int len;
2221 char *p, tmp[TMPBUFLEN];
2222
2223 if (!*size)
2224 return -EINVAL;
2225
2226 len = *size;
2227 if (len > TMPBUFLEN - 1)
2228 len = TMPBUFLEN - 1;
2229
2230 memcpy(tmp, *buf, len);
2231
2232 tmp[len] = 0;
2233 p = tmp;
2234 if (*p == '-' && *size > 1) {
2235 *neg = true;
2236 p++;
2237 } else
2238 *neg = false;
2239 if (!isdigit(*p))
2240 return -EINVAL;
2241
2242 *val = simple_strtoul(p, &p, 0);
2243
2244 len = p - tmp;
2245
2246 /* We don't know if the next char is whitespace thus we may accept
2247 * invalid integers (e.g. 1234...a) or two integers instead of one
2248 * (e.g. 123...1). So lets not allow such large numbers. */
2249 if (len == TMPBUFLEN - 1)
2250 return -EINVAL;
2251
2252 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2253 return -EINVAL;
2254
2255 if (tr && (len < *size))
2256 *tr = *p;
2257
2258 *buf += len;
2259 *size -= len;
2260
2261 return 0;
2262}
2263
2264/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002265 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002266 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002267 * @buf: the user buffer
2268 * @size: the size of the user buffer
2269 * @val: the integer to be converted
2270 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002271 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002272 * In case of success %0 is returned and @buf and @size are updated with
2273 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002274 */
2275static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2276 bool neg)
2277{
2278 int len;
2279 char tmp[TMPBUFLEN], *p = tmp;
2280
2281 sprintf(p, "%s%lu", neg ? "-" : "", val);
2282 len = strlen(tmp);
2283 if (len > *size)
2284 len = *size;
2285 if (copy_to_user(*buf, tmp, len))
2286 return -EFAULT;
2287 *size -= len;
2288 *buf += len;
2289 return 0;
2290}
2291#undef TMPBUFLEN
2292
2293static int proc_put_char(void __user **buf, size_t *size, char c)
2294{
2295 if (*size) {
2296 char __user **buffer = (char __user **)buf;
2297 if (put_user(c, *buffer))
2298 return -EFAULT;
2299 (*size)--, (*buffer)++;
2300 *buf = *buffer;
2301 }
2302 return 0;
2303}
2304
2305static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 int *valp,
2307 int write, void *data)
2308{
2309 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002310 if (*negp) {
2311 if (*lvalp > (unsigned long) INT_MAX + 1)
2312 return -EINVAL;
2313 *valp = -*lvalp;
2314 } else {
2315 if (*lvalp > (unsigned long) INT_MAX)
2316 return -EINVAL;
2317 *valp = *lvalp;
2318 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 } else {
2320 int val = *valp;
2321 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002322 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002323 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002325 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326 *lvalp = (unsigned long)val;
2327 }
2328 }
2329 return 0;
2330}
2331
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002332static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2333 int *valp,
2334 int write, void *data)
2335{
2336 if (write) {
2337 if (*negp)
2338 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002339 if (*lvalp > UINT_MAX)
2340 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002341 *valp = *lvalp;
2342 } else {
2343 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002344 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002345 *lvalp = (unsigned long)val;
2346 }
2347 return 0;
2348}
2349
Amerigo Wang00b7c332010-05-05 00:26:45 +00002350static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2351
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002352static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002353 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002354 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002355 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 int write, void *data),
2357 void *data)
2358{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002359 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002360 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002361 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362
Amerigo Wang00b7c332010-05-05 00:26:45 +00002363 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364 *lenp = 0;
2365 return 0;
2366 }
2367
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002368 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 vleft = table->maxlen / sizeof(*i);
2370 left = *lenp;
2371
2372 if (!conv)
2373 conv = do_proc_dointvec_conv;
2374
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002376 if (*ppos) {
2377 switch (sysctl_writes_strict) {
2378 case SYSCTL_WRITES_STRICT:
2379 goto out;
2380 case SYSCTL_WRITES_WARN:
2381 warn_sysctl_write(table);
2382 break;
2383 default:
2384 break;
2385 }
2386 }
2387
Amerigo Wang00b7c332010-05-05 00:26:45 +00002388 if (left > PAGE_SIZE - 1)
2389 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002390 p = kbuf = memdup_user_nul(buffer, left);
2391 if (IS_ERR(kbuf))
2392 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002393 }
2394
2395 for (; left && vleft--; i++, first=0) {
2396 unsigned long lval;
2397 bool neg;
2398
2399 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002400 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002401
J. R. Okajima563b0462010-05-25 16:10:14 -07002402 if (!left)
2403 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002404 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002405 proc_wspace_sep,
2406 sizeof(proc_wspace_sep), NULL);
2407 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002409 if (conv(&neg, &lval, i, 1, data)) {
2410 err = -EINVAL;
2411 break;
2412 }
2413 } else {
2414 if (conv(&neg, &lval, i, 0, data)) {
2415 err = -EINVAL;
2416 break;
2417 }
2418 if (!first)
2419 err = proc_put_char(&buffer, &left, '\t');
2420 if (err)
2421 break;
2422 err = proc_put_long(&buffer, &left, lval, neg);
2423 if (err)
2424 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 }
2426 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002427
2428 if (!write && !first && left && !err)
2429 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002430 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002431 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002432 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002433 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002434 if (first)
2435 return err ? : -EINVAL;
2436 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002438out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002440 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441}
2442
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002443static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002444 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002445 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002446 int write, void *data),
2447 void *data)
2448{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002449 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002450 buffer, lenp, ppos, conv, data);
2451}
2452
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453/**
2454 * proc_dointvec - read a vector of integers
2455 * @table: the sysctl table
2456 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 * @buffer: the user buffer
2458 * @lenp: the size of the user buffer
2459 * @ppos: file position
2460 *
2461 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2462 * values from/to the user buffer, treated as an ASCII string.
2463 *
2464 * Returns 0 on success.
2465 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002466int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 void __user *buffer, size_t *lenp, loff_t *ppos)
2468{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002469 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2470}
2471
2472/**
2473 * proc_douintvec - read a vector of unsigned integers
2474 * @table: the sysctl table
2475 * @write: %TRUE if this is a write to the sysctl file
2476 * @buffer: the user buffer
2477 * @lenp: the size of the user buffer
2478 * @ppos: file position
2479 *
2480 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2481 * values from/to the user buffer, treated as an ASCII string.
2482 *
2483 * Returns 0 on success.
2484 */
2485int proc_douintvec(struct ctl_table *table, int write,
2486 void __user *buffer, size_t *lenp, loff_t *ppos)
2487{
2488 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2489 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490}
2491
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002492/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002493 * Taint values can only be increased
2494 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002495 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002496static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002497 void __user *buffer, size_t *lenp, loff_t *ppos)
2498{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002499 struct ctl_table t;
2500 unsigned long tmptaint = get_taint();
2501 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002502
Bastian Blank91fcd412007-04-23 14:41:14 -07002503 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002504 return -EPERM;
2505
Andi Kleen25ddbb12008-10-15 22:01:41 -07002506 t = *table;
2507 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002508 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002509 if (err < 0)
2510 return err;
2511
2512 if (write) {
2513 /*
2514 * Poor man's atomic or. Not worth adding a primitive
2515 * to everyone's atomic.h for this
2516 */
2517 int i;
2518 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2519 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302520 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002521 }
2522 }
2523
2524 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002525}
2526
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002527#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002528static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002529 void __user *buffer, size_t *lenp, loff_t *ppos)
2530{
2531 if (write && !capable(CAP_SYS_ADMIN))
2532 return -EPERM;
2533
2534 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2535}
2536#endif
2537
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538struct do_proc_dointvec_minmax_conv_param {
2539 int *min;
2540 int *max;
2541};
2542
Amerigo Wang00b7c332010-05-05 00:26:45 +00002543static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2544 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545 int write, void *data)
2546{
2547 struct do_proc_dointvec_minmax_conv_param *param = data;
2548 if (write) {
2549 int val = *negp ? -*lvalp : *lvalp;
2550 if ((param->min && *param->min > val) ||
2551 (param->max && *param->max < val))
2552 return -EINVAL;
2553 *valp = val;
2554 } else {
2555 int val = *valp;
2556 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002557 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002558 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002560 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 *lvalp = (unsigned long)val;
2562 }
2563 }
2564 return 0;
2565}
2566
2567/**
2568 * proc_dointvec_minmax - read a vector of integers with min/max values
2569 * @table: the sysctl table
2570 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 * @buffer: the user buffer
2572 * @lenp: the size of the user buffer
2573 * @ppos: file position
2574 *
2575 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2576 * values from/to the user buffer, treated as an ASCII string.
2577 *
2578 * This routine will ensure the values are within the range specified by
2579 * table->extra1 (min) and table->extra2 (max).
2580 *
2581 * Returns 0 on success.
2582 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002583int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 void __user *buffer, size_t *lenp, loff_t *ppos)
2585{
2586 struct do_proc_dointvec_minmax_conv_param param = {
2587 .min = (int *) table->extra1,
2588 .max = (int *) table->extra2,
2589 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002590 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002591 do_proc_dointvec_minmax_conv, &param);
2592}
2593
Kees Cook54b50192012-07-30 14:39:18 -07002594static void validate_coredump_safety(void)
2595{
Alex Kelly046d6622012-10-04 17:15:23 -07002596#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002597 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002598 core_pattern[0] != '/' && core_pattern[0] != '|') {
2599 printk(KERN_WARNING "Unsafe core_pattern used with "\
2600 "suid_dumpable=2. Pipe handler or fully qualified "\
2601 "core dump path required.\n");
2602 }
Alex Kelly046d6622012-10-04 17:15:23 -07002603#endif
Kees Cook54b50192012-07-30 14:39:18 -07002604}
2605
2606static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2607 void __user *buffer, size_t *lenp, loff_t *ppos)
2608{
2609 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2610 if (!error)
2611 validate_coredump_safety();
2612 return error;
2613}
2614
Alex Kelly046d6622012-10-04 17:15:23 -07002615#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002616static int proc_dostring_coredump(struct ctl_table *table, int write,
2617 void __user *buffer, size_t *lenp, loff_t *ppos)
2618{
2619 int error = proc_dostring(table, write, buffer, lenp, ppos);
2620 if (!error)
2621 validate_coredump_safety();
2622 return error;
2623}
Alex Kelly046d6622012-10-04 17:15:23 -07002624#endif
Kees Cook54b50192012-07-30 14:39:18 -07002625
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002626static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627 void __user *buffer,
2628 size_t *lenp, loff_t *ppos,
2629 unsigned long convmul,
2630 unsigned long convdiv)
2631{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002632 unsigned long *i, *min, *max;
2633 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002634 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002635 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002636
2637 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 *lenp = 0;
2639 return 0;
2640 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002641
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002642 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643 min = (unsigned long *) table->extra1;
2644 max = (unsigned long *) table->extra2;
2645 vleft = table->maxlen / sizeof(unsigned long);
2646 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002647
2648 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002649 if (*ppos) {
2650 switch (sysctl_writes_strict) {
2651 case SYSCTL_WRITES_STRICT:
2652 goto out;
2653 case SYSCTL_WRITES_WARN:
2654 warn_sysctl_write(table);
2655 break;
2656 default:
2657 break;
2658 }
2659 }
2660
Amerigo Wang00b7c332010-05-05 00:26:45 +00002661 if (left > PAGE_SIZE - 1)
2662 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002663 p = kbuf = memdup_user_nul(buffer, left);
2664 if (IS_ERR(kbuf))
2665 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002666 }
2667
Eric Dumazet27b3d802010-10-07 12:59:29 -07002668 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002669 unsigned long val;
2670
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002672 bool neg;
2673
Al Viro70f6cbb2015-12-24 00:13:10 -05002674 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002675
Al Viro70f6cbb2015-12-24 00:13:10 -05002676 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002677 proc_wspace_sep,
2678 sizeof(proc_wspace_sep), NULL);
2679 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 break;
2681 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002682 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002683 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002684 if ((min && val < *min) || (max && val > *max))
2685 continue;
2686 *i = val;
2687 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002688 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002689 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002690 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002691 if (err)
2692 break;
2693 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002694 err = proc_put_long(&buffer, &left, val, false);
2695 if (err)
2696 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 }
2698 }
2699
Amerigo Wang00b7c332010-05-05 00:26:45 +00002700 if (!write && !first && left && !err)
2701 err = proc_put_char(&buffer, &left, '\n');
2702 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002703 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002704 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002705 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002706 if (first)
2707 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002708 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002709 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002710out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002711 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002712 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713}
2714
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002715static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002716 void __user *buffer,
2717 size_t *lenp, loff_t *ppos,
2718 unsigned long convmul,
2719 unsigned long convdiv)
2720{
2721 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002722 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002723}
2724
Linus Torvalds1da177e2005-04-16 15:20:36 -07002725/**
2726 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2727 * @table: the sysctl table
2728 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002729 * @buffer: the user buffer
2730 * @lenp: the size of the user buffer
2731 * @ppos: file position
2732 *
2733 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2734 * values from/to the user buffer, treated as an ASCII string.
2735 *
2736 * This routine will ensure the values are within the range specified by
2737 * table->extra1 (min) and table->extra2 (max).
2738 *
2739 * Returns 0 on success.
2740 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002741int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742 void __user *buffer, size_t *lenp, loff_t *ppos)
2743{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002744 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745}
2746
2747/**
2748 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2749 * @table: the sysctl table
2750 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751 * @buffer: the user buffer
2752 * @lenp: the size of the user buffer
2753 * @ppos: file position
2754 *
2755 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2756 * values from/to the user buffer, treated as an ASCII string. The values
2757 * are treated as milliseconds, and converted to jiffies when they are stored.
2758 *
2759 * This routine will ensure the values are within the range specified by
2760 * table->extra1 (min) and table->extra2 (max).
2761 *
2762 * Returns 0 on success.
2763 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002764int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002765 void __user *buffer,
2766 size_t *lenp, loff_t *ppos)
2767{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002768 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002769 lenp, ppos, HZ, 1000l);
2770}
2771
2772
Amerigo Wang00b7c332010-05-05 00:26:45 +00002773static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002774 int *valp,
2775 int write, void *data)
2776{
2777 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002778 if (*lvalp > LONG_MAX / HZ)
2779 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002780 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2781 } else {
2782 int val = *valp;
2783 unsigned long lval;
2784 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002785 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002786 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002787 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002788 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002789 lval = (unsigned long)val;
2790 }
2791 *lvalp = lval / HZ;
2792 }
2793 return 0;
2794}
2795
Amerigo Wang00b7c332010-05-05 00:26:45 +00002796static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002797 int *valp,
2798 int write, void *data)
2799{
2800 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002801 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2802 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002803 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2804 } else {
2805 int val = *valp;
2806 unsigned long lval;
2807 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002808 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002809 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002810 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002811 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002812 lval = (unsigned long)val;
2813 }
2814 *lvalp = jiffies_to_clock_t(lval);
2815 }
2816 return 0;
2817}
2818
Amerigo Wang00b7c332010-05-05 00:26:45 +00002819static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002820 int *valp,
2821 int write, void *data)
2822{
2823 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002824 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2825
2826 if (jif > INT_MAX)
2827 return 1;
2828 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002829 } else {
2830 int val = *valp;
2831 unsigned long lval;
2832 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002833 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002834 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002835 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002836 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002837 lval = (unsigned long)val;
2838 }
2839 *lvalp = jiffies_to_msecs(lval);
2840 }
2841 return 0;
2842}
2843
2844/**
2845 * proc_dointvec_jiffies - read a vector of integers as seconds
2846 * @table: the sysctl table
2847 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002848 * @buffer: the user buffer
2849 * @lenp: the size of the user buffer
2850 * @ppos: file position
2851 *
2852 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2853 * values from/to the user buffer, treated as an ASCII string.
2854 * The values read are assumed to be in seconds, and are converted into
2855 * jiffies.
2856 *
2857 * Returns 0 on success.
2858 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002859int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002860 void __user *buffer, size_t *lenp, loff_t *ppos)
2861{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002862 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002863 do_proc_dointvec_jiffies_conv,NULL);
2864}
2865
2866/**
2867 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2868 * @table: the sysctl table
2869 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002870 * @buffer: the user buffer
2871 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002872 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002873 *
2874 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2875 * values from/to the user buffer, treated as an ASCII string.
2876 * The values read are assumed to be in 1/USER_HZ seconds, and
2877 * are converted into jiffies.
2878 *
2879 * Returns 0 on success.
2880 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002881int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002882 void __user *buffer, size_t *lenp, loff_t *ppos)
2883{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002884 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002885 do_proc_dointvec_userhz_jiffies_conv,NULL);
2886}
2887
2888/**
2889 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2890 * @table: the sysctl table
2891 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002892 * @buffer: the user buffer
2893 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002894 * @ppos: file position
2895 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896 *
2897 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2898 * values from/to the user buffer, treated as an ASCII string.
2899 * The values read are assumed to be in 1/1000 seconds, and
2900 * are converted into jiffies.
2901 *
2902 * Returns 0 on success.
2903 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002904int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002905 void __user *buffer, size_t *lenp, loff_t *ppos)
2906{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002907 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002908 do_proc_dointvec_ms_jiffies_conv, NULL);
2909}
2910
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002911static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002912 void __user *buffer, size_t *lenp, loff_t *ppos)
2913{
2914 struct pid *new_pid;
2915 pid_t tmp;
2916 int r;
2917
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002918 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002919
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002920 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002921 lenp, ppos, NULL, NULL);
2922 if (r || !write)
2923 return r;
2924
2925 new_pid = find_get_pid(tmp);
2926 if (!new_pid)
2927 return -ESRCH;
2928
2929 put_pid(xchg(&cad_pid, new_pid));
2930 return 0;
2931}
2932
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002933/**
2934 * proc_do_large_bitmap - read/write from/to a large bitmap
2935 * @table: the sysctl table
2936 * @write: %TRUE if this is a write to the sysctl file
2937 * @buffer: the user buffer
2938 * @lenp: the size of the user buffer
2939 * @ppos: file position
2940 *
2941 * The bitmap is stored at table->data and the bitmap length (in bits)
2942 * in table->maxlen.
2943 *
2944 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2945 * large bitmaps may be represented in a compact manner. Writing into
2946 * the file will clear the bitmap then update it with the given input.
2947 *
2948 * Returns 0 on success.
2949 */
2950int proc_do_large_bitmap(struct ctl_table *table, int write,
2951 void __user *buffer, size_t *lenp, loff_t *ppos)
2952{
2953 int err = 0;
2954 bool first = 1;
2955 size_t left = *lenp;
2956 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002957 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002958 unsigned long *tmp_bitmap = NULL;
2959 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2960
WANG Cong122ff242014-05-12 16:04:53 -07002961 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002962 *lenp = 0;
2963 return 0;
2964 }
2965
2966 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002967 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002968
2969 if (left > PAGE_SIZE - 1)
2970 left = PAGE_SIZE - 1;
2971
Al Viro70f6cbb2015-12-24 00:13:10 -05002972 p = kbuf = memdup_user_nul(buffer, left);
2973 if (IS_ERR(kbuf))
2974 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002975
2976 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2977 GFP_KERNEL);
2978 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002979 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002980 return -ENOMEM;
2981 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002982 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002983 while (!err && left) {
2984 unsigned long val_a, val_b;
2985 bool neg;
2986
Al Viro70f6cbb2015-12-24 00:13:10 -05002987 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002988 sizeof(tr_a), &c);
2989 if (err)
2990 break;
2991 if (val_a >= bitmap_len || neg) {
2992 err = -EINVAL;
2993 break;
2994 }
2995
2996 val_b = val_a;
2997 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002998 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002999 left--;
3000 }
3001
3002 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05003003 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003004 &neg, tr_b, sizeof(tr_b),
3005 &c);
3006 if (err)
3007 break;
3008 if (val_b >= bitmap_len || neg ||
3009 val_a > val_b) {
3010 err = -EINVAL;
3011 break;
3012 }
3013 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003014 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003015 left--;
3016 }
3017 }
3018
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003019 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003020 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003021 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003022 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003023 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003024 } else {
3025 unsigned long bit_a, bit_b = 0;
3026
3027 while (left) {
3028 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3029 if (bit_a >= bitmap_len)
3030 break;
3031 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3032 bit_a + 1) - 1;
3033
3034 if (!first) {
3035 err = proc_put_char(&buffer, &left, ',');
3036 if (err)
3037 break;
3038 }
3039 err = proc_put_long(&buffer, &left, bit_a, false);
3040 if (err)
3041 break;
3042 if (bit_a != bit_b) {
3043 err = proc_put_char(&buffer, &left, '-');
3044 if (err)
3045 break;
3046 err = proc_put_long(&buffer, &left, bit_b, false);
3047 if (err)
3048 break;
3049 }
3050
3051 first = 0; bit_b++;
3052 }
3053 if (!err)
3054 err = proc_put_char(&buffer, &left, '\n');
3055 }
3056
3057 if (!err) {
3058 if (write) {
3059 if (*ppos)
3060 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3061 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003062 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003063 }
3064 kfree(tmp_bitmap);
3065 *lenp -= left;
3066 *ppos += *lenp;
3067 return 0;
3068 } else {
3069 kfree(tmp_bitmap);
3070 return err;
3071 }
3072}
3073
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003074static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp,
3075 int *valp, int write, void *data)
3076{
3077 if (write) {
Satya Durga Srinivasu Prabhala3929bf02018-08-24 12:23:08 -07003078 if (*negp || *lvalp == 0)
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003079 return -EINVAL;
3080 *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp;
3081 } else {
3082 *negp = false;
3083 *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp;
3084 }
3085
3086 return 0;
3087}
3088
3089/**
3090 * proc_douintvec_capacity - read a vector of integers in percentage and convert
3091 * into sched capacity
3092 * @table: the sysctl table
3093 * @write: %TRUE if this is a write to the sysctl file
3094 * @buffer: the user buffer
3095 * @lenp: the size of the user buffer
3096 * @ppos: file position
3097 *
3098 * Returns 0 on success.
3099 */
3100int proc_douintvec_capacity(struct ctl_table *table, int write,
3101 void __user *buffer, size_t *lenp, loff_t *ppos)
3102{
3103 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3104 do_proc_douintvec_capacity_conv, NULL);
3105}
3106
Jovi Zhang55610502011-01-12 17:00:45 -08003107#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003108
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003109int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003110 void __user *buffer, size_t *lenp, loff_t *ppos)
3111{
3112 return -ENOSYS;
3113}
3114
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003115int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003116 void __user *buffer, size_t *lenp, loff_t *ppos)
3117{
3118 return -ENOSYS;
3119}
3120
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003121int proc_douintvec(struct ctl_table *table, int write,
3122 void __user *buffer, size_t *lenp, loff_t *ppos)
3123{
3124 return -ENOSYS;
3125}
3126
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003127int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003128 void __user *buffer, size_t *lenp, loff_t *ppos)
3129{
3130 return -ENOSYS;
3131}
3132
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003133int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003134 void __user *buffer, size_t *lenp, loff_t *ppos)
3135{
3136 return -ENOSYS;
3137}
3138
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003139int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003140 void __user *buffer, size_t *lenp, loff_t *ppos)
3141{
3142 return -ENOSYS;
3143}
3144
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003145int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003146 void __user *buffer, size_t *lenp, loff_t *ppos)
3147{
3148 return -ENOSYS;
3149}
3150
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003151int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003152 void __user *buffer, size_t *lenp, loff_t *ppos)
3153{
3154 return -ENOSYS;
3155}
3156
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003157int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003158 void __user *buffer,
3159 size_t *lenp, loff_t *ppos)
3160{
3161 return -ENOSYS;
3162}
3163
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003164int proc_douintvec_capacity(struct ctl_table *table, int write,
3165 void __user *buffer, size_t *lenp, loff_t *ppos)
3166{
3167 return -ENOSYS;
3168}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003169
Jovi Zhang55610502011-01-12 17:00:45 -08003170#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003171
Linus Torvalds1da177e2005-04-16 15:20:36 -07003172/*
3173 * No sense putting this after each symbol definition, twice,
3174 * exception granted :-)
3175 */
3176EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003177EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003178EXPORT_SYMBOL(proc_dointvec_jiffies);
3179EXPORT_SYMBOL(proc_dointvec_minmax);
3180EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3181EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3182EXPORT_SYMBOL(proc_dostring);
3183EXPORT_SYMBOL(proc_doulongvec_minmax);
3184EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);