blob: 63400102f49baeb9f81e35f9c454a4c97e34567f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080022#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070027#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080028#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080029#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070031#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020033#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080066#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070067#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050068#include <linux/mount.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#include <asm/uaccess.h>
71#include <asm/processor.h>
72
Andi Kleen29cbc782006-09-30 01:47:55 +020073#ifdef CONFIG_X86
74#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010075#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010076#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020077#endif
David Howellsd550bbd2012-03-28 18:30:03 +010078#ifdef CONFIG_SPARC
79#include <asm/setup.h>
80#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080081#ifdef CONFIG_BSD_PROCESS_ACCT
82#include <linux/acct.h>
83#endif
Dave Young4f0e0562010-03-10 15:24:09 -080084#ifdef CONFIG_RT_MUTEXES
85#include <linux/rtmutex.h>
86#endif
Dave Young2edf5e42010-03-10 15:24:10 -080087#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88#include <linux/lockdep.h>
89#endif
Dave Young15485a42010-03-10 15:24:07 -080090#ifdef CONFIG_CHR_DEV_SG
91#include <scsi/sg.h>
92#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020093
Don Zickus58687ac2010-05-07 17:11:44 -040094#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050095#include <linux/nmi.h>
96#endif
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#if defined(CONFIG_SYSCTL)
99
100/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300111extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400117#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118static int sixty = 60;
119#endif
120
Aaron Tomlin270750db2014-01-20 17:34:13 +0000121static int __maybe_unused neg_one = -1;
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700126static int __maybe_unused three = 3;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700127static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800128static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129static int one_hundred = 100;
Rik van Riel12462752011-09-01 15:26:50 -0400130#ifdef CONFIG_PERF_EVENTS
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700131static int one_thousand = 1000;
Rik van Riel12462752011-09-01 15:26:50 -0400132#endif
Dave Youngaf913222009-09-22 16:43:33 -0700133#ifdef CONFIG_PRINTK
134static int ten_thousand = 10000;
135#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300136#ifdef CONFIG_PERF_EVENTS
137static int six_hundred_forty_kb = 640 * 1024;
138#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700139
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700140/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
141static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
144static int maxolduid = 65535;
145static int minolduid;
146
147static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700148static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Liu Hua80df2842014-04-07 15:38:57 -0700150/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
151#ifdef CONFIG_DETECT_HUNG_TASK
152static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
153#endif
154
Dave Youngd14f1722010-02-25 20:28:57 -0500155#ifdef CONFIG_INOTIFY_USER
156#include <linux/inotify.h>
157#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700158#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#endif
160
161#ifdef __hppa__
162extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530163#endif
164
165#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166extern int unaligned_enabled;
167#endif
168
Jes Sorensend2b176e2006-02-28 09:42:23 -0800169#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800170extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800171#endif
172
Vineet Guptab6fca722013-01-09 20:06:28 +0530173#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
174extern int no_unaligned_warning;
175#endif
176
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700177#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700178
179#define SYSCTL_WRITES_LEGACY -1
180#define SYSCTL_WRITES_WARN 0
181#define SYSCTL_WRITES_STRICT 1
182
Kees Cook41662f52016-01-20 15:00:45 -0800183static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700184
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700185static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700186 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700187static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800188 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700189#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700190
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700191#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700192static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700193 void __user *buffer, size_t *lenp, loff_t *ppos);
194#endif
195
Kees Cook54b50192012-07-30 14:39:18 -0700196static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
197 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700198#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700199static int proc_dostring_coredump(struct ctl_table *table, int write,
200 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700201#endif
Kees Cook54b50192012-07-30 14:39:18 -0700202
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700203#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800204/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100205static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700206
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700207static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700208 void __user *buffer, size_t *lenp,
209 loff_t *ppos)
210{
211 int error;
212
213 error = proc_dointvec(table, write, buffer, lenp, ppos);
214 if (error)
215 return error;
216
217 if (write)
218 sysrq_toggle_support(__sysrq_enabled);
219
220 return 0;
221}
222
223#endif
224
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700225static struct ctl_table kern_table[];
226static struct ctl_table vm_table[];
227static struct ctl_table fs_table[];
228static struct ctl_table debug_table[];
229static struct ctl_table dev_table[];
230extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800231#ifdef CONFIG_EPOLL
232extern struct ctl_table epoll_table[];
233#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
235#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
236int sysctl_legacy_va_layout;
237#endif
238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239/* The default sysctl tables: */
240
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800241static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .procname = "kernel",
244 .mode = 0555,
245 .child = kern_table,
246 },
247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .procname = "vm",
249 .mode = 0555,
250 .child = vm_table,
251 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 .procname = "fs",
254 .mode = 0555,
255 .child = fs_table,
256 },
257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 .procname = "debug",
259 .mode = 0555,
260 .child = debug_table,
261 },
262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 .procname = "dev",
264 .mode = 0555,
265 .child = dev_table,
266 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700267 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268};
269
Ingo Molnar77e54a12007-07-09 18:52:00 +0200270#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100271static int min_sched_granularity_ns = 100000; /* 100 usecs */
272static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
273static int min_wakeup_granularity_ns; /* 0 usecs */
274static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200275#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100276static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
277static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200278#endif /* CONFIG_SMP */
279#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200280
Mel Gorman5e771902010-05-24 14:32:31 -0700281#ifdef CONFIG_COMPACTION
282static int min_extfrag_threshold;
283static int max_extfrag_threshold = 1000;
284#endif
285
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700286static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200287 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200288 .procname = "sched_child_runs_first",
289 .data = &sysctl_sched_child_runs_first,
290 .maxlen = sizeof(unsigned int),
291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800292 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200293 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800294#ifdef CONFIG_SCHED_WALT
295 {
296 .procname = "sched_cpu_high_irqload",
297 .data = &sysctl_sched_cpu_high_irqload,
298 .maxlen = sizeof(unsigned int),
299 .mode = 0644,
300 .proc_handler = proc_dointvec,
301 },
Joonwoo Park6f188472017-06-16 11:32:17 -0700302 {
303 .procname = "sched_group_upmigrate",
304 .data = &sysctl_sched_group_upmigrate_pct,
305 .maxlen = sizeof(unsigned int),
306 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700307 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700308 .extra1 = &sysctl_sched_group_downmigrate_pct,
309 },
310 {
311 .procname = "sched_group_downmigrate",
312 .data = &sysctl_sched_group_downmigrate_pct,
313 .maxlen = sizeof(unsigned int),
314 .mode = 0644,
Joonwoo Park6f188472017-06-16 11:32:17 -0700315 .proc_handler = walt_proc_update_handler,
Joonwoo Park6f188472017-06-16 11:32:17 -0700316 .extra1 = &zero,
317 .extra2 = &sysctl_sched_group_upmigrate_pct,
318 },
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530319 {
320 .procname = "sched_boost",
321 .data = &sysctl_sched_boost,
322 .maxlen = sizeof(unsigned int),
323 .mode = 0644,
324 .proc_handler = sched_boost_handler,
325 .extra1 = &zero,
326 .extra2 = &three,
327 },
Pavankumar Kondeti4e13d112018-01-25 01:12:08 +0530328 {
329 .procname = "sched_walt_rotate_big_tasks",
330 .data = &sysctl_sched_walt_rotate_big_tasks,
331 .maxlen = sizeof(unsigned int),
332 .mode = 0644,
333 .proc_handler = proc_dointvec_minmax,
334 .extra1 = &zero,
335 .extra2 = &one,
336 },
Lingutla Chandrasekhar57eb0712018-03-12 10:20:08 +0530337 {
338 .procname = "sched_initial_task_util",
339 .data = &sysctl_sched_init_task_load_pct,
340 .maxlen = sizeof(unsigned int),
341 .mode = 0644,
342 .proc_handler = proc_dointvec,
343 },
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800344#endif
Pavankumar Kondetid0b9bfb2018-01-11 13:46:34 +0530345 {
346 .procname = "sched_upmigrate",
347 .data = &sysctl_sched_capacity_margin,
348 .maxlen = sizeof(unsigned int),
349 .mode = 0644,
350 .proc_handler = sched_updown_migrate_handler,
351 },
352 {
353 .procname = "sched_downmigrate",
354 .data = &sysctl_sched_capacity_margin_down,
355 .maxlen = sizeof(unsigned int),
356 .mode = 0644,
357 .proc_handler = sched_updown_migrate_handler,
358 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200359#ifdef CONFIG_SCHED_DEBUG
360 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100361 .procname = "sched_min_granularity_ns",
362 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200363 .maxlen = sizeof(unsigned int),
364 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800365 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100366 .extra1 = &min_sched_granularity_ns,
367 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200368 },
369 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200370 .procname = "sched_latency_ns",
371 .data = &sysctl_sched_latency,
372 .maxlen = sizeof(unsigned int),
373 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800374 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200375 .extra1 = &min_sched_granularity_ns,
376 .extra2 = &max_sched_granularity_ns,
377 },
378 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000379 .procname = "sched_sync_hint_enable",
380 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec,
384 },
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -0700385#ifdef CONFIG_SCHED_WALT
386 {
387 .procname = "sched_use_walt_cpu_util",
388 .data = &sysctl_sched_use_walt_cpu_util,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
391 .proc_handler = proc_dointvec,
392 },
393 {
394 .procname = "sched_use_walt_task_util",
395 .data = &sysctl_sched_use_walt_task_util,
396 .maxlen = sizeof(unsigned int),
397 .mode = 0644,
398 .proc_handler = proc_dointvec,
399 },
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -0700400#endif
Juri Lelli1931b932016-07-29 14:04:11 +0100401 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100402 .procname = "sched_cstate_aware",
403 .data = &sysctl_sched_cstate_aware,
404 .maxlen = sizeof(unsigned int),
405 .mode = 0644,
406 .proc_handler = proc_dointvec,
407 },
408 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200409 .procname = "sched_wakeup_granularity_ns",
410 .data = &sysctl_sched_wakeup_granularity,
411 .maxlen = sizeof(unsigned int),
412 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800413 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200414 .extra1 = &min_wakeup_granularity_ns,
415 .extra2 = &max_wakeup_granularity_ns,
416 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200417#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200418 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100419 .procname = "sched_tunable_scaling",
420 .data = &sysctl_sched_tunable_scaling,
421 .maxlen = sizeof(enum sched_tunable_scaling),
422 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800423 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100424 .extra1 = &min_sched_tunable_scaling,
425 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200426 },
427 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900428 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200429 .data = &sysctl_sched_migration_cost,
430 .maxlen = sizeof(unsigned int),
431 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800432 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200433 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100434 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100435 .procname = "sched_nr_migrate",
436 .data = &sysctl_sched_nr_migrate,
437 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100438 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800439 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100440 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530441 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900442 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200443 .data = &sysctl_sched_time_avg,
444 .maxlen = sizeof(unsigned int),
445 .mode = 0644,
Pavankumar Kondeti12939492017-02-02 14:24:34 +0530446 .proc_handler = proc_dointvec_minmax,
447 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200448 },
449 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900450 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800451 .data = &sysctl_sched_shares_window,
452 .maxlen = sizeof(unsigned int),
453 .mode = 0644,
454 .proc_handler = proc_dointvec,
455 },
Mel Gormancb251762016-02-05 09:08:36 +0000456#ifdef CONFIG_SCHEDSTATS
457 {
458 .procname = "sched_schedstats",
459 .data = NULL,
460 .maxlen = sizeof(unsigned int),
461 .mode = 0644,
462 .proc_handler = sysctl_schedstats,
463 .extra1 = &zero,
464 .extra2 = &one,
465 },
466#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200467#endif /* CONFIG_SMP */
468#ifdef CONFIG_NUMA_BALANCING
469 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200470 .procname = "numa_balancing_scan_delay_ms",
471 .data = &sysctl_numa_balancing_scan_delay,
472 .maxlen = sizeof(unsigned int),
473 .mode = 0644,
474 .proc_handler = proc_dointvec,
475 },
476 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200477 .procname = "numa_balancing_scan_period_min_ms",
478 .data = &sysctl_numa_balancing_scan_period_min,
479 .maxlen = sizeof(unsigned int),
480 .mode = 0644,
481 .proc_handler = proc_dointvec,
482 },
483 {
484 .procname = "numa_balancing_scan_period_max_ms",
485 .data = &sysctl_numa_balancing_scan_period_max,
486 .maxlen = sizeof(unsigned int),
487 .mode = 0644,
488 .proc_handler = proc_dointvec,
489 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200490 {
491 .procname = "numa_balancing_scan_size_mb",
492 .data = &sysctl_numa_balancing_scan_size,
493 .maxlen = sizeof(unsigned int),
494 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400495 .proc_handler = proc_dointvec_minmax,
496 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200497 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100498 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800499 .procname = "numa_balancing",
500 .data = NULL, /* filled in by handler */
501 .maxlen = sizeof(unsigned int),
502 .mode = 0644,
503 .proc_handler = sysctl_numa_balancing,
504 .extra1 = &zero,
505 .extra2 = &one,
506 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200507#endif /* CONFIG_NUMA_BALANCING */
508#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200509 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100510 .procname = "sched_rt_period_us",
511 .data = &sysctl_sched_rt_period,
512 .maxlen = sizeof(unsigned int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100515 },
516 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100517 .procname = "sched_rt_runtime_us",
518 .data = &sysctl_sched_rt_runtime,
519 .maxlen = sizeof(int),
520 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800521 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100522 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600523 {
524 .procname = "sched_rr_timeslice_ms",
525 .data = &sched_rr_timeslice,
526 .maxlen = sizeof(int),
527 .mode = 0644,
528 .proc_handler = sched_rr_handler,
529 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100530#ifdef CONFIG_SCHED_AUTOGROUP
531 {
532 .procname = "sched_autogroup_enabled",
533 .data = &sysctl_sched_autogroup_enabled,
534 .maxlen = sizeof(unsigned int),
535 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800536 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100537 .extra1 = &zero,
538 .extra2 = &one,
539 },
540#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700541#ifdef CONFIG_CFS_BANDWIDTH
542 {
543 .procname = "sched_cfs_bandwidth_slice_us",
544 .data = &sysctl_sched_cfs_bandwidth_slice,
545 .maxlen = sizeof(unsigned int),
546 .mode = 0644,
547 .proc_handler = proc_dointvec_minmax,
548 .extra1 = &one,
549 },
550#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100551#ifdef CONFIG_SCHED_TUNE
552 {
553 .procname = "sched_cfs_boost",
554 .data = &sysctl_sched_cfs_boost,
555 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100556#ifdef CONFIG_CGROUP_SCHEDTUNE
557 .mode = 0444,
558#else
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100559 .mode = 0644,
Patrick Bellasiffbceda2015-06-23 09:17:54 +0100560#endif
Patrick Bellasi62c1c062015-06-22 18:11:44 +0100561 .proc_handler = &sysctl_sched_cfs_boost_handler,
562 .extra1 = &zero,
563 .extra2 = &one_hundred,
564 },
565#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700566#ifdef CONFIG_PROVE_LOCKING
567 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700568 .procname = "prove_locking",
569 .data = &prove_locking,
570 .maxlen = sizeof(int),
571 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800572 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700573 },
574#endif
575#ifdef CONFIG_LOCK_STAT
576 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700577 .procname = "lock_stat",
578 .data = &lock_stat,
579 .maxlen = sizeof(int),
580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700582 },
583#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200584 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 .procname = "panic",
586 .data = &panic_timeout,
587 .maxlen = sizeof(int),
588 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800589 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 },
Alex Kelly046d6622012-10-04 17:15:23 -0700591#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 .procname = "core_uses_pid",
594 .data = &core_uses_pid,
595 .maxlen = sizeof(int),
596 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800597 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 },
599 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 .procname = "core_pattern",
601 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700602 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700604 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 },
Neil Hormana2939802009-09-23 15:56:56 -0700606 {
Neil Hormana2939802009-09-23 15:56:56 -0700607 .procname = "core_pipe_limit",
608 .data = &core_pipe_limit,
609 .maxlen = sizeof(unsigned int),
610 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800611 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700612 },
Alex Kelly046d6622012-10-04 17:15:23 -0700613#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800614#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700617 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800618 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800619 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700621 {
622 .procname = "sysctl_writes_strict",
623 .data = &sysctl_writes_strict,
624 .maxlen = sizeof(int),
625 .mode = 0644,
626 .proc_handler = proc_dointvec_minmax,
627 .extra1 = &neg_one,
628 .extra2 = &one,
629 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800630#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100631#ifdef CONFIG_LATENCYTOP
632 {
633 .procname = "latencytop",
634 .data = &latencytop_enabled,
635 .maxlen = sizeof(int),
636 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000637 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100638 },
639#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640#ifdef CONFIG_BLK_DEV_INITRD
641 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .procname = "real-root-dev",
643 .data = &real_root_dev,
644 .maxlen = sizeof(int),
645 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800646 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 },
648#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700649 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700650 .procname = "print-fatal-signals",
651 .data = &print_fatal_signals,
652 .maxlen = sizeof(int),
653 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800654 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700655 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700656#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .procname = "reboot-cmd",
659 .data = reboot_command,
660 .maxlen = 256,
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 },
664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "stop-a",
666 .data = &stop_a_enabled,
667 .maxlen = sizeof (int),
668 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800669 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 },
671 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 .procname = "scons-poweroff",
673 .data = &scons_pwroff,
674 .maxlen = sizeof (int),
675 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800676 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 },
678#endif
David S. Miller08714202008-11-16 23:49:24 -0800679#ifdef CONFIG_SPARC64
680 {
David S. Miller08714202008-11-16 23:49:24 -0800681 .procname = "tsb-ratio",
682 .data = &sysctl_tsb_ratio,
683 .maxlen = sizeof (int),
684 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800685 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800686 },
687#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688#ifdef __hppa__
689 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 .procname = "soft-power",
691 .data = &pwrsw_enabled,
692 .maxlen = sizeof (int),
693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800694 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530696#endif
697#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 .procname = "unaligned-trap",
700 .data = &unaligned_enabled,
701 .maxlen = sizeof (int),
702 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800703 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 },
705#endif
706 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 .procname = "ctrl-alt-del",
708 .data = &C_A_D,
709 .maxlen = sizeof(int),
710 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800711 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400713#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200714 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200715 .procname = "ftrace_enabled",
716 .data = &ftrace_enabled,
717 .maxlen = sizeof(int),
718 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800719 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200720 },
721#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500722#ifdef CONFIG_STACK_TRACER
723 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500724 .procname = "stack_tracer_enabled",
725 .data = &stack_tracer_enabled,
726 .maxlen = sizeof(int),
727 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800728 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500729 },
730#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400731#ifdef CONFIG_TRACING
732 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100733 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400734 .data = &ftrace_dump_on_oops,
735 .maxlen = sizeof(int),
736 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800737 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400738 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400739 {
740 .procname = "traceoff_on_warning",
741 .data = &__disable_trace_on_warning,
742 .maxlen = sizeof(__disable_trace_on_warning),
743 .mode = 0644,
744 .proc_handler = proc_dointvec,
745 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500746 {
747 .procname = "tracepoint_printk",
748 .data = &tracepoint_printk,
749 .maxlen = sizeof(tracepoint_printk),
750 .mode = 0644,
751 .proc_handler = proc_dointvec,
752 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400753#endif
Dave Young2965faa2015-09-09 15:38:55 -0700754#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800755 {
756 .procname = "kexec_load_disabled",
757 .data = &kexec_load_disabled,
758 .maxlen = sizeof(int),
759 .mode = 0644,
760 /* only handle a transition from default "0" to "1" */
761 .proc_handler = proc_dointvec_minmax,
762 .extra1 = &one,
763 .extra2 = &one,
764 },
765#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200766#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 .procname = "modprobe",
769 .data = &modprobe_path,
770 .maxlen = KMOD_PATH_LEN,
771 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800772 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 },
Kees Cook3d433212009-04-02 15:49:29 -0700774 {
Kees Cook3d433212009-04-02 15:49:29 -0700775 .procname = "modules_disabled",
776 .data = &modules_disabled,
777 .maxlen = sizeof(int),
778 .mode = 0644,
779 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800780 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700781 .extra1 = &one,
782 .extra2 = &one,
783 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700785#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100788 .data = &uevent_helper,
789 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800791 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 },
Michael Marineau86d56132014-04-10 14:09:31 -0700793#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794#ifdef CONFIG_CHR_DEV_SG
795 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 .procname = "sg-big-buff",
797 .data = &sg_big_buff,
798 .maxlen = sizeof (int),
799 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800800 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 },
802#endif
803#ifdef CONFIG_BSD_PROCESS_ACCT
804 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 .procname = "acct",
806 .data = &acct_parm,
807 .maxlen = 3*sizeof(int),
808 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800809 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 },
811#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812#ifdef CONFIG_MAGIC_SYSRQ
813 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800815 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 .maxlen = sizeof (int),
817 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700818 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 },
820#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700821#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700824 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 .maxlen = sizeof (int),
826 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800827 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700829#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700832 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 .maxlen = sizeof(int),
834 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700835 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 },
837 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 .procname = "random",
839 .mode = 0555,
840 .child = random_table,
841 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 {
Eric Paris17f60a72011-04-01 17:07:50 -0400843 .procname = "usermodehelper",
844 .mode = 0555,
845 .child = usermodehelper_table,
846 },
847 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 .procname = "overflowuid",
849 .data = &overflowuid,
850 .maxlen = sizeof(int),
851 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800852 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 .extra1 = &minolduid,
854 .extra2 = &maxolduid,
855 },
856 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 .procname = "overflowgid",
858 .data = &overflowgid,
859 .maxlen = sizeof(int),
860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 .extra1 = &minolduid,
863 .extra2 = &maxolduid,
864 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800865#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866#ifdef CONFIG_MATHEMU
867 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 .procname = "ieee_emulation_warnings",
869 .data = &sysctl_ieee_emulation_warnings,
870 .maxlen = sizeof(int),
871 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800872 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 },
874#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200877 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 .maxlen = sizeof(int),
879 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800880 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 },
882#endif
883 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 .procname = "pid_max",
885 .data = &pid_max,
886 .maxlen = sizeof (int),
887 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800888 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 .extra1 = &pid_max_min,
890 .extra2 = &pid_max_max,
891 },
892 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 .procname = "panic_on_oops",
894 .data = &panic_on_oops,
895 .maxlen = sizeof(int),
896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800899#if defined CONFIG_PRINTK
900 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800901 .procname = "printk",
902 .data = &console_loglevel,
903 .maxlen = 4*sizeof(int),
904 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800905 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800906 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700909 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 .maxlen = sizeof(int),
911 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800912 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 },
914 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700916 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 .maxlen = sizeof(int),
918 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800919 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 },
Dave Youngaf913222009-09-22 16:43:33 -0700921 {
Dave Youngaf913222009-09-22 16:43:33 -0700922 .procname = "printk_delay",
923 .data = &printk_delay_msec,
924 .maxlen = sizeof(int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700927 .extra1 = &zero,
928 .extra2 = &ten_thousand,
929 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700931 .procname = "printk_devkmsg",
932 .data = devkmsg_log_str,
933 .maxlen = DEVKMSG_STR_MAX_SIZE,
934 .mode = 0644,
935 .proc_handler = devkmsg_sysctl_set_loglvl,
936 },
937 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800938 .procname = "dmesg_restrict",
939 .data = &dmesg_restrict,
940 .maxlen = sizeof(int),
941 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700942 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800943 .extra1 = &zero,
944 .extra2 = &one,
945 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800946 {
947 .procname = "kptr_restrict",
948 .data = &kptr_restrict,
949 .maxlen = sizeof(int),
950 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700951 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800952 .extra1 = &zero,
953 .extra2 = &two,
954 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800955#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800956 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 .procname = "ngroups_max",
958 .data = &ngroups_max,
959 .maxlen = sizeof (int),
960 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 },
Dan Ballard73efc032011-10-31 17:11:20 -0700963 {
964 .procname = "cap_last_cap",
965 .data = (void *)&cap_last_cap,
966 .maxlen = sizeof(int),
967 .mode = 0444,
968 .proc_handler = proc_dointvec,
969 },
Don Zickus58687ac2010-05-07 17:11:44 -0400970#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500971 {
Don Zickus58687ac2010-05-07 17:11:44 -0400972 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200973 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500974 .maxlen = sizeof (int),
975 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700976 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700977 .extra1 = &zero,
978 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400979 },
980 {
981 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700982 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400983 .maxlen = sizeof(int),
984 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700985 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800986 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400987 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500988 },
Don Zickus2508ce12010-05-07 17:11:46 -0400989 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700990 .procname = "nmi_watchdog",
991 .data = &nmi_watchdog_enabled,
992 .maxlen = sizeof (int),
993 .mode = 0644,
994 .proc_handler = proc_nmi_watchdog,
995 .extra1 = &zero,
996#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
997 .extra2 = &one,
998#else
999 .extra2 = &zero,
1000#endif
1001 },
1002 {
1003 .procname = "soft_watchdog",
1004 .data = &soft_watchdog_enabled,
1005 .maxlen = sizeof (int),
1006 .mode = 0644,
1007 .proc_handler = proc_soft_watchdog,
1008 .extra1 = &zero,
1009 .extra2 = &one,
1010 },
1011 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001012 .procname = "watchdog_cpumask",
1013 .data = &watchdog_cpumask_bits,
1014 .maxlen = NR_CPUS,
1015 .mode = 0644,
1016 .proc_handler = proc_watchdog_cpumask,
1017 },
1018 {
Don Zickus2508ce12010-05-07 17:11:46 -04001019 .procname = "softlockup_panic",
1020 .data = &softlockup_panic,
1021 .maxlen = sizeof(int),
1022 .mode = 0644,
1023 .proc_handler = proc_dointvec_minmax,
1024 .extra1 = &zero,
1025 .extra2 = &one,
1026 },
Don Zickusac1f5912015-11-05 18:44:44 -08001027#ifdef CONFIG_HARDLOCKUP_DETECTOR
1028 {
1029 .procname = "hardlockup_panic",
1030 .data = &hardlockup_panic,
1031 .maxlen = sizeof(int),
1032 .mode = 0644,
1033 .proc_handler = proc_dointvec_minmax,
1034 .extra1 = &zero,
1035 .extra2 = &one,
1036 },
1037#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001038#ifdef CONFIG_SMP
1039 {
1040 .procname = "softlockup_all_cpu_backtrace",
1041 .data = &sysctl_softlockup_all_cpu_backtrace,
1042 .maxlen = sizeof(int),
1043 .mode = 0644,
1044 .proc_handler = proc_dointvec_minmax,
1045 .extra1 = &zero,
1046 .extra2 = &one,
1047 },
Jiri Kosina55537872015-11-05 18:44:41 -08001048 {
1049 .procname = "hardlockup_all_cpu_backtrace",
1050 .data = &sysctl_hardlockup_all_cpu_backtrace,
1051 .maxlen = sizeof(int),
1052 .mode = 0644,
1053 .proc_handler = proc_dointvec_minmax,
1054 .extra1 = &zero,
1055 .extra2 = &one,
1056 },
Aaron Tomlined235872014-06-23 13:22:05 -07001057#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001058#endif
1059#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1060 {
1061 .procname = "unknown_nmi_panic",
1062 .data = &unknown_nmi_panic,
1063 .maxlen = sizeof (int),
1064 .mode = 0644,
1065 .proc_handler = proc_dointvec,
1066 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001067#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068#if defined(CONFIG_X86)
1069 {
Don Zickus8da5add2006-09-26 10:52:27 +02001070 .procname = "panic_on_unrecovered_nmi",
1071 .data = &panic_on_unrecovered_nmi,
1072 .maxlen = sizeof(int),
1073 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001074 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001075 },
1076 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001077 .procname = "panic_on_io_nmi",
1078 .data = &panic_on_io_nmi,
1079 .maxlen = sizeof(int),
1080 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001081 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001082 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001083#ifdef CONFIG_DEBUG_STACKOVERFLOW
1084 {
1085 .procname = "panic_on_stackoverflow",
1086 .data = &sysctl_panic_on_stackoverflow,
1087 .maxlen = sizeof(int),
1088 .mode = 0644,
1089 .proc_handler = proc_dointvec,
1090 },
1091#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001092 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 .procname = "bootloader_type",
1094 .data = &bootloader_type,
1095 .maxlen = sizeof (int),
1096 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001097 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001099 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001100 .procname = "bootloader_version",
1101 .data = &bootloader_version,
1102 .maxlen = sizeof (int),
1103 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001104 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001105 },
1106 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001107 .procname = "kstack_depth_to_print",
1108 .data = &kstack_depth_to_print,
1109 .maxlen = sizeof(int),
1110 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001112 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001113 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001114 .procname = "io_delay_type",
1115 .data = &io_delay_type,
1116 .maxlen = sizeof(int),
1117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001119 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001121#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 .procname = "randomize_va_space",
1124 .data = &randomize_va_space,
1125 .maxlen = sizeof(int),
1126 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001127 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001129#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001130#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001131 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001132 .procname = "spin_retry",
1133 .data = &spin_retry,
1134 .maxlen = sizeof (int),
1135 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001136 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001137 },
1138#endif
Len Brown673d5b42007-07-28 03:33:16 -04001139#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001140 {
Pavel Machekc255d842006-02-20 18:27:58 -08001141 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001142 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001143 .maxlen = sizeof (unsigned long),
1144 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001145 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001146 },
1147#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301148#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001149 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001150 .procname = "ignore-unaligned-usertrap",
1151 .data = &no_unaligned_warning,
1152 .maxlen = sizeof (int),
1153 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001154 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001155 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301156#endif
1157#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001158 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001159 .procname = "unaligned-dump-stack",
1160 .data = &unaligned_dump_stack,
1161 .maxlen = sizeof (int),
1162 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001163 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001164 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001165#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001166#ifdef CONFIG_DETECT_HUNG_TASK
1167 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001168 .procname = "hung_task_panic",
1169 .data = &sysctl_hung_task_panic,
1170 .maxlen = sizeof(int),
1171 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001172 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001173 .extra1 = &zero,
1174 .extra2 = &one,
1175 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001176 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001177 .procname = "hung_task_check_count",
1178 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001179 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001180 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001181 .proc_handler = proc_dointvec_minmax,
1182 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001183 },
1184 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001185 .procname = "hung_task_timeout_secs",
1186 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001187 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001188 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001189 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001190 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001191 },
1192 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001193 .procname = "hung_task_warnings",
1194 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001195 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001196 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001197 .proc_handler = proc_dointvec_minmax,
1198 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001199 },
Imran Khana9788f42017-09-18 15:48:30 +05301200 {
1201 .procname = "hung_task_selective_monitoring",
1202 .data = &sysctl_hung_task_selective_monitoring,
1203 .maxlen = sizeof(int),
1204 .mode = 0644,
1205 .proc_handler = proc_dointvec_minmax,
1206 .extra1 = &zero,
1207 .extra2 = &one,
1208 },
1209
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001210#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001211#ifdef CONFIG_RT_MUTEXES
1212 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001213 .procname = "max_lock_depth",
1214 .data = &max_lock_depth,
1215 .maxlen = sizeof(int),
1216 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001217 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001218 },
1219#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001220 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001221 .procname = "poweroff_cmd",
1222 .data = &poweroff_cmd,
1223 .maxlen = POWEROFF_CMD_PATH_LEN,
1224 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001225 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001226 },
David Howells0b77f5b2008-04-29 01:01:32 -07001227#ifdef CONFIG_KEYS
1228 {
David Howells0b77f5b2008-04-29 01:01:32 -07001229 .procname = "keys",
1230 .mode = 0555,
1231 .child = key_sysctls,
1232 },
1233#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001234#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001235 /*
1236 * User-space scripts rely on the existence of this file
1237 * as a feature check for perf_events being enabled.
1238 *
1239 * So it's an ABI, do not remove!
1240 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001241 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001242 .procname = "perf_event_paranoid",
1243 .data = &sysctl_perf_event_paranoid,
1244 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001245 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001246 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001247 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001248 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001249 .procname = "perf_event_mlock_kb",
1250 .data = &sysctl_perf_event_mlock,
1251 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001252 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001253 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001254 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001255 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001256 .procname = "perf_event_max_sample_rate",
1257 .data = &sysctl_perf_event_sample_rate,
1258 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001259 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001260 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001261 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001262 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001263 {
1264 .procname = "perf_cpu_time_max_percent",
1265 .data = &sysctl_perf_cpu_time_max_percent,
1266 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1267 .mode = 0644,
1268 .proc_handler = perf_cpu_time_max_percent_handler,
1269 .extra1 = &zero,
1270 .extra2 = &one_hundred,
1271 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001272 {
1273 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001274 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001275 .maxlen = sizeof(sysctl_perf_event_max_stack),
1276 .mode = 0644,
1277 .proc_handler = perf_event_max_stack_handler,
1278 .extra1 = &zero,
1279 .extra2 = &six_hundred_forty_kb,
1280 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001281 {
1282 .procname = "perf_event_max_contexts_per_stack",
1283 .data = &sysctl_perf_event_max_contexts_per_stack,
1284 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1285 .mode = 0644,
1286 .proc_handler = perf_event_max_stack_handler,
1287 .extra1 = &zero,
1288 .extra2 = &one_thousand,
1289 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001290#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001291#ifdef CONFIG_KMEMCHECK
1292 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001293 .procname = "kmemcheck",
1294 .data = &kmemcheck_enabled,
1295 .maxlen = sizeof(int),
1296 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001297 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001298 },
1299#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001300 {
1301 .procname = "panic_on_warn",
1302 .data = &panic_on_warn,
1303 .maxlen = sizeof(int),
1304 .mode = 0644,
1305 .proc_handler = proc_dointvec_minmax,
1306 .extra1 = &zero,
1307 .extra2 = &one,
1308 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001309#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1310 {
1311 .procname = "timer_migration",
1312 .data = &sysctl_timer_migration,
1313 .maxlen = sizeof(unsigned int),
1314 .mode = 0644,
1315 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001316 .extra1 = &zero,
1317 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001318 },
1319#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001320#ifdef CONFIG_BPF_SYSCALL
1321 {
1322 .procname = "unprivileged_bpf_disabled",
1323 .data = &sysctl_unprivileged_bpf_disabled,
1324 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1325 .mode = 0644,
1326 /* only handle a transition from default "0" to "1" */
1327 .proc_handler = proc_dointvec_minmax,
1328 .extra1 = &one,
1329 .extra2 = &one,
1330 },
1331#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001332#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1333 {
1334 .procname = "panic_on_rcu_stall",
1335 .data = &sysctl_panic_on_rcu_stall,
1336 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1337 .mode = 0644,
1338 .proc_handler = proc_dointvec_minmax,
1339 .extra1 = &zero,
1340 .extra2 = &one,
1341 },
1342#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001343#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001344 {
1345 .procname = "boot_reason",
1346 .data = &boot_reason,
1347 .maxlen = sizeof(int),
1348 .mode = 0444,
1349 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001350 },
1351
1352 {
1353 .procname = "cold_boot",
1354 .data = &cold_boot,
1355 .maxlen = sizeof(int),
1356 .mode = 0444,
1357 .proc_handler = proc_dointvec,
1358 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001359#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001360 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361};
1362
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001363static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001364 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 .procname = "overcommit_memory",
1366 .data = &sysctl_overcommit_memory,
1367 .maxlen = sizeof(sysctl_overcommit_memory),
1368 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001369 .proc_handler = proc_dointvec_minmax,
1370 .extra1 = &zero,
1371 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 },
1373 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001374 .procname = "panic_on_oom",
1375 .data = &sysctl_panic_on_oom,
1376 .maxlen = sizeof(sysctl_panic_on_oom),
1377 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001378 .proc_handler = proc_dointvec_minmax,
1379 .extra1 = &zero,
1380 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001381 },
1382 {
David Rientjesfe071d72007-10-16 23:25:56 -07001383 .procname = "oom_kill_allocating_task",
1384 .data = &sysctl_oom_kill_allocating_task,
1385 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001387 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001388 },
1389 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001390 .procname = "oom_dump_tasks",
1391 .data = &sysctl_oom_dump_tasks,
1392 .maxlen = sizeof(sysctl_oom_dump_tasks),
1393 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001394 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001395 },
1396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397 .procname = "overcommit_ratio",
1398 .data = &sysctl_overcommit_ratio,
1399 .maxlen = sizeof(sysctl_overcommit_ratio),
1400 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001401 .proc_handler = overcommit_ratio_handler,
1402 },
1403 {
1404 .procname = "overcommit_kbytes",
1405 .data = &sysctl_overcommit_kbytes,
1406 .maxlen = sizeof(sysctl_overcommit_kbytes),
1407 .mode = 0644,
1408 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409 },
1410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .procname = "page-cluster",
1412 .data = &page_cluster,
1413 .maxlen = sizeof(int),
1414 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001415 .proc_handler = proc_dointvec_minmax,
1416 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001417 },
1418 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419 .procname = "dirty_background_ratio",
1420 .data = &dirty_background_ratio,
1421 .maxlen = sizeof(dirty_background_ratio),
1422 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001423 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 .extra1 = &zero,
1425 .extra2 = &one_hundred,
1426 },
1427 {
David Rientjes2da02992009-01-06 14:39:31 -08001428 .procname = "dirty_background_bytes",
1429 .data = &dirty_background_bytes,
1430 .maxlen = sizeof(dirty_background_bytes),
1431 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001432 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001433 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001434 },
1435 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 .procname = "dirty_ratio",
1437 .data = &vm_dirty_ratio,
1438 .maxlen = sizeof(vm_dirty_ratio),
1439 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001440 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 .extra1 = &zero,
1442 .extra2 = &one_hundred,
1443 },
1444 {
David Rientjes2da02992009-01-06 14:39:31 -08001445 .procname = "dirty_bytes",
1446 .data = &vm_dirty_bytes,
1447 .maxlen = sizeof(vm_dirty_bytes),
1448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001449 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001450 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001451 },
1452 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001454 .data = &dirty_writeback_interval,
1455 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001457 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458 },
1459 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001461 .data = &dirty_expire_interval,
1462 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001464 .proc_handler = proc_dointvec_minmax,
1465 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 },
1467 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001468 .procname = "dirtytime_expire_seconds",
1469 .data = &dirtytime_expire_interval,
1470 .maxlen = sizeof(dirty_expire_interval),
1471 .mode = 0644,
1472 .proc_handler = dirtytime_interval_handler,
1473 .extra1 = &zero,
1474 },
1475 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001476 .procname = "nr_pdflush_threads",
1477 .mode = 0444 /* read-only */,
1478 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 },
1480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .procname = "swappiness",
1482 .data = &vm_swappiness,
1483 .maxlen = sizeof(vm_swappiness),
1484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001485 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 .extra1 = &zero,
1487 .extra2 = &one_hundred,
1488 },
1489#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001490 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001492 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 .maxlen = sizeof(unsigned long),
1494 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001495 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001496 },
1497#ifdef CONFIG_NUMA
1498 {
1499 .procname = "nr_hugepages_mempolicy",
1500 .data = NULL,
1501 .maxlen = sizeof(unsigned long),
1502 .mode = 0644,
1503 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001504 },
1505#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 .procname = "hugetlb_shm_group",
1508 .data = &sysctl_hugetlb_shm_group,
1509 .maxlen = sizeof(gid_t),
1510 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001511 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 },
Mel Gorman396faf02007-07-17 04:03:13 -07001513 {
Mel Gorman396faf02007-07-17 04:03:13 -07001514 .procname = "hugepages_treat_as_movable",
1515 .data = &hugepages_treat_as_movable,
1516 .maxlen = sizeof(int),
1517 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001518 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001519 },
Adam Litke54f9f802007-10-16 01:26:20 -07001520 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001521 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001522 .data = NULL,
1523 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001525 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001526 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527#endif
1528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529 .procname = "lowmem_reserve_ratio",
1530 .data = &sysctl_lowmem_reserve_ratio,
1531 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001533 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534 },
1535 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001536 .procname = "drop_caches",
1537 .data = &sysctl_drop_caches,
1538 .maxlen = sizeof(int),
1539 .mode = 0644,
1540 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001541 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001542 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001543 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001544#ifdef CONFIG_COMPACTION
1545 {
1546 .procname = "compact_memory",
1547 .data = &sysctl_compact_memory,
1548 .maxlen = sizeof(int),
1549 .mode = 0200,
1550 .proc_handler = sysctl_compaction_handler,
1551 },
Mel Gorman5e771902010-05-24 14:32:31 -07001552 {
1553 .procname = "extfrag_threshold",
1554 .data = &sysctl_extfrag_threshold,
1555 .maxlen = sizeof(int),
1556 .mode = 0644,
1557 .proc_handler = sysctl_extfrag_handler,
1558 .extra1 = &min_extfrag_threshold,
1559 .extra2 = &max_extfrag_threshold,
1560 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001561 {
1562 .procname = "compact_unevictable_allowed",
1563 .data = &sysctl_compact_unevictable_allowed,
1564 .maxlen = sizeof(int),
1565 .mode = 0644,
1566 .proc_handler = proc_dointvec,
1567 .extra1 = &zero,
1568 .extra2 = &one,
1569 },
Mel Gorman5e771902010-05-24 14:32:31 -07001570
Mel Gorman76ab0f52010-05-24 14:32:28 -07001571#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001572 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 .procname = "min_free_kbytes",
1574 .data = &min_free_kbytes,
1575 .maxlen = sizeof(min_free_kbytes),
1576 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001577 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 .extra1 = &zero,
1579 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001580 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001581 .procname = "watermark_scale_factor",
1582 .data = &watermark_scale_factor,
1583 .maxlen = sizeof(watermark_scale_factor),
1584 .mode = 0644,
1585 .proc_handler = watermark_scale_factor_sysctl_handler,
Rik van Riel12462752011-09-01 15:26:50 -04001586 .extra1 = &zero,
1587 .extra2 = &zero,
1588 },
1589 {
1590 .procname = "extra_free_kbytes",
1591 .data = &extra_free_kbytes,
1592 .maxlen = sizeof(extra_free_kbytes),
1593 .mode = 0644,
1594 .proc_handler = min_free_kbytes_sysctl_handler,
1595 .extra1 = &zero,
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001596 },
1597 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001598 .procname = "percpu_pagelist_fraction",
1599 .data = &percpu_pagelist_fraction,
1600 .maxlen = sizeof(percpu_pagelist_fraction),
1601 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001602 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001603 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001604 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001605#ifdef CONFIG_MMU
1606 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607 .procname = "max_map_count",
1608 .data = &sysctl_max_map_count,
1609 .maxlen = sizeof(sysctl_max_map_count),
1610 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001611 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001612 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001613 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001614#else
1615 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001616 .procname = "nr_trim_pages",
1617 .data = &sysctl_nr_trim_pages,
1618 .maxlen = sizeof(sysctl_nr_trim_pages),
1619 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001620 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001621 .extra1 = &zero,
1622 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623#endif
1624 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625 .procname = "laptop_mode",
1626 .data = &laptop_mode,
1627 .maxlen = sizeof(laptop_mode),
1628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001629 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630 },
1631 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001632 .procname = "block_dump",
1633 .data = &block_dump,
1634 .maxlen = sizeof(block_dump),
1635 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001636 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637 .extra1 = &zero,
1638 },
1639 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640 .procname = "vfs_cache_pressure",
1641 .data = &sysctl_vfs_cache_pressure,
1642 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1643 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001644 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645 .extra1 = &zero,
1646 },
1647#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1648 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649 .procname = "legacy_va_layout",
1650 .data = &sysctl_legacy_va_layout,
1651 .maxlen = sizeof(sysctl_legacy_va_layout),
1652 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001653 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654 .extra1 = &zero,
1655 },
1656#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001657#ifdef CONFIG_NUMA
1658 {
Christoph Lameter17436602006-01-18 17:42:32 -08001659 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001660 .data = &node_reclaim_mode,
1661 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001662 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001663 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001664 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001665 },
Christoph Lameter96146342006-07-03 00:24:13 -07001666 {
Christoph Lameter96146342006-07-03 00:24:13 -07001667 .procname = "min_unmapped_ratio",
1668 .data = &sysctl_min_unmapped_ratio,
1669 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1670 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001671 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001672 .extra1 = &zero,
1673 .extra2 = &one_hundred,
1674 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001675 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001676 .procname = "min_slab_ratio",
1677 .data = &sysctl_min_slab_ratio,
1678 .maxlen = sizeof(sysctl_min_slab_ratio),
1679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001680 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001681 .extra1 = &zero,
1682 .extra2 = &one_hundred,
1683 },
Christoph Lameter17436602006-01-18 17:42:32 -08001684#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001685#ifdef CONFIG_SMP
1686 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001687 .procname = "stat_interval",
1688 .data = &sysctl_stat_interval,
1689 .maxlen = sizeof(sysctl_stat_interval),
1690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001691 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001692 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001693 {
1694 .procname = "stat_refresh",
1695 .data = NULL,
1696 .maxlen = 0,
1697 .mode = 0600,
1698 .proc_handler = vmstat_refresh,
1699 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001700#endif
David Howells6e141542009-12-15 19:27:45 +00001701#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001702 {
Eric Parised032182007-06-28 15:55:21 -04001703 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001704 .data = &dac_mmap_min_addr,
1705 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001707 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001708 },
David Howells6e141542009-12-15 19:27:45 +00001709#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001710#ifdef CONFIG_NUMA
1711 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001712 .procname = "numa_zonelist_order",
1713 .data = &numa_zonelist_order,
1714 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001716 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001717 },
1718#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001719#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001720 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001721 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001722 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001723#ifdef CONFIG_X86_32
1724 .data = &vdso32_enabled,
1725 .maxlen = sizeof(vdso32_enabled),
1726#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001727 .data = &vdso_enabled,
1728 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001729#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001730 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001731 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001732 .extra1 = &zero,
1733 },
1734#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001735#ifdef CONFIG_HIGHMEM
1736 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001737 .procname = "highmem_is_dirtyable",
1738 .data = &vm_highmem_is_dirtyable,
1739 .maxlen = sizeof(vm_highmem_is_dirtyable),
1740 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001741 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001742 .extra1 = &zero,
1743 .extra2 = &one,
1744 },
1745#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001746#ifdef CONFIG_MEMORY_FAILURE
1747 {
Andi Kleen6a460792009-09-16 11:50:15 +02001748 .procname = "memory_failure_early_kill",
1749 .data = &sysctl_memory_failure_early_kill,
1750 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1751 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001752 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001753 .extra1 = &zero,
1754 .extra2 = &one,
1755 },
1756 {
Andi Kleen6a460792009-09-16 11:50:15 +02001757 .procname = "memory_failure_recovery",
1758 .data = &sysctl_memory_failure_recovery,
1759 .maxlen = sizeof(sysctl_memory_failure_recovery),
1760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001761 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001762 .extra1 = &zero,
1763 .extra2 = &one,
1764 },
1765#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001766 {
1767 .procname = "user_reserve_kbytes",
1768 .data = &sysctl_user_reserve_kbytes,
1769 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1770 .mode = 0644,
1771 .proc_handler = proc_doulongvec_minmax,
1772 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001773 {
1774 .procname = "admin_reserve_kbytes",
1775 .data = &sysctl_admin_reserve_kbytes,
1776 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1777 .mode = 0644,
1778 .proc_handler = proc_doulongvec_minmax,
1779 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001780#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1781 {
1782 .procname = "mmap_rnd_bits",
1783 .data = &mmap_rnd_bits,
1784 .maxlen = sizeof(mmap_rnd_bits),
1785 .mode = 0600,
1786 .proc_handler = proc_dointvec_minmax,
1787 .extra1 = (void *)&mmap_rnd_bits_min,
1788 .extra2 = (void *)&mmap_rnd_bits_max,
1789 },
1790#endif
1791#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1792 {
1793 .procname = "mmap_rnd_compat_bits",
1794 .data = &mmap_rnd_compat_bits,
1795 .maxlen = sizeof(mmap_rnd_compat_bits),
1796 .mode = 0600,
1797 .proc_handler = proc_dointvec_minmax,
1798 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1799 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1800 },
1801#endif
Vinayak Menonc1c6a992015-12-21 13:00:58 +05301802#ifdef CONFIG_SWAP
1803 {
1804 .procname = "swap_ratio",
1805 .data = &sysctl_swap_ratio,
1806 .maxlen = sizeof(sysctl_swap_ratio),
1807 .mode = 0644,
1808 .proc_handler = proc_dointvec_minmax,
1809 },
1810 {
1811 .procname = "swap_ratio_enable",
1812 .data = &sysctl_swap_ratio_enable,
1813 .maxlen = sizeof(sysctl_swap_ratio_enable),
1814 .mode = 0644,
1815 .proc_handler = proc_dointvec_minmax,
1816 },
1817#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001818 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819};
1820
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001821static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001823 .procname = "inode-nr",
1824 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001825 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001826 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001827 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001828 },
1829 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830 .procname = "inode-state",
1831 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001832 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001833 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001834 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835 },
1836 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001837 .procname = "file-nr",
1838 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001839 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001840 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001841 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842 },
1843 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844 .procname = "file-max",
1845 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001846 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001848 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 },
1850 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001851 .procname = "nr_open",
1852 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001853 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001854 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001855 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001856 .extra1 = &sysctl_nr_open_min,
1857 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001858 },
1859 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 .procname = "dentry-state",
1861 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001862 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001864 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865 },
1866 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 .procname = "overflowuid",
1868 .data = &fs_overflowuid,
1869 .maxlen = sizeof(int),
1870 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001871 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872 .extra1 = &minolduid,
1873 .extra2 = &maxolduid,
1874 },
1875 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 .procname = "overflowgid",
1877 .data = &fs_overflowgid,
1878 .maxlen = sizeof(int),
1879 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001880 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 .extra1 = &minolduid,
1882 .extra2 = &maxolduid,
1883 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001884#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001885 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886 .procname = "leases-enable",
1887 .data = &leases_enable,
1888 .maxlen = sizeof(int),
1889 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001890 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001892#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893#ifdef CONFIG_DNOTIFY
1894 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 .procname = "dir-notify-enable",
1896 .data = &dir_notify_enable,
1897 .maxlen = sizeof(int),
1898 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001899 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001900 },
1901#endif
1902#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001903#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001905 .procname = "lease-break-time",
1906 .data = &lease_break_time,
1907 .maxlen = sizeof(int),
1908 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001909 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001910 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001911#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001912#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914 .procname = "aio-nr",
1915 .data = &aio_nr,
1916 .maxlen = sizeof(aio_nr),
1917 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001918 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 },
1920 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921 .procname = "aio-max-nr",
1922 .data = &aio_max_nr,
1923 .maxlen = sizeof(aio_max_nr),
1924 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001925 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001926 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001927#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001928#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001929 {
Robert Love0399cb02005-07-13 12:38:18 -04001930 .procname = "inotify",
1931 .mode = 0555,
1932 .child = inotify_table,
1933 },
1934#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001935#ifdef CONFIG_EPOLL
1936 {
1937 .procname = "epoll",
1938 .mode = 0555,
1939 .child = epoll_table,
1940 },
1941#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001943 {
Kees Cook800179c2012-07-25 17:29:07 -07001944 .procname = "protected_symlinks",
1945 .data = &sysctl_protected_symlinks,
1946 .maxlen = sizeof(int),
1947 .mode = 0600,
1948 .proc_handler = proc_dointvec_minmax,
1949 .extra1 = &zero,
1950 .extra2 = &one,
1951 },
1952 {
1953 .procname = "protected_hardlinks",
1954 .data = &sysctl_protected_hardlinks,
1955 .maxlen = sizeof(int),
1956 .mode = 0600,
1957 .proc_handler = proc_dointvec_minmax,
1958 .extra1 = &zero,
1959 .extra2 = &one,
1960 },
1961 {
Alan Coxd6e71142005-06-23 00:09:43 -07001962 .procname = "suid_dumpable",
1963 .data = &suid_dumpable,
1964 .maxlen = sizeof(int),
1965 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001966 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001967 .extra1 = &zero,
1968 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001969 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001970#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1971 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001972 .procname = "binfmt_misc",
1973 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001974 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001975 },
1976#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001977 {
Jens Axboeff9da692010-06-03 14:54:39 +02001978 .procname = "pipe-max-size",
1979 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001980 .maxlen = sizeof(int),
1981 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001982 .proc_handler = &pipe_proc_fn,
1983 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001984 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001985 {
1986 .procname = "pipe-user-pages-hard",
1987 .data = &pipe_user_pages_hard,
1988 .maxlen = sizeof(pipe_user_pages_hard),
1989 .mode = 0644,
1990 .proc_handler = proc_doulongvec_minmax,
1991 },
1992 {
1993 .procname = "pipe-user-pages-soft",
1994 .data = &pipe_user_pages_soft,
1995 .maxlen = sizeof(pipe_user_pages_soft),
1996 .mode = 0644,
1997 .proc_handler = proc_doulongvec_minmax,
1998 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001999 {
2000 .procname = "mount-max",
2001 .data = &sysctl_mount_max,
2002 .maxlen = sizeof(unsigned int),
2003 .mode = 0644,
2004 .proc_handler = proc_dointvec_minmax,
2005 .extra1 = &one,
2006 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002007 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002008};
2009
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002010static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07002011#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002012 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002013 .procname = "exception-trace",
2014 .data = &show_unhandled_signals,
2015 .maxlen = sizeof(int),
2016 .mode = 0644,
2017 .proc_handler = proc_dointvec
2018 },
2019#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002020#if defined(CONFIG_OPTPROBES)
2021 {
2022 .procname = "kprobes-optimization",
2023 .data = &sysctl_kprobes_optimization,
2024 .maxlen = sizeof(int),
2025 .mode = 0644,
2026 .proc_handler = proc_kprobes_optimization_handler,
2027 .extra1 = &zero,
2028 .extra2 = &one,
2029 },
2030#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002031 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002032};
2033
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002034static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002035 { }
Robert Love0eeca282005-07-12 17:06:03 -04002036};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002037
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002038int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002039{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002040 struct ctl_table_header *hdr;
2041
2042 hdr = register_sysctl_table(sysctl_base_table);
2043 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002044 return 0;
2045}
2046
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002047#endif /* CONFIG_SYSCTL */
2048
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049/*
2050 * /proc/sys support
2051 */
2052
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002053#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002054
Kees Cookf8808302014-06-06 14:37:17 -07002055static int _proc_do_string(char *data, int maxlen, int write,
2056 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002057 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002058{
2059 size_t len;
2060 char __user *p;
2061 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002062
2063 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002064 *lenp = 0;
2065 return 0;
2066 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002067
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002068 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002069 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2070 /* Only continue writes not past the end of buffer. */
2071 len = strlen(data);
2072 if (len > maxlen - 1)
2073 len = maxlen - 1;
2074
2075 if (*ppos > len)
2076 return 0;
2077 len = *ppos;
2078 } else {
2079 /* Start writing from beginning of buffer. */
2080 len = 0;
2081 }
2082
Kees Cook2ca9bb42014-06-06 14:37:18 -07002083 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002084 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002085 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002086 if (get_user(c, p++))
2087 return -EFAULT;
2088 if (c == 0 || c == '\n')
2089 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002090 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002091 }
Kees Cookf8808302014-06-06 14:37:17 -07002092 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002093 } else {
2094 len = strlen(data);
2095 if (len > maxlen)
2096 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002097
2098 if (*ppos > len) {
2099 *lenp = 0;
2100 return 0;
2101 }
2102
2103 data += *ppos;
2104 len -= *ppos;
2105
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002106 if (len > *lenp)
2107 len = *lenp;
2108 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002109 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002110 return -EFAULT;
2111 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002112 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002113 return -EFAULT;
2114 len++;
2115 }
2116 *lenp = len;
2117 *ppos += len;
2118 }
2119 return 0;
2120}
2121
Kees Cookf4aacea2014-06-06 14:37:19 -07002122static void warn_sysctl_write(struct ctl_table *table)
2123{
2124 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2125 "This will not be supported in the future. To silence this\n"
2126 "warning, set kernel.sysctl_writes_strict = -1\n",
2127 current->comm, table->procname);
2128}
2129
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130/**
2131 * proc_dostring - read a string sysctl
2132 * @table: the sysctl table
2133 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 * @buffer: the user buffer
2135 * @lenp: the size of the user buffer
2136 * @ppos: file position
2137 *
2138 * Reads/writes a string from/to the user buffer. If the kernel
2139 * buffer provided is not large enough to hold the string, the
2140 * string is truncated. The copied string is %NULL-terminated.
2141 * If the string is being read by the user process, it is copied
2142 * and a newline '\n' is added. It is truncated if the buffer is
2143 * not large enough.
2144 *
2145 * Returns 0 on success.
2146 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002147int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148 void __user *buffer, size_t *lenp, loff_t *ppos)
2149{
Kees Cookf4aacea2014-06-06 14:37:19 -07002150 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2151 warn_sysctl_write(table);
2152
Kees Cookf8808302014-06-06 14:37:17 -07002153 return _proc_do_string((char *)(table->data), table->maxlen, write,
2154 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155}
2156
Amerigo Wang00b7c332010-05-05 00:26:45 +00002157static size_t proc_skip_spaces(char **buf)
2158{
2159 size_t ret;
2160 char *tmp = skip_spaces(*buf);
2161 ret = tmp - *buf;
2162 *buf = tmp;
2163 return ret;
2164}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002166static void proc_skip_char(char **buf, size_t *size, const char v)
2167{
2168 while (*size) {
2169 if (**buf != v)
2170 break;
2171 (*size)--;
2172 (*buf)++;
2173 }
2174}
2175
Amerigo Wang00b7c332010-05-05 00:26:45 +00002176#define TMPBUFLEN 22
2177/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002178 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002179 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002180 * @buf: a kernel buffer
2181 * @size: size of the kernel buffer
2182 * @val: this is where the number will be stored
2183 * @neg: set to %TRUE if number is negative
2184 * @perm_tr: a vector which contains the allowed trailers
2185 * @perm_tr_len: size of the perm_tr vector
2186 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002187 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002188 * In case of success %0 is returned and @buf and @size are updated with
2189 * the amount of bytes read. If @tr is non-NULL and a trailing
2190 * character exists (size is non-zero after returning from this
2191 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002192 */
2193static int proc_get_long(char **buf, size_t *size,
2194 unsigned long *val, bool *neg,
2195 const char *perm_tr, unsigned perm_tr_len, char *tr)
2196{
2197 int len;
2198 char *p, tmp[TMPBUFLEN];
2199
2200 if (!*size)
2201 return -EINVAL;
2202
2203 len = *size;
2204 if (len > TMPBUFLEN - 1)
2205 len = TMPBUFLEN - 1;
2206
2207 memcpy(tmp, *buf, len);
2208
2209 tmp[len] = 0;
2210 p = tmp;
2211 if (*p == '-' && *size > 1) {
2212 *neg = true;
2213 p++;
2214 } else
2215 *neg = false;
2216 if (!isdigit(*p))
2217 return -EINVAL;
2218
2219 *val = simple_strtoul(p, &p, 0);
2220
2221 len = p - tmp;
2222
2223 /* We don't know if the next char is whitespace thus we may accept
2224 * invalid integers (e.g. 1234...a) or two integers instead of one
2225 * (e.g. 123...1). So lets not allow such large numbers. */
2226 if (len == TMPBUFLEN - 1)
2227 return -EINVAL;
2228
2229 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2230 return -EINVAL;
2231
2232 if (tr && (len < *size))
2233 *tr = *p;
2234
2235 *buf += len;
2236 *size -= len;
2237
2238 return 0;
2239}
2240
2241/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002242 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002243 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002244 * @buf: the user buffer
2245 * @size: the size of the user buffer
2246 * @val: the integer to be converted
2247 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002248 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002249 * In case of success %0 is returned and @buf and @size are updated with
2250 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002251 */
2252static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2253 bool neg)
2254{
2255 int len;
2256 char tmp[TMPBUFLEN], *p = tmp;
2257
2258 sprintf(p, "%s%lu", neg ? "-" : "", val);
2259 len = strlen(tmp);
2260 if (len > *size)
2261 len = *size;
2262 if (copy_to_user(*buf, tmp, len))
2263 return -EFAULT;
2264 *size -= len;
2265 *buf += len;
2266 return 0;
2267}
2268#undef TMPBUFLEN
2269
2270static int proc_put_char(void __user **buf, size_t *size, char c)
2271{
2272 if (*size) {
2273 char __user **buffer = (char __user **)buf;
2274 if (put_user(c, *buffer))
2275 return -EFAULT;
2276 (*size)--, (*buffer)++;
2277 *buf = *buffer;
2278 }
2279 return 0;
2280}
2281
2282static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 int *valp,
2284 int write, void *data)
2285{
2286 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002287 if (*negp) {
2288 if (*lvalp > (unsigned long) INT_MAX + 1)
2289 return -EINVAL;
2290 *valp = -*lvalp;
2291 } else {
2292 if (*lvalp > (unsigned long) INT_MAX)
2293 return -EINVAL;
2294 *valp = *lvalp;
2295 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 } else {
2297 int val = *valp;
2298 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002299 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002300 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002302 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303 *lvalp = (unsigned long)val;
2304 }
2305 }
2306 return 0;
2307}
2308
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002309static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2310 int *valp,
2311 int write, void *data)
2312{
2313 if (write) {
2314 if (*negp)
2315 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002316 if (*lvalp > UINT_MAX)
2317 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002318 *valp = *lvalp;
2319 } else {
2320 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002321 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002322 *lvalp = (unsigned long)val;
2323 }
2324 return 0;
2325}
2326
Amerigo Wang00b7c332010-05-05 00:26:45 +00002327static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2328
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002329static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002330 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002331 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002332 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 int write, void *data),
2334 void *data)
2335{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002336 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002337 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002338 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339
Amerigo Wang00b7c332010-05-05 00:26:45 +00002340 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 *lenp = 0;
2342 return 0;
2343 }
2344
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002345 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346 vleft = table->maxlen / sizeof(*i);
2347 left = *lenp;
2348
2349 if (!conv)
2350 conv = do_proc_dointvec_conv;
2351
Linus Torvalds1da177e2005-04-16 15:20:36 -07002352 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002353 if (*ppos) {
2354 switch (sysctl_writes_strict) {
2355 case SYSCTL_WRITES_STRICT:
2356 goto out;
2357 case SYSCTL_WRITES_WARN:
2358 warn_sysctl_write(table);
2359 break;
2360 default:
2361 break;
2362 }
2363 }
2364
Amerigo Wang00b7c332010-05-05 00:26:45 +00002365 if (left > PAGE_SIZE - 1)
2366 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002367 p = kbuf = memdup_user_nul(buffer, left);
2368 if (IS_ERR(kbuf))
2369 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002370 }
2371
2372 for (; left && vleft--; i++, first=0) {
2373 unsigned long lval;
2374 bool neg;
2375
2376 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002377 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002378
J. R. Okajima563b0462010-05-25 16:10:14 -07002379 if (!left)
2380 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002381 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002382 proc_wspace_sep,
2383 sizeof(proc_wspace_sep), NULL);
2384 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002386 if (conv(&neg, &lval, i, 1, data)) {
2387 err = -EINVAL;
2388 break;
2389 }
2390 } else {
2391 if (conv(&neg, &lval, i, 0, data)) {
2392 err = -EINVAL;
2393 break;
2394 }
2395 if (!first)
2396 err = proc_put_char(&buffer, &left, '\t');
2397 if (err)
2398 break;
2399 err = proc_put_long(&buffer, &left, lval, neg);
2400 if (err)
2401 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 }
2403 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002404
2405 if (!write && !first && left && !err)
2406 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002407 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002408 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002409 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002410 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002411 if (first)
2412 return err ? : -EINVAL;
2413 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002415out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002417 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418}
2419
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002420static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002421 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002422 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002423 int write, void *data),
2424 void *data)
2425{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002426 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002427 buffer, lenp, ppos, conv, data);
2428}
2429
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430/**
2431 * proc_dointvec - read a vector of integers
2432 * @table: the sysctl table
2433 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 * @buffer: the user buffer
2435 * @lenp: the size of the user buffer
2436 * @ppos: file position
2437 *
2438 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2439 * values from/to the user buffer, treated as an ASCII string.
2440 *
2441 * Returns 0 on success.
2442 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002443int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 void __user *buffer, size_t *lenp, loff_t *ppos)
2445{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002446 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2447}
2448
2449/**
2450 * proc_douintvec - read a vector of unsigned integers
2451 * @table: the sysctl table
2452 * @write: %TRUE if this is a write to the sysctl file
2453 * @buffer: the user buffer
2454 * @lenp: the size of the user buffer
2455 * @ppos: file position
2456 *
2457 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2458 * values from/to the user buffer, treated as an ASCII string.
2459 *
2460 * Returns 0 on success.
2461 */
2462int proc_douintvec(struct ctl_table *table, int write,
2463 void __user *buffer, size_t *lenp, loff_t *ppos)
2464{
2465 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2466 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467}
2468
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002469/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002470 * Taint values can only be increased
2471 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002472 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002473static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002474 void __user *buffer, size_t *lenp, loff_t *ppos)
2475{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002476 struct ctl_table t;
2477 unsigned long tmptaint = get_taint();
2478 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002479
Bastian Blank91fcd412007-04-23 14:41:14 -07002480 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002481 return -EPERM;
2482
Andi Kleen25ddbb12008-10-15 22:01:41 -07002483 t = *table;
2484 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002485 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002486 if (err < 0)
2487 return err;
2488
2489 if (write) {
2490 /*
2491 * Poor man's atomic or. Not worth adding a primitive
2492 * to everyone's atomic.h for this
2493 */
2494 int i;
2495 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2496 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302497 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002498 }
2499 }
2500
2501 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002502}
2503
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002504#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002505static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002506 void __user *buffer, size_t *lenp, loff_t *ppos)
2507{
2508 if (write && !capable(CAP_SYS_ADMIN))
2509 return -EPERM;
2510
2511 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2512}
2513#endif
2514
Linus Torvalds1da177e2005-04-16 15:20:36 -07002515struct do_proc_dointvec_minmax_conv_param {
2516 int *min;
2517 int *max;
2518};
2519
Amerigo Wang00b7c332010-05-05 00:26:45 +00002520static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2521 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522 int write, void *data)
2523{
2524 struct do_proc_dointvec_minmax_conv_param *param = data;
2525 if (write) {
2526 int val = *negp ? -*lvalp : *lvalp;
2527 if ((param->min && *param->min > val) ||
2528 (param->max && *param->max < val))
2529 return -EINVAL;
2530 *valp = val;
2531 } else {
2532 int val = *valp;
2533 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002534 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002535 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002536 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002537 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538 *lvalp = (unsigned long)val;
2539 }
2540 }
2541 return 0;
2542}
2543
2544/**
2545 * proc_dointvec_minmax - read a vector of integers with min/max values
2546 * @table: the sysctl table
2547 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 * @buffer: the user buffer
2549 * @lenp: the size of the user buffer
2550 * @ppos: file position
2551 *
2552 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2553 * values from/to the user buffer, treated as an ASCII string.
2554 *
2555 * This routine will ensure the values are within the range specified by
2556 * table->extra1 (min) and table->extra2 (max).
2557 *
2558 * Returns 0 on success.
2559 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002560int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 void __user *buffer, size_t *lenp, loff_t *ppos)
2562{
2563 struct do_proc_dointvec_minmax_conv_param param = {
2564 .min = (int *) table->extra1,
2565 .max = (int *) table->extra2,
2566 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002567 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568 do_proc_dointvec_minmax_conv, &param);
2569}
2570
Kees Cook54b50192012-07-30 14:39:18 -07002571static void validate_coredump_safety(void)
2572{
Alex Kelly046d6622012-10-04 17:15:23 -07002573#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002574 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002575 core_pattern[0] != '/' && core_pattern[0] != '|') {
2576 printk(KERN_WARNING "Unsafe core_pattern used with "\
2577 "suid_dumpable=2. Pipe handler or fully qualified "\
2578 "core dump path required.\n");
2579 }
Alex Kelly046d6622012-10-04 17:15:23 -07002580#endif
Kees Cook54b50192012-07-30 14:39:18 -07002581}
2582
2583static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2584 void __user *buffer, size_t *lenp, loff_t *ppos)
2585{
2586 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2587 if (!error)
2588 validate_coredump_safety();
2589 return error;
2590}
2591
Alex Kelly046d6622012-10-04 17:15:23 -07002592#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002593static int proc_dostring_coredump(struct ctl_table *table, int write,
2594 void __user *buffer, size_t *lenp, loff_t *ppos)
2595{
2596 int error = proc_dostring(table, write, buffer, lenp, ppos);
2597 if (!error)
2598 validate_coredump_safety();
2599 return error;
2600}
Alex Kelly046d6622012-10-04 17:15:23 -07002601#endif
Kees Cook54b50192012-07-30 14:39:18 -07002602
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002603static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002604 void __user *buffer,
2605 size_t *lenp, loff_t *ppos,
2606 unsigned long convmul,
2607 unsigned long convdiv)
2608{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002609 unsigned long *i, *min, *max;
2610 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002611 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002612 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002613
2614 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615 *lenp = 0;
2616 return 0;
2617 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002618
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002619 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 min = (unsigned long *) table->extra1;
2621 max = (unsigned long *) table->extra2;
2622 vleft = table->maxlen / sizeof(unsigned long);
2623 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002624
2625 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002626 if (*ppos) {
2627 switch (sysctl_writes_strict) {
2628 case SYSCTL_WRITES_STRICT:
2629 goto out;
2630 case SYSCTL_WRITES_WARN:
2631 warn_sysctl_write(table);
2632 break;
2633 default:
2634 break;
2635 }
2636 }
2637
Amerigo Wang00b7c332010-05-05 00:26:45 +00002638 if (left > PAGE_SIZE - 1)
2639 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002640 p = kbuf = memdup_user_nul(buffer, left);
2641 if (IS_ERR(kbuf))
2642 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002643 }
2644
Eric Dumazet27b3d802010-10-07 12:59:29 -07002645 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002646 unsigned long val;
2647
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002649 bool neg;
2650
Al Viro70f6cbb2015-12-24 00:13:10 -05002651 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002652
Al Viro70f6cbb2015-12-24 00:13:10 -05002653 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002654 proc_wspace_sep,
2655 sizeof(proc_wspace_sep), NULL);
2656 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 break;
2658 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002660 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 if ((min && val < *min) || (max && val > *max))
2662 continue;
2663 *i = val;
2664 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002665 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002666 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002667 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002668 if (err)
2669 break;
2670 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002671 err = proc_put_long(&buffer, &left, val, false);
2672 if (err)
2673 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 }
2675 }
2676
Amerigo Wang00b7c332010-05-05 00:26:45 +00002677 if (!write && !first && left && !err)
2678 err = proc_put_char(&buffer, &left, '\n');
2679 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002680 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002682 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002683 if (first)
2684 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002687out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002688 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002689 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690}
2691
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002692static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002693 void __user *buffer,
2694 size_t *lenp, loff_t *ppos,
2695 unsigned long convmul,
2696 unsigned long convdiv)
2697{
2698 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002699 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002700}
2701
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702/**
2703 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2704 * @table: the sysctl table
2705 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706 * @buffer: the user buffer
2707 * @lenp: the size of the user buffer
2708 * @ppos: file position
2709 *
2710 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2711 * values from/to the user buffer, treated as an ASCII string.
2712 *
2713 * This routine will ensure the values are within the range specified by
2714 * table->extra1 (min) and table->extra2 (max).
2715 *
2716 * Returns 0 on success.
2717 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002718int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719 void __user *buffer, size_t *lenp, loff_t *ppos)
2720{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002721 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002722}
2723
2724/**
2725 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2726 * @table: the sysctl table
2727 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 * @buffer: the user buffer
2729 * @lenp: the size of the user buffer
2730 * @ppos: file position
2731 *
2732 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2733 * values from/to the user buffer, treated as an ASCII string. The values
2734 * are treated as milliseconds, and converted to jiffies when they are stored.
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 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002741int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742 void __user *buffer,
2743 size_t *lenp, loff_t *ppos)
2744{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002745 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002746 lenp, ppos, HZ, 1000l);
2747}
2748
2749
Amerigo Wang00b7c332010-05-05 00:26:45 +00002750static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751 int *valp,
2752 int write, void *data)
2753{
2754 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002755 if (*lvalp > LONG_MAX / HZ)
2756 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002757 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2758 } else {
2759 int val = *valp;
2760 unsigned long lval;
2761 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002762 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002763 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002764 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002765 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002766 lval = (unsigned long)val;
2767 }
2768 *lvalp = lval / HZ;
2769 }
2770 return 0;
2771}
2772
Amerigo Wang00b7c332010-05-05 00:26:45 +00002773static int do_proc_dointvec_userhz_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 (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2779 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002780 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
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 = jiffies_to_clock_t(lval);
2792 }
2793 return 0;
2794}
2795
Amerigo Wang00b7c332010-05-05 00:26:45 +00002796static int do_proc_dointvec_ms_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) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002801 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2802
2803 if (jif > INT_MAX)
2804 return 1;
2805 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002806 } else {
2807 int val = *valp;
2808 unsigned long lval;
2809 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002810 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002811 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002812 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002813 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002814 lval = (unsigned long)val;
2815 }
2816 *lvalp = jiffies_to_msecs(lval);
2817 }
2818 return 0;
2819}
2820
2821/**
2822 * proc_dointvec_jiffies - read a vector of integers as seconds
2823 * @table: the sysctl table
2824 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002825 * @buffer: the user buffer
2826 * @lenp: the size of the user buffer
2827 * @ppos: file position
2828 *
2829 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2830 * values from/to the user buffer, treated as an ASCII string.
2831 * The values read are assumed to be in seconds, and are converted into
2832 * jiffies.
2833 *
2834 * Returns 0 on success.
2835 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002836int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002837 void __user *buffer, size_t *lenp, loff_t *ppos)
2838{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002839 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 do_proc_dointvec_jiffies_conv,NULL);
2841}
2842
2843/**
2844 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2845 * @table: the sysctl table
2846 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002847 * @buffer: the user buffer
2848 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002849 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002850 *
2851 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2852 * values from/to the user buffer, treated as an ASCII string.
2853 * The values read are assumed to be in 1/USER_HZ seconds, and
2854 * are converted into jiffies.
2855 *
2856 * Returns 0 on success.
2857 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002858int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002859 void __user *buffer, size_t *lenp, loff_t *ppos)
2860{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002861 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862 do_proc_dointvec_userhz_jiffies_conv,NULL);
2863}
2864
2865/**
2866 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2867 * @table: the sysctl table
2868 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002869 * @buffer: the user buffer
2870 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002871 * @ppos: file position
2872 * @ppos: the current position in the file
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/1000 seconds, and
2877 * are converted into jiffies.
2878 *
2879 * Returns 0 on success.
2880 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002881int proc_dointvec_ms_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_ms_jiffies_conv, NULL);
2886}
2887
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002888static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002889 void __user *buffer, size_t *lenp, loff_t *ppos)
2890{
2891 struct pid *new_pid;
2892 pid_t tmp;
2893 int r;
2894
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002895 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002896
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002897 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002898 lenp, ppos, NULL, NULL);
2899 if (r || !write)
2900 return r;
2901
2902 new_pid = find_get_pid(tmp);
2903 if (!new_pid)
2904 return -ESRCH;
2905
2906 put_pid(xchg(&cad_pid, new_pid));
2907 return 0;
2908}
2909
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002910/**
2911 * proc_do_large_bitmap - read/write from/to a large bitmap
2912 * @table: the sysctl table
2913 * @write: %TRUE if this is a write to the sysctl file
2914 * @buffer: the user buffer
2915 * @lenp: the size of the user buffer
2916 * @ppos: file position
2917 *
2918 * The bitmap is stored at table->data and the bitmap length (in bits)
2919 * in table->maxlen.
2920 *
2921 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2922 * large bitmaps may be represented in a compact manner. Writing into
2923 * the file will clear the bitmap then update it with the given input.
2924 *
2925 * Returns 0 on success.
2926 */
2927int proc_do_large_bitmap(struct ctl_table *table, int write,
2928 void __user *buffer, size_t *lenp, loff_t *ppos)
2929{
2930 int err = 0;
2931 bool first = 1;
2932 size_t left = *lenp;
2933 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002934 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002935 unsigned long *tmp_bitmap = NULL;
2936 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2937
WANG Cong122ff242014-05-12 16:04:53 -07002938 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002939 *lenp = 0;
2940 return 0;
2941 }
2942
2943 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002944 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002945
2946 if (left > PAGE_SIZE - 1)
2947 left = PAGE_SIZE - 1;
2948
Al Viro70f6cbb2015-12-24 00:13:10 -05002949 p = kbuf = memdup_user_nul(buffer, left);
2950 if (IS_ERR(kbuf))
2951 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002952
2953 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2954 GFP_KERNEL);
2955 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002956 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002957 return -ENOMEM;
2958 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002959 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002960 while (!err && left) {
2961 unsigned long val_a, val_b;
2962 bool neg;
2963
Al Viro70f6cbb2015-12-24 00:13:10 -05002964 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002965 sizeof(tr_a), &c);
2966 if (err)
2967 break;
2968 if (val_a >= bitmap_len || neg) {
2969 err = -EINVAL;
2970 break;
2971 }
2972
2973 val_b = val_a;
2974 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002975 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002976 left--;
2977 }
2978
2979 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002980 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002981 &neg, tr_b, sizeof(tr_b),
2982 &c);
2983 if (err)
2984 break;
2985 if (val_b >= bitmap_len || neg ||
2986 val_a > val_b) {
2987 err = -EINVAL;
2988 break;
2989 }
2990 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002991 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002992 left--;
2993 }
2994 }
2995
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002996 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002997 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002998 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002999 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003000 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003001 } else {
3002 unsigned long bit_a, bit_b = 0;
3003
3004 while (left) {
3005 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3006 if (bit_a >= bitmap_len)
3007 break;
3008 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3009 bit_a + 1) - 1;
3010
3011 if (!first) {
3012 err = proc_put_char(&buffer, &left, ',');
3013 if (err)
3014 break;
3015 }
3016 err = proc_put_long(&buffer, &left, bit_a, false);
3017 if (err)
3018 break;
3019 if (bit_a != bit_b) {
3020 err = proc_put_char(&buffer, &left, '-');
3021 if (err)
3022 break;
3023 err = proc_put_long(&buffer, &left, bit_b, false);
3024 if (err)
3025 break;
3026 }
3027
3028 first = 0; bit_b++;
3029 }
3030 if (!err)
3031 err = proc_put_char(&buffer, &left, '\n');
3032 }
3033
3034 if (!err) {
3035 if (write) {
3036 if (*ppos)
3037 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3038 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003039 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003040 }
3041 kfree(tmp_bitmap);
3042 *lenp -= left;
3043 *ppos += *lenp;
3044 return 0;
3045 } else {
3046 kfree(tmp_bitmap);
3047 return err;
3048 }
3049}
3050
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003051static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp,
3052 int *valp, int write, void *data)
3053{
3054 if (write) {
3055 if (*negp)
3056 return -EINVAL;
3057 *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp;
3058 } else {
3059 *negp = false;
3060 *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp;
3061 }
3062
3063 return 0;
3064}
3065
3066/**
3067 * proc_douintvec_capacity - read a vector of integers in percentage and convert
3068 * into sched capacity
3069 * @table: the sysctl table
3070 * @write: %TRUE if this is a write to the sysctl file
3071 * @buffer: the user buffer
3072 * @lenp: the size of the user buffer
3073 * @ppos: file position
3074 *
3075 * Returns 0 on success.
3076 */
3077int proc_douintvec_capacity(struct ctl_table *table, int write,
3078 void __user *buffer, size_t *lenp, loff_t *ppos)
3079{
3080 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3081 do_proc_douintvec_capacity_conv, NULL);
3082}
3083
Jovi Zhang55610502011-01-12 17:00:45 -08003084#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003085
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003086int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003087 void __user *buffer, size_t *lenp, loff_t *ppos)
3088{
3089 return -ENOSYS;
3090}
3091
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003092int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093 void __user *buffer, size_t *lenp, loff_t *ppos)
3094{
3095 return -ENOSYS;
3096}
3097
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003098int proc_douintvec(struct ctl_table *table, int write,
3099 void __user *buffer, size_t *lenp, loff_t *ppos)
3100{
3101 return -ENOSYS;
3102}
3103
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003104int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003105 void __user *buffer, size_t *lenp, loff_t *ppos)
3106{
3107 return -ENOSYS;
3108}
3109
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003110int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003111 void __user *buffer, size_t *lenp, loff_t *ppos)
3112{
3113 return -ENOSYS;
3114}
3115
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003116int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003117 void __user *buffer, size_t *lenp, loff_t *ppos)
3118{
3119 return -ENOSYS;
3120}
3121
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003122int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123 void __user *buffer, size_t *lenp, loff_t *ppos)
3124{
3125 return -ENOSYS;
3126}
3127
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003128int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003129 void __user *buffer, size_t *lenp, loff_t *ppos)
3130{
3131 return -ENOSYS;
3132}
3133
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003134int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003135 void __user *buffer,
3136 size_t *lenp, loff_t *ppos)
3137{
3138 return -ENOSYS;
3139}
3140
Joonwoo Parkb02fc002017-06-16 11:58:58 -07003141int proc_douintvec_capacity(struct ctl_table *table, int write,
3142 void __user *buffer, size_t *lenp, loff_t *ppos)
3143{
3144 return -ENOSYS;
3145}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003146
Jovi Zhang55610502011-01-12 17:00:45 -08003147#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003148
Linus Torvalds1da177e2005-04-16 15:20:36 -07003149/*
3150 * No sense putting this after each symbol definition, twice,
3151 * exception granted :-)
3152 */
3153EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003154EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003155EXPORT_SYMBOL(proc_dointvec_jiffies);
3156EXPORT_SYMBOL(proc_dointvec_minmax);
3157EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3158EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3159EXPORT_SYMBOL(proc_dostring);
3160EXPORT_SYMBOL(proc_doulongvec_minmax);
3161EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);