blob: 337cb1e4eacc3a0668792138765f7a746a1ab672 [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;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700126static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700129static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700130#ifdef CONFIG_PRINTK
131static int ten_thousand = 10000;
132#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300133#ifdef CONFIG_PERF_EVENTS
134static int six_hundred_forty_kb = 640 * 1024;
135#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
143
144static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700145static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Liu Hua80df2842014-04-07 15:38:57 -0700147/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
148#ifdef CONFIG_DETECT_HUNG_TASK
149static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
150#endif
151
Dave Youngd14f1722010-02-25 20:28:57 -0500152#ifdef CONFIG_INOTIFY_USER
153#include <linux/inotify.h>
154#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700155#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#endif
157
158#ifdef __hppa__
159extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530160#endif
161
162#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163extern int unaligned_enabled;
164#endif
165
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800167extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800168#endif
169
Vineet Guptab6fca722013-01-09 20:06:28 +0530170#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
171extern int no_unaligned_warning;
172#endif
173
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700174#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700175
176#define SYSCTL_WRITES_LEGACY -1
177#define SYSCTL_WRITES_WARN 0
178#define SYSCTL_WRITES_STRICT 1
179
Kees Cook41662f52016-01-20 15:00:45 -0800180static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700181
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700182static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700183 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700184static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800185 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700186#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700187
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700188#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700189static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700190 void __user *buffer, size_t *lenp, loff_t *ppos);
191#endif
192
Kees Cook54b50192012-07-30 14:39:18 -0700193static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
194 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700195#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700196static int proc_dostring_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#endif
Kees Cook54b50192012-07-30 14:39:18 -0700199
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700200#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800201/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100202static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700203
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700204static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700205 void __user *buffer, size_t *lenp,
206 loff_t *ppos)
207{
208 int error;
209
210 error = proc_dointvec(table, write, buffer, lenp, ppos);
211 if (error)
212 return error;
213
214 if (write)
215 sysrq_toggle_support(__sysrq_enabled);
216
217 return 0;
218}
219
220#endif
221
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700222static struct ctl_table kern_table[];
223static struct ctl_table vm_table[];
224static struct ctl_table fs_table[];
225static struct ctl_table debug_table[];
226static struct ctl_table dev_table[];
227extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800228#ifdef CONFIG_EPOLL
229extern struct ctl_table epoll_table[];
230#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
233int sysctl_legacy_va_layout;
234#endif
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236/* The default sysctl tables: */
237
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800238static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .procname = "kernel",
241 .mode = 0555,
242 .child = kern_table,
243 },
244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .procname = "vm",
246 .mode = 0555,
247 .child = vm_table,
248 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 .procname = "fs",
251 .mode = 0555,
252 .child = fs_table,
253 },
254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 .procname = "debug",
256 .mode = 0555,
257 .child = debug_table,
258 },
259 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 .procname = "dev",
261 .mode = 0555,
262 .child = dev_table,
263 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700264 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265};
266
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100268static int min_sched_granularity_ns = 100000; /* 100 usecs */
269static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
270static int min_wakeup_granularity_ns; /* 0 usecs */
271static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200272#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100273static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
274static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200275#endif /* CONFIG_SMP */
276#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200277
Mel Gorman5e771902010-05-24 14:32:31 -0700278#ifdef CONFIG_COMPACTION
279static int min_extfrag_threshold;
280static int max_extfrag_threshold = 1000;
281#endif
282
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700283static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200284 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200285 .procname = "sched_child_runs_first",
286 .data = &sysctl_sched_child_runs_first,
287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800289 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200290 },
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700291 {
292 .procname = "sched_wake_to_idle",
293 .data = &sysctl_sched_wake_to_idle,
294 .maxlen = sizeof(unsigned int),
295 .mode = 0644,
296 .proc_handler = proc_dointvec,
297 },
298#ifdef CONFIG_SCHED_HMP
299 {
300 .procname = "sched_freq_inc_notify",
301 .data = &sysctl_sched_freq_inc_notify,
302 .maxlen = sizeof(unsigned int),
303 .mode = 0644,
304 .proc_handler = proc_dointvec_minmax,
305 .extra1 = &zero,
306 },
307 {
308 .procname = "sched_freq_dec_notify",
309 .data = &sysctl_sched_freq_dec_notify,
310 .maxlen = sizeof(unsigned int),
311 .mode = 0644,
312 .proc_handler = proc_dointvec_minmax,
313 .extra1 = &zero,
314 },
315 {
316 .procname = "sched_cpu_high_irqload",
317 .data = &sysctl_sched_cpu_high_irqload,
318 .maxlen = sizeof(unsigned int),
319 .mode = 0644,
320 .proc_handler = proc_dointvec,
321 },
322 {
323 .procname = "sched_ravg_hist_size",
324 .data = &sysctl_sched_ravg_hist_size,
325 .maxlen = sizeof(unsigned int),
326 .mode = 0644,
327 .proc_handler = sched_window_update_handler,
328 },
329 {
330 .procname = "sched_window_stats_policy",
331 .data = &sysctl_sched_window_stats_policy,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
334 .proc_handler = sched_window_update_handler,
335 },
336 {
337 .procname = "sched_spill_load",
338 .data = &sysctl_sched_spill_load_pct,
339 .maxlen = sizeof(unsigned int),
340 .mode = 0644,
341 .proc_handler = sched_hmp_proc_update_handler,
342 .extra1 = &zero,
343 .extra2 = &one_hundred,
344 },
345 {
346 .procname = "sched_spill_nr_run",
347 .data = &sysctl_sched_spill_nr_run,
348 .maxlen = sizeof(unsigned int),
349 .mode = 0644,
350 .proc_handler = proc_dointvec_minmax,
351 .extra1 = &zero,
352 },
353 {
354 .procname = "sched_upmigrate",
355 .data = &sysctl_sched_upmigrate_pct,
356 .maxlen = sizeof(unsigned int),
357 .mode = 0644,
358 .proc_handler = sched_hmp_proc_update_handler,
359 .extra1 = &zero,
360 .extra2 = &one_hundred,
361 },
362 {
363 .procname = "sched_downmigrate",
364 .data = &sysctl_sched_downmigrate_pct,
365 .maxlen = sizeof(unsigned int),
366 .mode = 0644,
367 .proc_handler = sched_hmp_proc_update_handler,
368 .extra1 = &zero,
369 .extra2 = &one_hundred,
370 },
371 {
372 .procname = "sched_init_task_load",
373 .data = &sysctl_sched_init_task_load_pct,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = sched_hmp_proc_update_handler,
377 .extra1 = &zero,
378 .extra2 = &one_hundred,
379 },
380 {
381 .procname = "sched_select_prev_cpu_us",
382 .data = &sysctl_sched_select_prev_cpu_us,
383 .maxlen = sizeof(unsigned int),
384 .mode = 0644,
385 .proc_handler = sched_hmp_proc_update_handler,
386 .extra1 = &zero,
387 },
388 {
389 .procname = "sched_enable_colocation",
390 .data = &sysctl_sched_enable_colocation,
391 .maxlen = sizeof(unsigned int),
392 .mode = 0644,
393 .proc_handler = proc_dointvec,
394 .extra1 = &zero,
395 .extra2 = &one,
396 },
397 {
398 .procname = "sched_restrict_cluster_spill",
399 .data = &sysctl_sched_restrict_cluster_spill,
400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
402 .proc_handler = proc_dointvec_minmax,
403 .extra1 = &zero,
404 .extra2 = &one,
405 },
406 {
407 .procname = "sched_small_wakee_task_load",
408 .data = &sysctl_sched_small_wakee_task_load_pct,
409 .maxlen = sizeof(unsigned int),
410 .mode = 0644,
411 .proc_handler = sched_hmp_proc_update_handler,
412 .extra1 = &zero,
413 .extra2 = &one_hundred,
414 },
415 {
416 .procname = "sched_big_waker_task_load",
417 .data = &sysctl_sched_big_waker_task_load_pct,
418 .maxlen = sizeof(unsigned int),
419 .mode = 0644,
420 .proc_handler = sched_hmp_proc_update_handler,
421 .extra1 = &zero,
422 .extra2 = &one_hundred,
423 },
424 {
425 .procname = "sched_enable_thread_grouping",
426 .data = &sysctl_sched_enable_thread_grouping,
427 .maxlen = sizeof(unsigned int),
428 .mode = 0644,
429 .proc_handler = proc_dointvec,
430 },
431 {
432 .procname = "sched_new_task_windows",
433 .data = &sysctl_sched_new_task_windows,
434 .maxlen = sizeof(unsigned int),
435 .mode = 0644,
436 .proc_handler = sched_window_update_handler,
437 },
438 {
439 .procname = "sched_pred_alert_freq",
440 .data = &sysctl_sched_pred_alert_freq,
441 .maxlen = sizeof(unsigned int),
442 .mode = 0644,
443 .proc_handler = proc_dointvec_minmax,
444 .extra1 = &zero,
445 },
446 {
447 .procname = "sched_freq_aggregate",
448 .data = &sysctl_sched_freq_aggregate,
449 .maxlen = sizeof(unsigned int),
450 .mode = 0644,
451 .proc_handler = sched_window_update_handler,
452 },
453 {
454 .procname = "sched_freq_aggregate_threshold",
455 .data = &sysctl_sched_freq_aggregate_threshold_pct,
456 .maxlen = sizeof(unsigned int),
457 .mode = 0644,
458 .proc_handler = sched_hmp_proc_update_handler,
459 .extra1 = &zero,
460 /*
461 * Special handling for sched_freq_aggregate_threshold_pct
462 * which can be greater than 100. Use 1000 as an upper bound
463 * value which works for all practical use cases.
464 */
465 .extra2 = &one_thousand,
466 },
467 {
468 .procname = "sched_boost",
469 .data = &sysctl_sched_boost,
470 .maxlen = sizeof(unsigned int),
471 .mode = 0644,
472 .proc_handler = sched_boost_handler,
473 },
474#endif /* CONFIG_SCHED_HMP */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200475#ifdef CONFIG_SCHED_DEBUG
476 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100477 .procname = "sched_min_granularity_ns",
478 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200479 .maxlen = sizeof(unsigned int),
480 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800481 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100482 .extra1 = &min_sched_granularity_ns,
483 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200484 },
485 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200486 .procname = "sched_latency_ns",
487 .data = &sysctl_sched_latency,
488 .maxlen = sizeof(unsigned int),
489 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800490 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200491 .extra1 = &min_sched_granularity_ns,
492 .extra2 = &max_sched_granularity_ns,
493 },
494 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200495 .procname = "sched_wakeup_granularity_ns",
496 .data = &sysctl_sched_wakeup_granularity,
497 .maxlen = sizeof(unsigned int),
498 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800499 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200500 .extra1 = &min_wakeup_granularity_ns,
501 .extra2 = &max_wakeup_granularity_ns,
502 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200503#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200504 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100505 .procname = "sched_tunable_scaling",
506 .data = &sysctl_sched_tunable_scaling,
507 .maxlen = sizeof(enum sched_tunable_scaling),
508 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800509 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100510 .extra1 = &min_sched_tunable_scaling,
511 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200512 },
513 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900514 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200515 .data = &sysctl_sched_migration_cost,
516 .maxlen = sizeof(unsigned int),
517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800518 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200519 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100520 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100521 .procname = "sched_nr_migrate",
522 .data = &sysctl_sched_nr_migrate,
523 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800525 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100526 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530527 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900528 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200529 .data = &sysctl_sched_time_avg,
530 .maxlen = sizeof(unsigned int),
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200533 },
534 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900535 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800536 .data = &sysctl_sched_shares_window,
537 .maxlen = sizeof(unsigned int),
538 .mode = 0644,
539 .proc_handler = proc_dointvec,
540 },
Mel Gormancb251762016-02-05 09:08:36 +0000541#ifdef CONFIG_SCHEDSTATS
542 {
543 .procname = "sched_schedstats",
544 .data = NULL,
545 .maxlen = sizeof(unsigned int),
546 .mode = 0644,
547 .proc_handler = sysctl_schedstats,
548 .extra1 = &zero,
549 .extra2 = &one,
550 },
551#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200552#endif /* CONFIG_SMP */
553#ifdef CONFIG_NUMA_BALANCING
554 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200555 .procname = "numa_balancing_scan_delay_ms",
556 .data = &sysctl_numa_balancing_scan_delay,
557 .maxlen = sizeof(unsigned int),
558 .mode = 0644,
559 .proc_handler = proc_dointvec,
560 },
561 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200562 .procname = "numa_balancing_scan_period_min_ms",
563 .data = &sysctl_numa_balancing_scan_period_min,
564 .maxlen = sizeof(unsigned int),
565 .mode = 0644,
566 .proc_handler = proc_dointvec,
567 },
568 {
569 .procname = "numa_balancing_scan_period_max_ms",
570 .data = &sysctl_numa_balancing_scan_period_max,
571 .maxlen = sizeof(unsigned int),
572 .mode = 0644,
573 .proc_handler = proc_dointvec,
574 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200575 {
576 .procname = "numa_balancing_scan_size_mb",
577 .data = &sysctl_numa_balancing_scan_size,
578 .maxlen = sizeof(unsigned int),
579 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400580 .proc_handler = proc_dointvec_minmax,
581 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200582 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100583 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800584 .procname = "numa_balancing",
585 .data = NULL, /* filled in by handler */
586 .maxlen = sizeof(unsigned int),
587 .mode = 0644,
588 .proc_handler = sysctl_numa_balancing,
589 .extra1 = &zero,
590 .extra2 = &one,
591 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200592#endif /* CONFIG_NUMA_BALANCING */
593#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200594 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100595 .procname = "sched_rt_period_us",
596 .data = &sysctl_sched_rt_period,
597 .maxlen = sizeof(unsigned int),
598 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800599 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100600 },
601 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100602 .procname = "sched_rt_runtime_us",
603 .data = &sysctl_sched_rt_runtime,
604 .maxlen = sizeof(int),
605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800606 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100607 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600608 {
609 .procname = "sched_rr_timeslice_ms",
610 .data = &sched_rr_timeslice,
611 .maxlen = sizeof(int),
612 .mode = 0644,
613 .proc_handler = sched_rr_handler,
614 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100615#ifdef CONFIG_SCHED_AUTOGROUP
616 {
617 .procname = "sched_autogroup_enabled",
618 .data = &sysctl_sched_autogroup_enabled,
619 .maxlen = sizeof(unsigned int),
620 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800621 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100622 .extra1 = &zero,
623 .extra2 = &one,
624 },
625#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700626#ifdef CONFIG_CFS_BANDWIDTH
627 {
628 .procname = "sched_cfs_bandwidth_slice_us",
629 .data = &sysctl_sched_cfs_bandwidth_slice,
630 .maxlen = sizeof(unsigned int),
631 .mode = 0644,
632 .proc_handler = proc_dointvec_minmax,
633 .extra1 = &one,
634 },
635#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700636#ifdef CONFIG_PROVE_LOCKING
637 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700638 .procname = "prove_locking",
639 .data = &prove_locking,
640 .maxlen = sizeof(int),
641 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800642 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700643 },
644#endif
645#ifdef CONFIG_LOCK_STAT
646 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700647 .procname = "lock_stat",
648 .data = &lock_stat,
649 .maxlen = sizeof(int),
650 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800651 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700652 },
653#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200654 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 .procname = "panic",
656 .data = &panic_timeout,
657 .maxlen = sizeof(int),
658 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 },
Alex Kelly046d6622012-10-04 17:15:23 -0700661#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .procname = "core_uses_pid",
664 .data = &core_uses_pid,
665 .maxlen = sizeof(int),
666 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800667 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 },
669 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .procname = "core_pattern",
671 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700672 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700674 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 },
Neil Hormana2939802009-09-23 15:56:56 -0700676 {
Neil Hormana2939802009-09-23 15:56:56 -0700677 .procname = "core_pipe_limit",
678 .data = &core_pipe_limit,
679 .maxlen = sizeof(unsigned int),
680 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800681 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700682 },
Alex Kelly046d6622012-10-04 17:15:23 -0700683#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800684#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700687 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800688 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800689 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700691 {
692 .procname = "sysctl_writes_strict",
693 .data = &sysctl_writes_strict,
694 .maxlen = sizeof(int),
695 .mode = 0644,
696 .proc_handler = proc_dointvec_minmax,
697 .extra1 = &neg_one,
698 .extra2 = &one,
699 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800700#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100701#ifdef CONFIG_LATENCYTOP
702 {
703 .procname = "latencytop",
704 .data = &latencytop_enabled,
705 .maxlen = sizeof(int),
706 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000707 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100708 },
709#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710#ifdef CONFIG_BLK_DEV_INITRD
711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .procname = "real-root-dev",
713 .data = &real_root_dev,
714 .maxlen = sizeof(int),
715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800716 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 },
718#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700719 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700720 .procname = "print-fatal-signals",
721 .data = &print_fatal_signals,
722 .maxlen = sizeof(int),
723 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800724 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700725 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700726#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 .procname = "reboot-cmd",
729 .data = reboot_command,
730 .maxlen = 256,
731 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800732 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 },
734 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .procname = "stop-a",
736 .data = &stop_a_enabled,
737 .maxlen = sizeof (int),
738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 },
741 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .procname = "scons-poweroff",
743 .data = &scons_pwroff,
744 .maxlen = sizeof (int),
745 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800746 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 },
748#endif
David S. Miller08714202008-11-16 23:49:24 -0800749#ifdef CONFIG_SPARC64
750 {
David S. Miller08714202008-11-16 23:49:24 -0800751 .procname = "tsb-ratio",
752 .data = &sysctl_tsb_ratio,
753 .maxlen = sizeof (int),
754 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800755 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800756 },
757#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758#ifdef __hppa__
759 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 .procname = "soft-power",
761 .data = &pwrsw_enabled,
762 .maxlen = sizeof (int),
763 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800764 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530766#endif
767#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 .procname = "unaligned-trap",
770 .data = &unaligned_enabled,
771 .maxlen = sizeof (int),
772 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800773 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 },
775#endif
776 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 .procname = "ctrl-alt-del",
778 .data = &C_A_D,
779 .maxlen = sizeof(int),
780 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800781 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400783#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200784 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200785 .procname = "ftrace_enabled",
786 .data = &ftrace_enabled,
787 .maxlen = sizeof(int),
788 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800789 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200790 },
791#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500792#ifdef CONFIG_STACK_TRACER
793 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500794 .procname = "stack_tracer_enabled",
795 .data = &stack_tracer_enabled,
796 .maxlen = sizeof(int),
797 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800798 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500799 },
800#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400801#ifdef CONFIG_TRACING
802 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100803 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400804 .data = &ftrace_dump_on_oops,
805 .maxlen = sizeof(int),
806 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800807 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400808 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400809 {
810 .procname = "traceoff_on_warning",
811 .data = &__disable_trace_on_warning,
812 .maxlen = sizeof(__disable_trace_on_warning),
813 .mode = 0644,
814 .proc_handler = proc_dointvec,
815 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500816 {
817 .procname = "tracepoint_printk",
818 .data = &tracepoint_printk,
819 .maxlen = sizeof(tracepoint_printk),
820 .mode = 0644,
821 .proc_handler = proc_dointvec,
822 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400823#endif
Dave Young2965faa2015-09-09 15:38:55 -0700824#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800825 {
826 .procname = "kexec_load_disabled",
827 .data = &kexec_load_disabled,
828 .maxlen = sizeof(int),
829 .mode = 0644,
830 /* only handle a transition from default "0" to "1" */
831 .proc_handler = proc_dointvec_minmax,
832 .extra1 = &one,
833 .extra2 = &one,
834 },
835#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200836#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 .procname = "modprobe",
839 .data = &modprobe_path,
840 .maxlen = KMOD_PATH_LEN,
841 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800842 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 },
Kees Cook3d433212009-04-02 15:49:29 -0700844 {
Kees Cook3d433212009-04-02 15:49:29 -0700845 .procname = "modules_disabled",
846 .data = &modules_disabled,
847 .maxlen = sizeof(int),
848 .mode = 0644,
849 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800850 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700851 .extra1 = &one,
852 .extra2 = &one,
853 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700855#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100858 .data = &uevent_helper,
859 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 },
Michael Marineau86d56132014-04-10 14:09:31 -0700863#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864#ifdef CONFIG_CHR_DEV_SG
865 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 .procname = "sg-big-buff",
867 .data = &sg_big_buff,
868 .maxlen = sizeof (int),
869 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800870 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 },
872#endif
873#ifdef CONFIG_BSD_PROCESS_ACCT
874 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 .procname = "acct",
876 .data = &acct_parm,
877 .maxlen = 3*sizeof(int),
878 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800879 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 },
881#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882#ifdef CONFIG_MAGIC_SYSRQ
883 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800885 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 .maxlen = sizeof (int),
887 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700888 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 },
890#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700891#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700894 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 .maxlen = sizeof (int),
896 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700899#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700902 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 .maxlen = sizeof(int),
904 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700905 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 },
907 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 .procname = "random",
909 .mode = 0555,
910 .child = random_table,
911 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 {
Eric Paris17f60a72011-04-01 17:07:50 -0400913 .procname = "usermodehelper",
914 .mode = 0555,
915 .child = usermodehelper_table,
916 },
917 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 .procname = "overflowuid",
919 .data = &overflowuid,
920 .maxlen = sizeof(int),
921 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800922 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923 .extra1 = &minolduid,
924 .extra2 = &maxolduid,
925 },
926 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 .procname = "overflowgid",
928 .data = &overflowgid,
929 .maxlen = sizeof(int),
930 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800931 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 .extra1 = &minolduid,
933 .extra2 = &maxolduid,
934 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800935#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936#ifdef CONFIG_MATHEMU
937 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 .procname = "ieee_emulation_warnings",
939 .data = &sysctl_ieee_emulation_warnings,
940 .maxlen = sizeof(int),
941 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800942 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 },
944#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200947 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 .maxlen = sizeof(int),
949 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800950 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 },
952#endif
953 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 .procname = "pid_max",
955 .data = &pid_max,
956 .maxlen = sizeof (int),
957 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800958 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 .extra1 = &pid_max_min,
960 .extra2 = &pid_max_max,
961 },
962 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963 .procname = "panic_on_oops",
964 .data = &panic_on_oops,
965 .maxlen = sizeof(int),
966 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800967 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800969#if defined CONFIG_PRINTK
970 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800971 .procname = "printk",
972 .data = &console_loglevel,
973 .maxlen = 4*sizeof(int),
974 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800975 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800976 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700979 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 .maxlen = sizeof(int),
981 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800982 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983 },
984 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700986 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 .maxlen = sizeof(int),
988 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800989 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 },
Dave Youngaf913222009-09-22 16:43:33 -0700991 {
Dave Youngaf913222009-09-22 16:43:33 -0700992 .procname = "printk_delay",
993 .data = &printk_delay_msec,
994 .maxlen = sizeof(int),
995 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800996 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700997 .extra1 = &zero,
998 .extra2 = &ten_thousand,
999 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 {
Borislav Petkov750afe72016-08-02 14:04:07 -07001001 .procname = "printk_devkmsg",
1002 .data = devkmsg_log_str,
1003 .maxlen = DEVKMSG_STR_MAX_SIZE,
1004 .mode = 0644,
1005 .proc_handler = devkmsg_sysctl_set_loglvl,
1006 },
1007 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -08001008 .procname = "dmesg_restrict",
1009 .data = &dmesg_restrict,
1010 .maxlen = sizeof(int),
1011 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -07001012 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -08001013 .extra1 = &zero,
1014 .extra2 = &one,
1015 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -08001016 {
1017 .procname = "kptr_restrict",
1018 .data = &kptr_restrict,
1019 .maxlen = sizeof(int),
1020 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -07001021 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -08001022 .extra1 = &zero,
1023 .extra2 = &two,
1024 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -08001025#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -08001026 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 .procname = "ngroups_max",
1028 .data = &ngroups_max,
1029 .maxlen = sizeof (int),
1030 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 },
Dan Ballard73efc032011-10-31 17:11:20 -07001033 {
1034 .procname = "cap_last_cap",
1035 .data = (void *)&cap_last_cap,
1036 .maxlen = sizeof(int),
1037 .mode = 0444,
1038 .proc_handler = proc_dointvec,
1039 },
Don Zickus58687ac2010-05-07 17:11:44 -04001040#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -05001041 {
Don Zickus58687ac2010-05-07 17:11:44 -04001042 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +02001043 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -05001044 .maxlen = sizeof (int),
1045 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001046 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001047 .extra1 = &zero,
1048 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -04001049 },
1050 {
1051 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -07001052 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -04001053 .maxlen = sizeof(int),
1054 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001055 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +08001056 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -04001057 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -05001058 },
Don Zickus2508ce12010-05-07 17:11:46 -04001059 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -07001060 .procname = "nmi_watchdog",
1061 .data = &nmi_watchdog_enabled,
1062 .maxlen = sizeof (int),
1063 .mode = 0644,
1064 .proc_handler = proc_nmi_watchdog,
1065 .extra1 = &zero,
1066#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
1067 .extra2 = &one,
1068#else
1069 .extra2 = &zero,
1070#endif
1071 },
1072 {
1073 .procname = "soft_watchdog",
1074 .data = &soft_watchdog_enabled,
1075 .maxlen = sizeof (int),
1076 .mode = 0644,
1077 .proc_handler = proc_soft_watchdog,
1078 .extra1 = &zero,
1079 .extra2 = &one,
1080 },
1081 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -07001082 .procname = "watchdog_cpumask",
1083 .data = &watchdog_cpumask_bits,
1084 .maxlen = NR_CPUS,
1085 .mode = 0644,
1086 .proc_handler = proc_watchdog_cpumask,
1087 },
1088 {
Don Zickus2508ce12010-05-07 17:11:46 -04001089 .procname = "softlockup_panic",
1090 .data = &softlockup_panic,
1091 .maxlen = sizeof(int),
1092 .mode = 0644,
1093 .proc_handler = proc_dointvec_minmax,
1094 .extra1 = &zero,
1095 .extra2 = &one,
1096 },
Don Zickusac1f5912015-11-05 18:44:44 -08001097#ifdef CONFIG_HARDLOCKUP_DETECTOR
1098 {
1099 .procname = "hardlockup_panic",
1100 .data = &hardlockup_panic,
1101 .maxlen = sizeof(int),
1102 .mode = 0644,
1103 .proc_handler = proc_dointvec_minmax,
1104 .extra1 = &zero,
1105 .extra2 = &one,
1106 },
1107#endif
Aaron Tomlined235872014-06-23 13:22:05 -07001108#ifdef CONFIG_SMP
1109 {
1110 .procname = "softlockup_all_cpu_backtrace",
1111 .data = &sysctl_softlockup_all_cpu_backtrace,
1112 .maxlen = sizeof(int),
1113 .mode = 0644,
1114 .proc_handler = proc_dointvec_minmax,
1115 .extra1 = &zero,
1116 .extra2 = &one,
1117 },
Jiri Kosina55537872015-11-05 18:44:41 -08001118 {
1119 .procname = "hardlockup_all_cpu_backtrace",
1120 .data = &sysctl_hardlockup_all_cpu_backtrace,
1121 .maxlen = sizeof(int),
1122 .mode = 0644,
1123 .proc_handler = proc_dointvec_minmax,
1124 .extra1 = &zero,
1125 .extra2 = &one,
1126 },
Aaron Tomlined235872014-06-23 13:22:05 -07001127#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001128#endif
1129#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1130 {
1131 .procname = "unknown_nmi_panic",
1132 .data = &unknown_nmi_panic,
1133 .maxlen = sizeof (int),
1134 .mode = 0644,
1135 .proc_handler = proc_dointvec,
1136 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001137#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138#if defined(CONFIG_X86)
1139 {
Don Zickus8da5add2006-09-26 10:52:27 +02001140 .procname = "panic_on_unrecovered_nmi",
1141 .data = &panic_on_unrecovered_nmi,
1142 .maxlen = sizeof(int),
1143 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001144 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001145 },
1146 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001147 .procname = "panic_on_io_nmi",
1148 .data = &panic_on_io_nmi,
1149 .maxlen = sizeof(int),
1150 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001151 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001152 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001153#ifdef CONFIG_DEBUG_STACKOVERFLOW
1154 {
1155 .procname = "panic_on_stackoverflow",
1156 .data = &sysctl_panic_on_stackoverflow,
1157 .maxlen = sizeof(int),
1158 .mode = 0644,
1159 .proc_handler = proc_dointvec,
1160 },
1161#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001162 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 .procname = "bootloader_type",
1164 .data = &bootloader_type,
1165 .maxlen = sizeof (int),
1166 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001167 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001169 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001170 .procname = "bootloader_version",
1171 .data = &bootloader_version,
1172 .maxlen = sizeof (int),
1173 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001174 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001175 },
1176 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001177 .procname = "kstack_depth_to_print",
1178 .data = &kstack_depth_to_print,
1179 .maxlen = sizeof(int),
1180 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001181 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001182 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001183 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001184 .procname = "io_delay_type",
1185 .data = &io_delay_type,
1186 .maxlen = sizeof(int),
1187 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001188 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001189 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001191#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 .procname = "randomize_va_space",
1194 .data = &randomize_va_space,
1195 .maxlen = sizeof(int),
1196 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001197 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001199#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001200#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001201 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001202 .procname = "spin_retry",
1203 .data = &spin_retry,
1204 .maxlen = sizeof (int),
1205 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001206 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001207 },
1208#endif
Len Brown673d5b42007-07-28 03:33:16 -04001209#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001210 {
Pavel Machekc255d842006-02-20 18:27:58 -08001211 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001212 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001213 .maxlen = sizeof (unsigned long),
1214 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001215 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001216 },
1217#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301218#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001219 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001220 .procname = "ignore-unaligned-usertrap",
1221 .data = &no_unaligned_warning,
1222 .maxlen = sizeof (int),
1223 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001224 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001225 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301226#endif
1227#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001228 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001229 .procname = "unaligned-dump-stack",
1230 .data = &unaligned_dump_stack,
1231 .maxlen = sizeof (int),
1232 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001233 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001234 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001235#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001236#ifdef CONFIG_DETECT_HUNG_TASK
1237 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001238 .procname = "hung_task_panic",
1239 .data = &sysctl_hung_task_panic,
1240 .maxlen = sizeof(int),
1241 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001242 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001243 .extra1 = &zero,
1244 .extra2 = &one,
1245 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001246 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001247 .procname = "hung_task_check_count",
1248 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001249 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001250 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001251 .proc_handler = proc_dointvec_minmax,
1252 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001253 },
1254 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001255 .procname = "hung_task_timeout_secs",
1256 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001257 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001258 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001259 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001260 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001261 },
1262 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001263 .procname = "hung_task_warnings",
1264 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001265 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001266 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001267 .proc_handler = proc_dointvec_minmax,
1268 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001269 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001270#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001271#ifdef CONFIG_RT_MUTEXES
1272 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001273 .procname = "max_lock_depth",
1274 .data = &max_lock_depth,
1275 .maxlen = sizeof(int),
1276 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001277 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001278 },
1279#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001280 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001281 .procname = "poweroff_cmd",
1282 .data = &poweroff_cmd,
1283 .maxlen = POWEROFF_CMD_PATH_LEN,
1284 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001285 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001286 },
David Howells0b77f5b2008-04-29 01:01:32 -07001287#ifdef CONFIG_KEYS
1288 {
David Howells0b77f5b2008-04-29 01:01:32 -07001289 .procname = "keys",
1290 .mode = 0555,
1291 .child = key_sysctls,
1292 },
1293#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001294#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001295 /*
1296 * User-space scripts rely on the existence of this file
1297 * as a feature check for perf_events being enabled.
1298 *
1299 * So it's an ABI, do not remove!
1300 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001301 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001302 .procname = "perf_event_paranoid",
1303 .data = &sysctl_perf_event_paranoid,
1304 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001305 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001306 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001307 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001308 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001309 .procname = "perf_event_mlock_kb",
1310 .data = &sysctl_perf_event_mlock,
1311 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001312 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001313 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001314 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001315 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001316 .procname = "perf_event_max_sample_rate",
1317 .data = &sysctl_perf_event_sample_rate,
1318 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001319 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001320 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001321 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001322 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001323 {
1324 .procname = "perf_cpu_time_max_percent",
1325 .data = &sysctl_perf_cpu_time_max_percent,
1326 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1327 .mode = 0644,
1328 .proc_handler = perf_cpu_time_max_percent_handler,
1329 .extra1 = &zero,
1330 .extra2 = &one_hundred,
1331 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001332 {
1333 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001334 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001335 .maxlen = sizeof(sysctl_perf_event_max_stack),
1336 .mode = 0644,
1337 .proc_handler = perf_event_max_stack_handler,
1338 .extra1 = &zero,
1339 .extra2 = &six_hundred_forty_kb,
1340 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001341 {
1342 .procname = "perf_event_max_contexts_per_stack",
1343 .data = &sysctl_perf_event_max_contexts_per_stack,
1344 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1345 .mode = 0644,
1346 .proc_handler = perf_event_max_stack_handler,
1347 .extra1 = &zero,
1348 .extra2 = &one_thousand,
1349 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001350#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001351#ifdef CONFIG_KMEMCHECK
1352 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001353 .procname = "kmemcheck",
1354 .data = &kmemcheck_enabled,
1355 .maxlen = sizeof(int),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001358 },
1359#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001360 {
1361 .procname = "panic_on_warn",
1362 .data = &panic_on_warn,
1363 .maxlen = sizeof(int),
1364 .mode = 0644,
1365 .proc_handler = proc_dointvec_minmax,
1366 .extra1 = &zero,
1367 .extra2 = &one,
1368 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001369#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1370 {
1371 .procname = "timer_migration",
1372 .data = &sysctl_timer_migration,
1373 .maxlen = sizeof(unsigned int),
1374 .mode = 0644,
1375 .proc_handler = timer_migration_handler,
1376 },
1377#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001378#ifdef CONFIG_BPF_SYSCALL
1379 {
1380 .procname = "unprivileged_bpf_disabled",
1381 .data = &sysctl_unprivileged_bpf_disabled,
1382 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1383 .mode = 0644,
1384 /* only handle a transition from default "0" to "1" */
1385 .proc_handler = proc_dointvec_minmax,
1386 .extra1 = &one,
1387 .extra2 = &one,
1388 },
1389#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001390#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1391 {
1392 .procname = "panic_on_rcu_stall",
1393 .data = &sysctl_panic_on_rcu_stall,
1394 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1395 .mode = 0644,
1396 .proc_handler = proc_dointvec_minmax,
1397 .extra1 = &zero,
1398 .extra2 = &one,
1399 },
1400#endif
David Collinsa1792ad2014-01-10 14:11:24 -08001401#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
Rick Adamsea449ff2010-09-28 10:21:07 -07001402 {
1403 .procname = "boot_reason",
1404 .data = &boot_reason,
1405 .maxlen = sizeof(int),
1406 .mode = 0444,
1407 .proc_handler = proc_dointvec,
David Keitel381adf32013-03-26 18:50:03 -07001408 },
1409
1410 {
1411 .procname = "cold_boot",
1412 .data = &cold_boot,
1413 .maxlen = sizeof(int),
1414 .mode = 0444,
1415 .proc_handler = proc_dointvec,
1416 },
Rick Adamsea449ff2010-09-28 10:21:07 -07001417#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001418 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419};
1420
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001421static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 .procname = "overcommit_memory",
1424 .data = &sysctl_overcommit_memory,
1425 .maxlen = sizeof(sysctl_overcommit_memory),
1426 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001427 .proc_handler = proc_dointvec_minmax,
1428 .extra1 = &zero,
1429 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 },
1431 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001432 .procname = "panic_on_oom",
1433 .data = &sysctl_panic_on_oom,
1434 .maxlen = sizeof(sysctl_panic_on_oom),
1435 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001436 .proc_handler = proc_dointvec_minmax,
1437 .extra1 = &zero,
1438 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001439 },
1440 {
David Rientjesfe071d72007-10-16 23:25:56 -07001441 .procname = "oom_kill_allocating_task",
1442 .data = &sysctl_oom_kill_allocating_task,
1443 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001445 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001446 },
1447 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001448 .procname = "oom_dump_tasks",
1449 .data = &sysctl_oom_dump_tasks,
1450 .maxlen = sizeof(sysctl_oom_dump_tasks),
1451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001452 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001453 },
1454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 .procname = "overcommit_ratio",
1456 .data = &sysctl_overcommit_ratio,
1457 .maxlen = sizeof(sysctl_overcommit_ratio),
1458 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001459 .proc_handler = overcommit_ratio_handler,
1460 },
1461 {
1462 .procname = "overcommit_kbytes",
1463 .data = &sysctl_overcommit_kbytes,
1464 .maxlen = sizeof(sysctl_overcommit_kbytes),
1465 .mode = 0644,
1466 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 },
1468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 .procname = "page-cluster",
1470 .data = &page_cluster,
1471 .maxlen = sizeof(int),
1472 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001473 .proc_handler = proc_dointvec_minmax,
1474 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475 },
1476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .procname = "dirty_background_ratio",
1478 .data = &dirty_background_ratio,
1479 .maxlen = sizeof(dirty_background_ratio),
1480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001481 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 .extra1 = &zero,
1483 .extra2 = &one_hundred,
1484 },
1485 {
David Rientjes2da02992009-01-06 14:39:31 -08001486 .procname = "dirty_background_bytes",
1487 .data = &dirty_background_bytes,
1488 .maxlen = sizeof(dirty_background_bytes),
1489 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001490 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001491 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001492 },
1493 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .procname = "dirty_ratio",
1495 .data = &vm_dirty_ratio,
1496 .maxlen = sizeof(vm_dirty_ratio),
1497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001498 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 .extra1 = &zero,
1500 .extra2 = &one_hundred,
1501 },
1502 {
David Rientjes2da02992009-01-06 14:39:31 -08001503 .procname = "dirty_bytes",
1504 .data = &vm_dirty_bytes,
1505 .maxlen = sizeof(vm_dirty_bytes),
1506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001507 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001508 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001509 },
1510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001512 .data = &dirty_writeback_interval,
1513 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 },
1517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001519 .data = &dirty_expire_interval,
1520 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001522 .proc_handler = proc_dointvec_minmax,
1523 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 },
1525 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001526 .procname = "dirtytime_expire_seconds",
1527 .data = &dirtytime_expire_interval,
1528 .maxlen = sizeof(dirty_expire_interval),
1529 .mode = 0644,
1530 .proc_handler = dirtytime_interval_handler,
1531 .extra1 = &zero,
1532 },
1533 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001534 .procname = "nr_pdflush_threads",
1535 .mode = 0444 /* read-only */,
1536 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 },
1538 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 .procname = "swappiness",
1540 .data = &vm_swappiness,
1541 .maxlen = sizeof(vm_swappiness),
1542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001543 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 .extra1 = &zero,
1545 .extra2 = &one_hundred,
1546 },
1547#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001548 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001550 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 .maxlen = sizeof(unsigned long),
1552 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001553 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001554 },
1555#ifdef CONFIG_NUMA
1556 {
1557 .procname = "nr_hugepages_mempolicy",
1558 .data = NULL,
1559 .maxlen = sizeof(unsigned long),
1560 .mode = 0644,
1561 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001562 },
1563#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565 .procname = "hugetlb_shm_group",
1566 .data = &sysctl_hugetlb_shm_group,
1567 .maxlen = sizeof(gid_t),
1568 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001569 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001570 },
Mel Gorman396faf02007-07-17 04:03:13 -07001571 {
Mel Gorman396faf02007-07-17 04:03:13 -07001572 .procname = "hugepages_treat_as_movable",
1573 .data = &hugepages_treat_as_movable,
1574 .maxlen = sizeof(int),
1575 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001576 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001577 },
Adam Litke54f9f802007-10-16 01:26:20 -07001578 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001579 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001580 .data = NULL,
1581 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001583 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001584 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585#endif
1586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 .procname = "lowmem_reserve_ratio",
1588 .data = &sysctl_lowmem_reserve_ratio,
1589 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001591 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 },
1593 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001594 .procname = "drop_caches",
1595 .data = &sysctl_drop_caches,
1596 .maxlen = sizeof(int),
1597 .mode = 0644,
1598 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001599 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001600 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001601 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001602#ifdef CONFIG_COMPACTION
1603 {
1604 .procname = "compact_memory",
1605 .data = &sysctl_compact_memory,
1606 .maxlen = sizeof(int),
1607 .mode = 0200,
1608 .proc_handler = sysctl_compaction_handler,
1609 },
Mel Gorman5e771902010-05-24 14:32:31 -07001610 {
1611 .procname = "extfrag_threshold",
1612 .data = &sysctl_extfrag_threshold,
1613 .maxlen = sizeof(int),
1614 .mode = 0644,
1615 .proc_handler = sysctl_extfrag_handler,
1616 .extra1 = &min_extfrag_threshold,
1617 .extra2 = &max_extfrag_threshold,
1618 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001619 {
1620 .procname = "compact_unevictable_allowed",
1621 .data = &sysctl_compact_unevictable_allowed,
1622 .maxlen = sizeof(int),
1623 .mode = 0644,
1624 .proc_handler = proc_dointvec,
1625 .extra1 = &zero,
1626 .extra2 = &one,
1627 },
Mel Gorman5e771902010-05-24 14:32:31 -07001628
Mel Gorman76ab0f52010-05-24 14:32:28 -07001629#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001630 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631 .procname = "min_free_kbytes",
1632 .data = &min_free_kbytes,
1633 .maxlen = sizeof(min_free_kbytes),
1634 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001635 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636 .extra1 = &zero,
1637 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001638 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001639 .procname = "watermark_scale_factor",
1640 .data = &watermark_scale_factor,
1641 .maxlen = sizeof(watermark_scale_factor),
1642 .mode = 0644,
1643 .proc_handler = watermark_scale_factor_sysctl_handler,
1644 .extra1 = &one,
1645 .extra2 = &one_thousand,
1646 },
1647 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001648 .procname = "percpu_pagelist_fraction",
1649 .data = &percpu_pagelist_fraction,
1650 .maxlen = sizeof(percpu_pagelist_fraction),
1651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001652 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001653 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001654 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655#ifdef CONFIG_MMU
1656 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657 .procname = "max_map_count",
1658 .data = &sysctl_max_map_count,
1659 .maxlen = sizeof(sysctl_max_map_count),
1660 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001661 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001662 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001664#else
1665 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001666 .procname = "nr_trim_pages",
1667 .data = &sysctl_nr_trim_pages,
1668 .maxlen = sizeof(sysctl_nr_trim_pages),
1669 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001670 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001671 .extra1 = &zero,
1672 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673#endif
1674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001675 .procname = "laptop_mode",
1676 .data = &laptop_mode,
1677 .maxlen = sizeof(laptop_mode),
1678 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001679 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 },
1681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682 .procname = "block_dump",
1683 .data = &block_dump,
1684 .maxlen = sizeof(block_dump),
1685 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001686 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 .extra1 = &zero,
1688 },
1689 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001690 .procname = "vfs_cache_pressure",
1691 .data = &sysctl_vfs_cache_pressure,
1692 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001694 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001695 .extra1 = &zero,
1696 },
1697#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1698 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 .procname = "legacy_va_layout",
1700 .data = &sysctl_legacy_va_layout,
1701 .maxlen = sizeof(sysctl_legacy_va_layout),
1702 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001703 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001704 .extra1 = &zero,
1705 },
1706#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001707#ifdef CONFIG_NUMA
1708 {
Christoph Lameter17436602006-01-18 17:42:32 -08001709 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001710 .data = &node_reclaim_mode,
1711 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001712 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001713 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001714 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001715 },
Christoph Lameter96146342006-07-03 00:24:13 -07001716 {
Christoph Lameter96146342006-07-03 00:24:13 -07001717 .procname = "min_unmapped_ratio",
1718 .data = &sysctl_min_unmapped_ratio,
1719 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1720 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001721 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001722 .extra1 = &zero,
1723 .extra2 = &one_hundred,
1724 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001725 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001726 .procname = "min_slab_ratio",
1727 .data = &sysctl_min_slab_ratio,
1728 .maxlen = sizeof(sysctl_min_slab_ratio),
1729 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001730 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001731 .extra1 = &zero,
1732 .extra2 = &one_hundred,
1733 },
Christoph Lameter17436602006-01-18 17:42:32 -08001734#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001735#ifdef CONFIG_SMP
1736 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001737 .procname = "stat_interval",
1738 .data = &sysctl_stat_interval,
1739 .maxlen = sizeof(sysctl_stat_interval),
1740 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001741 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001742 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001743 {
1744 .procname = "stat_refresh",
1745 .data = NULL,
1746 .maxlen = 0,
1747 .mode = 0600,
1748 .proc_handler = vmstat_refresh,
1749 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001750#endif
David Howells6e141542009-12-15 19:27:45 +00001751#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001752 {
Eric Parised032182007-06-28 15:55:21 -04001753 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001754 .data = &dac_mmap_min_addr,
1755 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001756 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001757 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001758 },
David Howells6e141542009-12-15 19:27:45 +00001759#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001760#ifdef CONFIG_NUMA
1761 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001762 .procname = "numa_zonelist_order",
1763 .data = &numa_zonelist_order,
1764 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1765 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001766 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001767 },
1768#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001769#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001770 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001771 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001772 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001773#ifdef CONFIG_X86_32
1774 .data = &vdso32_enabled,
1775 .maxlen = sizeof(vdso32_enabled),
1776#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001777 .data = &vdso_enabled,
1778 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001779#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001780 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001781 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001782 .extra1 = &zero,
1783 },
1784#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001785#ifdef CONFIG_HIGHMEM
1786 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001787 .procname = "highmem_is_dirtyable",
1788 .data = &vm_highmem_is_dirtyable,
1789 .maxlen = sizeof(vm_highmem_is_dirtyable),
1790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001791 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001792 .extra1 = &zero,
1793 .extra2 = &one,
1794 },
1795#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001796#ifdef CONFIG_MEMORY_FAILURE
1797 {
Andi Kleen6a460792009-09-16 11:50:15 +02001798 .procname = "memory_failure_early_kill",
1799 .data = &sysctl_memory_failure_early_kill,
1800 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1801 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001802 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001803 .extra1 = &zero,
1804 .extra2 = &one,
1805 },
1806 {
Andi Kleen6a460792009-09-16 11:50:15 +02001807 .procname = "memory_failure_recovery",
1808 .data = &sysctl_memory_failure_recovery,
1809 .maxlen = sizeof(sysctl_memory_failure_recovery),
1810 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001811 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001812 .extra1 = &zero,
1813 .extra2 = &one,
1814 },
1815#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001816 {
1817 .procname = "user_reserve_kbytes",
1818 .data = &sysctl_user_reserve_kbytes,
1819 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1820 .mode = 0644,
1821 .proc_handler = proc_doulongvec_minmax,
1822 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001823 {
1824 .procname = "admin_reserve_kbytes",
1825 .data = &sysctl_admin_reserve_kbytes,
1826 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1827 .mode = 0644,
1828 .proc_handler = proc_doulongvec_minmax,
1829 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001830#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1831 {
1832 .procname = "mmap_rnd_bits",
1833 .data = &mmap_rnd_bits,
1834 .maxlen = sizeof(mmap_rnd_bits),
1835 .mode = 0600,
1836 .proc_handler = proc_dointvec_minmax,
1837 .extra1 = (void *)&mmap_rnd_bits_min,
1838 .extra2 = (void *)&mmap_rnd_bits_max,
1839 },
1840#endif
1841#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1842 {
1843 .procname = "mmap_rnd_compat_bits",
1844 .data = &mmap_rnd_compat_bits,
1845 .maxlen = sizeof(mmap_rnd_compat_bits),
1846 .mode = 0600,
1847 .proc_handler = proc_dointvec_minmax,
1848 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1849 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1850 },
1851#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001852 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001853};
1854
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001855static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001856 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857 .procname = "inode-nr",
1858 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001859 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001861 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 },
1863 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001864 .procname = "inode-state",
1865 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001866 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001868 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 },
1870 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871 .procname = "file-nr",
1872 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001873 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001875 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 },
1877 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878 .procname = "file-max",
1879 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001880 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001882 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001883 },
1884 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001885 .procname = "nr_open",
1886 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001887 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001888 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001889 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001890 .extra1 = &sysctl_nr_open_min,
1891 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001892 },
1893 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894 .procname = "dentry-state",
1895 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001896 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001897 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001898 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 },
1900 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901 .procname = "overflowuid",
1902 .data = &fs_overflowuid,
1903 .maxlen = sizeof(int),
1904 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001905 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 .extra1 = &minolduid,
1907 .extra2 = &maxolduid,
1908 },
1909 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001910 .procname = "overflowgid",
1911 .data = &fs_overflowgid,
1912 .maxlen = sizeof(int),
1913 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001914 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001915 .extra1 = &minolduid,
1916 .extra2 = &maxolduid,
1917 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001918#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 .procname = "leases-enable",
1921 .data = &leases_enable,
1922 .maxlen = sizeof(int),
1923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001924 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001926#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001927#ifdef CONFIG_DNOTIFY
1928 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929 .procname = "dir-notify-enable",
1930 .data = &dir_notify_enable,
1931 .maxlen = sizeof(int),
1932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001933 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934 },
1935#endif
1936#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001937#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939 .procname = "lease-break-time",
1940 .data = &lease_break_time,
1941 .maxlen = sizeof(int),
1942 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001943 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001945#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001946#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001948 .procname = "aio-nr",
1949 .data = &aio_nr,
1950 .maxlen = sizeof(aio_nr),
1951 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001952 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001953 },
1954 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001955 .procname = "aio-max-nr",
1956 .data = &aio_max_nr,
1957 .maxlen = sizeof(aio_max_nr),
1958 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001959 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001960 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001961#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001962#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001963 {
Robert Love0399cb02005-07-13 12:38:18 -04001964 .procname = "inotify",
1965 .mode = 0555,
1966 .child = inotify_table,
1967 },
1968#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001969#ifdef CONFIG_EPOLL
1970 {
1971 .procname = "epoll",
1972 .mode = 0555,
1973 .child = epoll_table,
1974 },
1975#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001977 {
Kees Cook800179c2012-07-25 17:29:07 -07001978 .procname = "protected_symlinks",
1979 .data = &sysctl_protected_symlinks,
1980 .maxlen = sizeof(int),
1981 .mode = 0600,
1982 .proc_handler = proc_dointvec_minmax,
1983 .extra1 = &zero,
1984 .extra2 = &one,
1985 },
1986 {
1987 .procname = "protected_hardlinks",
1988 .data = &sysctl_protected_hardlinks,
1989 .maxlen = sizeof(int),
1990 .mode = 0600,
1991 .proc_handler = proc_dointvec_minmax,
1992 .extra1 = &zero,
1993 .extra2 = &one,
1994 },
1995 {
Alan Coxd6e71142005-06-23 00:09:43 -07001996 .procname = "suid_dumpable",
1997 .data = &suid_dumpable,
1998 .maxlen = sizeof(int),
1999 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07002000 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07002001 .extra1 = &zero,
2002 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07002003 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002004#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
2005 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002006 .procname = "binfmt_misc",
2007 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05002008 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08002009 },
2010#endif
Jens Axboeb492e952010-05-19 21:03:16 +02002011 {
Jens Axboeff9da692010-06-03 14:54:39 +02002012 .procname = "pipe-max-size",
2013 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002014 .maxlen = sizeof(int),
2015 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02002016 .proc_handler = &pipe_proc_fn,
2017 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02002018 },
Willy Tarreau759c0112016-01-18 16:36:09 +01002019 {
2020 .procname = "pipe-user-pages-hard",
2021 .data = &pipe_user_pages_hard,
2022 .maxlen = sizeof(pipe_user_pages_hard),
2023 .mode = 0644,
2024 .proc_handler = proc_doulongvec_minmax,
2025 },
2026 {
2027 .procname = "pipe-user-pages-soft",
2028 .data = &pipe_user_pages_soft,
2029 .maxlen = sizeof(pipe_user_pages_soft),
2030 .mode = 0644,
2031 .proc_handler = proc_doulongvec_minmax,
2032 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05002033 {
2034 .procname = "mount-max",
2035 .data = &sysctl_mount_max,
2036 .maxlen = sizeof(unsigned int),
2037 .mode = 0644,
2038 .proc_handler = proc_dointvec_minmax,
2039 .extra1 = &one,
2040 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002041 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042};
2043
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002044static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07002045#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002046 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02002047 .procname = "exception-trace",
2048 .data = &show_unhandled_signals,
2049 .maxlen = sizeof(int),
2050 .mode = 0644,
2051 .proc_handler = proc_dointvec
2052 },
2053#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05002054#if defined(CONFIG_OPTPROBES)
2055 {
2056 .procname = "kprobes-optimization",
2057 .data = &sysctl_kprobes_optimization,
2058 .maxlen = sizeof(int),
2059 .mode = 0644,
2060 .proc_handler = proc_kprobes_optimization_handler,
2061 .extra1 = &zero,
2062 .extra2 = &one,
2063 },
2064#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002065 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066};
2067
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002068static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07002069 { }
Robert Love0eeca282005-07-12 17:06:03 -04002070};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08002072int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00002073{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07002074 struct ctl_table_header *hdr;
2075
2076 hdr = register_sysctl_table(sysctl_base_table);
2077 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08002078 return 0;
2079}
2080
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002081#endif /* CONFIG_SYSCTL */
2082
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083/*
2084 * /proc/sys support
2085 */
2086
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002087#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088
Kees Cookf8808302014-06-06 14:37:17 -07002089static int _proc_do_string(char *data, int maxlen, int write,
2090 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002091 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002092{
2093 size_t len;
2094 char __user *p;
2095 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002096
2097 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002098 *lenp = 0;
2099 return 0;
2100 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002101
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002102 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002103 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2104 /* Only continue writes not past the end of buffer. */
2105 len = strlen(data);
2106 if (len > maxlen - 1)
2107 len = maxlen - 1;
2108
2109 if (*ppos > len)
2110 return 0;
2111 len = *ppos;
2112 } else {
2113 /* Start writing from beginning of buffer. */
2114 len = 0;
2115 }
2116
Kees Cook2ca9bb42014-06-06 14:37:18 -07002117 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002118 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002119 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002120 if (get_user(c, p++))
2121 return -EFAULT;
2122 if (c == 0 || c == '\n')
2123 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002124 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002125 }
Kees Cookf8808302014-06-06 14:37:17 -07002126 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002127 } else {
2128 len = strlen(data);
2129 if (len > maxlen)
2130 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002131
2132 if (*ppos > len) {
2133 *lenp = 0;
2134 return 0;
2135 }
2136
2137 data += *ppos;
2138 len -= *ppos;
2139
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002140 if (len > *lenp)
2141 len = *lenp;
2142 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002143 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002144 return -EFAULT;
2145 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002146 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002147 return -EFAULT;
2148 len++;
2149 }
2150 *lenp = len;
2151 *ppos += len;
2152 }
2153 return 0;
2154}
2155
Kees Cookf4aacea2014-06-06 14:37:19 -07002156static void warn_sysctl_write(struct ctl_table *table)
2157{
2158 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2159 "This will not be supported in the future. To silence this\n"
2160 "warning, set kernel.sysctl_writes_strict = -1\n",
2161 current->comm, table->procname);
2162}
2163
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164/**
2165 * proc_dostring - read a string sysctl
2166 * @table: the sysctl table
2167 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002168 * @buffer: the user buffer
2169 * @lenp: the size of the user buffer
2170 * @ppos: file position
2171 *
2172 * Reads/writes a string from/to the user buffer. If the kernel
2173 * buffer provided is not large enough to hold the string, the
2174 * string is truncated. The copied string is %NULL-terminated.
2175 * If the string is being read by the user process, it is copied
2176 * and a newline '\n' is added. It is truncated if the buffer is
2177 * not large enough.
2178 *
2179 * Returns 0 on success.
2180 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002181int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 void __user *buffer, size_t *lenp, loff_t *ppos)
2183{
Kees Cookf4aacea2014-06-06 14:37:19 -07002184 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2185 warn_sysctl_write(table);
2186
Kees Cookf8808302014-06-06 14:37:17 -07002187 return _proc_do_string((char *)(table->data), table->maxlen, write,
2188 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189}
2190
Amerigo Wang00b7c332010-05-05 00:26:45 +00002191static size_t proc_skip_spaces(char **buf)
2192{
2193 size_t ret;
2194 char *tmp = skip_spaces(*buf);
2195 ret = tmp - *buf;
2196 *buf = tmp;
2197 return ret;
2198}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002200static void proc_skip_char(char **buf, size_t *size, const char v)
2201{
2202 while (*size) {
2203 if (**buf != v)
2204 break;
2205 (*size)--;
2206 (*buf)++;
2207 }
2208}
2209
Amerigo Wang00b7c332010-05-05 00:26:45 +00002210#define TMPBUFLEN 22
2211/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002212 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002213 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002214 * @buf: a kernel buffer
2215 * @size: size of the kernel buffer
2216 * @val: this is where the number will be stored
2217 * @neg: set to %TRUE if number is negative
2218 * @perm_tr: a vector which contains the allowed trailers
2219 * @perm_tr_len: size of the perm_tr vector
2220 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002221 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002222 * In case of success %0 is returned and @buf and @size are updated with
2223 * the amount of bytes read. If @tr is non-NULL and a trailing
2224 * character exists (size is non-zero after returning from this
2225 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002226 */
2227static int proc_get_long(char **buf, size_t *size,
2228 unsigned long *val, bool *neg,
2229 const char *perm_tr, unsigned perm_tr_len, char *tr)
2230{
2231 int len;
2232 char *p, tmp[TMPBUFLEN];
2233
2234 if (!*size)
2235 return -EINVAL;
2236
2237 len = *size;
2238 if (len > TMPBUFLEN - 1)
2239 len = TMPBUFLEN - 1;
2240
2241 memcpy(tmp, *buf, len);
2242
2243 tmp[len] = 0;
2244 p = tmp;
2245 if (*p == '-' && *size > 1) {
2246 *neg = true;
2247 p++;
2248 } else
2249 *neg = false;
2250 if (!isdigit(*p))
2251 return -EINVAL;
2252
2253 *val = simple_strtoul(p, &p, 0);
2254
2255 len = p - tmp;
2256
2257 /* We don't know if the next char is whitespace thus we may accept
2258 * invalid integers (e.g. 1234...a) or two integers instead of one
2259 * (e.g. 123...1). So lets not allow such large numbers. */
2260 if (len == TMPBUFLEN - 1)
2261 return -EINVAL;
2262
2263 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2264 return -EINVAL;
2265
2266 if (tr && (len < *size))
2267 *tr = *p;
2268
2269 *buf += len;
2270 *size -= len;
2271
2272 return 0;
2273}
2274
2275/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002276 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002277 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002278 * @buf: the user buffer
2279 * @size: the size of the user buffer
2280 * @val: the integer to be converted
2281 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002282 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002283 * In case of success %0 is returned and @buf and @size are updated with
2284 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002285 */
2286static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2287 bool neg)
2288{
2289 int len;
2290 char tmp[TMPBUFLEN], *p = tmp;
2291
2292 sprintf(p, "%s%lu", neg ? "-" : "", val);
2293 len = strlen(tmp);
2294 if (len > *size)
2295 len = *size;
2296 if (copy_to_user(*buf, tmp, len))
2297 return -EFAULT;
2298 *size -= len;
2299 *buf += len;
2300 return 0;
2301}
2302#undef TMPBUFLEN
2303
2304static int proc_put_char(void __user **buf, size_t *size, char c)
2305{
2306 if (*size) {
2307 char __user **buffer = (char __user **)buf;
2308 if (put_user(c, *buffer))
2309 return -EFAULT;
2310 (*size)--, (*buffer)++;
2311 *buf = *buffer;
2312 }
2313 return 0;
2314}
2315
2316static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317 int *valp,
2318 int write, void *data)
2319{
2320 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002321 if (*negp) {
2322 if (*lvalp > (unsigned long) INT_MAX + 1)
2323 return -EINVAL;
2324 *valp = -*lvalp;
2325 } else {
2326 if (*lvalp > (unsigned long) INT_MAX)
2327 return -EINVAL;
2328 *valp = *lvalp;
2329 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330 } else {
2331 int val = *valp;
2332 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002333 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002334 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002336 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 *lvalp = (unsigned long)val;
2338 }
2339 }
2340 return 0;
2341}
2342
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002343static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2344 int *valp,
2345 int write, void *data)
2346{
2347 if (write) {
2348 if (*negp)
2349 return -EINVAL;
2350 *valp = *lvalp;
2351 } else {
2352 unsigned int val = *valp;
2353 *lvalp = (unsigned long)val;
2354 }
2355 return 0;
2356}
2357
Amerigo Wang00b7c332010-05-05 00:26:45 +00002358static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2359
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002360static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002361 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002362 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002363 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364 int write, void *data),
2365 void *data)
2366{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002367 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002368 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002369 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370
Amerigo Wang00b7c332010-05-05 00:26:45 +00002371 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372 *lenp = 0;
2373 return 0;
2374 }
2375
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002376 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 vleft = table->maxlen / sizeof(*i);
2378 left = *lenp;
2379
2380 if (!conv)
2381 conv = do_proc_dointvec_conv;
2382
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002384 if (*ppos) {
2385 switch (sysctl_writes_strict) {
2386 case SYSCTL_WRITES_STRICT:
2387 goto out;
2388 case SYSCTL_WRITES_WARN:
2389 warn_sysctl_write(table);
2390 break;
2391 default:
2392 break;
2393 }
2394 }
2395
Amerigo Wang00b7c332010-05-05 00:26:45 +00002396 if (left > PAGE_SIZE - 1)
2397 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002398 p = kbuf = memdup_user_nul(buffer, left);
2399 if (IS_ERR(kbuf))
2400 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002401 }
2402
2403 for (; left && vleft--; i++, first=0) {
2404 unsigned long lval;
2405 bool neg;
2406
2407 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002408 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002409
J. R. Okajima563b0462010-05-25 16:10:14 -07002410 if (!left)
2411 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002412 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002413 proc_wspace_sep,
2414 sizeof(proc_wspace_sep), NULL);
2415 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002417 if (conv(&neg, &lval, i, 1, data)) {
2418 err = -EINVAL;
2419 break;
2420 }
2421 } else {
2422 if (conv(&neg, &lval, i, 0, data)) {
2423 err = -EINVAL;
2424 break;
2425 }
2426 if (!first)
2427 err = proc_put_char(&buffer, &left, '\t');
2428 if (err)
2429 break;
2430 err = proc_put_long(&buffer, &left, lval, neg);
2431 if (err)
2432 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 }
2434 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002435
2436 if (!write && !first && left && !err)
2437 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002438 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002439 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002440 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002441 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002442 if (first)
2443 return err ? : -EINVAL;
2444 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002446out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002448 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449}
2450
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002451static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002452 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002453 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002454 int write, void *data),
2455 void *data)
2456{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002457 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002458 buffer, lenp, ppos, conv, data);
2459}
2460
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461/**
2462 * proc_dointvec - read a vector of integers
2463 * @table: the sysctl table
2464 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002465 * @buffer: the user buffer
2466 * @lenp: the size of the user buffer
2467 * @ppos: file position
2468 *
2469 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2470 * values from/to the user buffer, treated as an ASCII string.
2471 *
2472 * Returns 0 on success.
2473 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002474int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475 void __user *buffer, size_t *lenp, loff_t *ppos)
2476{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002477 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2478}
2479
2480/**
2481 * proc_douintvec - read a vector of unsigned integers
2482 * @table: the sysctl table
2483 * @write: %TRUE if this is a write to the sysctl file
2484 * @buffer: the user buffer
2485 * @lenp: the size of the user buffer
2486 * @ppos: file position
2487 *
2488 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2489 * values from/to the user buffer, treated as an ASCII string.
2490 *
2491 * Returns 0 on success.
2492 */
2493int proc_douintvec(struct ctl_table *table, int write,
2494 void __user *buffer, size_t *lenp, loff_t *ppos)
2495{
2496 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2497 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498}
2499
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002500/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002501 * Taint values can only be increased
2502 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002503 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002504static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002505 void __user *buffer, size_t *lenp, loff_t *ppos)
2506{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002507 struct ctl_table t;
2508 unsigned long tmptaint = get_taint();
2509 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002510
Bastian Blank91fcd412007-04-23 14:41:14 -07002511 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002512 return -EPERM;
2513
Andi Kleen25ddbb12008-10-15 22:01:41 -07002514 t = *table;
2515 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002516 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002517 if (err < 0)
2518 return err;
2519
2520 if (write) {
2521 /*
2522 * Poor man's atomic or. Not worth adding a primitive
2523 * to everyone's atomic.h for this
2524 */
2525 int i;
2526 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2527 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302528 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002529 }
2530 }
2531
2532 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002533}
2534
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002535#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002536static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002537 void __user *buffer, size_t *lenp, loff_t *ppos)
2538{
2539 if (write && !capable(CAP_SYS_ADMIN))
2540 return -EPERM;
2541
2542 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2543}
2544#endif
2545
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546struct do_proc_dointvec_minmax_conv_param {
2547 int *min;
2548 int *max;
2549};
2550
Amerigo Wang00b7c332010-05-05 00:26:45 +00002551static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2552 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 int write, void *data)
2554{
2555 struct do_proc_dointvec_minmax_conv_param *param = data;
2556 if (write) {
2557 int val = *negp ? -*lvalp : *lvalp;
2558 if ((param->min && *param->min > val) ||
2559 (param->max && *param->max < val))
2560 return -EINVAL;
2561 *valp = val;
2562 } else {
2563 int val = *valp;
2564 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002565 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002566 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002568 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569 *lvalp = (unsigned long)val;
2570 }
2571 }
2572 return 0;
2573}
2574
2575/**
2576 * proc_dointvec_minmax - read a vector of integers with min/max values
2577 * @table: the sysctl table
2578 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579 * @buffer: the user buffer
2580 * @lenp: the size of the user buffer
2581 * @ppos: file position
2582 *
2583 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2584 * values from/to the user buffer, treated as an ASCII string.
2585 *
2586 * This routine will ensure the values are within the range specified by
2587 * table->extra1 (min) and table->extra2 (max).
2588 *
2589 * Returns 0 on success.
2590 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002591int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002592 void __user *buffer, size_t *lenp, loff_t *ppos)
2593{
2594 struct do_proc_dointvec_minmax_conv_param param = {
2595 .min = (int *) table->extra1,
2596 .max = (int *) table->extra2,
2597 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002598 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 do_proc_dointvec_minmax_conv, &param);
2600}
2601
Kees Cook54b50192012-07-30 14:39:18 -07002602static void validate_coredump_safety(void)
2603{
Alex Kelly046d6622012-10-04 17:15:23 -07002604#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002605 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002606 core_pattern[0] != '/' && core_pattern[0] != '|') {
2607 printk(KERN_WARNING "Unsafe core_pattern used with "\
2608 "suid_dumpable=2. Pipe handler or fully qualified "\
2609 "core dump path required.\n");
2610 }
Alex Kelly046d6622012-10-04 17:15:23 -07002611#endif
Kees Cook54b50192012-07-30 14:39:18 -07002612}
2613
2614static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2615 void __user *buffer, size_t *lenp, loff_t *ppos)
2616{
2617 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2618 if (!error)
2619 validate_coredump_safety();
2620 return error;
2621}
2622
Alex Kelly046d6622012-10-04 17:15:23 -07002623#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002624static int proc_dostring_coredump(struct ctl_table *table, int write,
2625 void __user *buffer, size_t *lenp, loff_t *ppos)
2626{
2627 int error = proc_dostring(table, write, buffer, lenp, ppos);
2628 if (!error)
2629 validate_coredump_safety();
2630 return error;
2631}
Alex Kelly046d6622012-10-04 17:15:23 -07002632#endif
Kees Cook54b50192012-07-30 14:39:18 -07002633
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002634static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 void __user *buffer,
2636 size_t *lenp, loff_t *ppos,
2637 unsigned long convmul,
2638 unsigned long convdiv)
2639{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002640 unsigned long *i, *min, *max;
2641 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002642 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002643 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002644
2645 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002646 *lenp = 0;
2647 return 0;
2648 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002649
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002650 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651 min = (unsigned long *) table->extra1;
2652 max = (unsigned long *) table->extra2;
2653 vleft = table->maxlen / sizeof(unsigned long);
2654 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002655
2656 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002657 if (*ppos) {
2658 switch (sysctl_writes_strict) {
2659 case SYSCTL_WRITES_STRICT:
2660 goto out;
2661 case SYSCTL_WRITES_WARN:
2662 warn_sysctl_write(table);
2663 break;
2664 default:
2665 break;
2666 }
2667 }
2668
Amerigo Wang00b7c332010-05-05 00:26:45 +00002669 if (left > PAGE_SIZE - 1)
2670 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002671 p = kbuf = memdup_user_nul(buffer, left);
2672 if (IS_ERR(kbuf))
2673 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002674 }
2675
Eric Dumazet27b3d802010-10-07 12:59:29 -07002676 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002677 unsigned long val;
2678
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002680 bool neg;
2681
Al Viro70f6cbb2015-12-24 00:13:10 -05002682 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002683
Al Viro70f6cbb2015-12-24 00:13:10 -05002684 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002685 proc_wspace_sep,
2686 sizeof(proc_wspace_sep), NULL);
2687 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002688 break;
2689 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690 continue;
2691 if ((min && val < *min) || (max && val > *max))
2692 continue;
2693 *i = val;
2694 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002695 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002696 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002697 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002698 if (err)
2699 break;
2700 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002701 err = proc_put_long(&buffer, &left, val, false);
2702 if (err)
2703 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002704 }
2705 }
2706
Amerigo Wang00b7c332010-05-05 00:26:45 +00002707 if (!write && !first && left && !err)
2708 err = proc_put_char(&buffer, &left, '\n');
2709 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002710 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002711 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002712 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002713 if (first)
2714 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002716 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002717out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002719 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002720}
2721
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002722static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002723 void __user *buffer,
2724 size_t *lenp, loff_t *ppos,
2725 unsigned long convmul,
2726 unsigned long convdiv)
2727{
2728 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002729 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002730}
2731
Linus Torvalds1da177e2005-04-16 15:20:36 -07002732/**
2733 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2734 * @table: the sysctl table
2735 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002736 * @buffer: the user buffer
2737 * @lenp: the size of the user buffer
2738 * @ppos: file position
2739 *
2740 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2741 * values from/to the user buffer, treated as an ASCII string.
2742 *
2743 * This routine will ensure the values are within the range specified by
2744 * table->extra1 (min) and table->extra2 (max).
2745 *
2746 * Returns 0 on success.
2747 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002748int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002749 void __user *buffer, size_t *lenp, loff_t *ppos)
2750{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002751 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002752}
2753
2754/**
2755 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2756 * @table: the sysctl table
2757 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002758 * @buffer: the user buffer
2759 * @lenp: the size of the user buffer
2760 * @ppos: file position
2761 *
2762 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2763 * values from/to the user buffer, treated as an ASCII string. The values
2764 * are treated as milliseconds, and converted to jiffies when they are stored.
2765 *
2766 * This routine will ensure the values are within the range specified by
2767 * table->extra1 (min) and table->extra2 (max).
2768 *
2769 * Returns 0 on success.
2770 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002771int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002772 void __user *buffer,
2773 size_t *lenp, loff_t *ppos)
2774{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002775 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002776 lenp, ppos, HZ, 1000l);
2777}
2778
2779
Amerigo Wang00b7c332010-05-05 00:26:45 +00002780static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002781 int *valp,
2782 int write, void *data)
2783{
2784 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002785 if (*lvalp > LONG_MAX / HZ)
2786 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002787 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2788 } else {
2789 int val = *valp;
2790 unsigned long lval;
2791 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002792 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002793 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002794 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002795 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002796 lval = (unsigned long)val;
2797 }
2798 *lvalp = lval / HZ;
2799 }
2800 return 0;
2801}
2802
Amerigo Wang00b7c332010-05-05 00:26:45 +00002803static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002804 int *valp,
2805 int write, void *data)
2806{
2807 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002808 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2809 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002810 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2811 } else {
2812 int val = *valp;
2813 unsigned long lval;
2814 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002815 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002816 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002817 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002818 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002819 lval = (unsigned long)val;
2820 }
2821 *lvalp = jiffies_to_clock_t(lval);
2822 }
2823 return 0;
2824}
2825
Amerigo Wang00b7c332010-05-05 00:26:45 +00002826static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002827 int *valp,
2828 int write, void *data)
2829{
2830 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002831 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2832
2833 if (jif > INT_MAX)
2834 return 1;
2835 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002836 } else {
2837 int val = *valp;
2838 unsigned long lval;
2839 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002840 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002841 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002842 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002843 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002844 lval = (unsigned long)val;
2845 }
2846 *lvalp = jiffies_to_msecs(lval);
2847 }
2848 return 0;
2849}
2850
2851/**
2852 * proc_dointvec_jiffies - read a vector of integers as seconds
2853 * @table: the sysctl table
2854 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002855 * @buffer: the user buffer
2856 * @lenp: the size of the user buffer
2857 * @ppos: file position
2858 *
2859 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2860 * values from/to the user buffer, treated as an ASCII string.
2861 * The values read are assumed to be in seconds, and are converted into
2862 * jiffies.
2863 *
2864 * Returns 0 on success.
2865 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002866int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002867 void __user *buffer, size_t *lenp, loff_t *ppos)
2868{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002869 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002870 do_proc_dointvec_jiffies_conv,NULL);
2871}
2872
2873/**
2874 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2875 * @table: the sysctl table
2876 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002877 * @buffer: the user buffer
2878 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002879 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002880 *
2881 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2882 * values from/to the user buffer, treated as an ASCII string.
2883 * The values read are assumed to be in 1/USER_HZ seconds, and
2884 * are converted into jiffies.
2885 *
2886 * Returns 0 on success.
2887 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002888int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002889 void __user *buffer, size_t *lenp, loff_t *ppos)
2890{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002891 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002892 do_proc_dointvec_userhz_jiffies_conv,NULL);
2893}
2894
2895/**
2896 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2897 * @table: the sysctl table
2898 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899 * @buffer: the user buffer
2900 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002901 * @ppos: file position
2902 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002903 *
2904 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2905 * values from/to the user buffer, treated as an ASCII string.
2906 * The values read are assumed to be in 1/1000 seconds, and
2907 * are converted into jiffies.
2908 *
2909 * Returns 0 on success.
2910 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002911int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002912 void __user *buffer, size_t *lenp, loff_t *ppos)
2913{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002914 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002915 do_proc_dointvec_ms_jiffies_conv, NULL);
2916}
2917
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002918static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002919 void __user *buffer, size_t *lenp, loff_t *ppos)
2920{
2921 struct pid *new_pid;
2922 pid_t tmp;
2923 int r;
2924
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002925 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002926
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002927 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002928 lenp, ppos, NULL, NULL);
2929 if (r || !write)
2930 return r;
2931
2932 new_pid = find_get_pid(tmp);
2933 if (!new_pid)
2934 return -ESRCH;
2935
2936 put_pid(xchg(&cad_pid, new_pid));
2937 return 0;
2938}
2939
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002940/**
2941 * proc_do_large_bitmap - read/write from/to a large bitmap
2942 * @table: the sysctl table
2943 * @write: %TRUE if this is a write to the sysctl file
2944 * @buffer: the user buffer
2945 * @lenp: the size of the user buffer
2946 * @ppos: file position
2947 *
2948 * The bitmap is stored at table->data and the bitmap length (in bits)
2949 * in table->maxlen.
2950 *
2951 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2952 * large bitmaps may be represented in a compact manner. Writing into
2953 * the file will clear the bitmap then update it with the given input.
2954 *
2955 * Returns 0 on success.
2956 */
2957int proc_do_large_bitmap(struct ctl_table *table, int write,
2958 void __user *buffer, size_t *lenp, loff_t *ppos)
2959{
2960 int err = 0;
2961 bool first = 1;
2962 size_t left = *lenp;
2963 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002964 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002965 unsigned long *tmp_bitmap = NULL;
2966 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2967
WANG Cong122ff242014-05-12 16:04:53 -07002968 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002969 *lenp = 0;
2970 return 0;
2971 }
2972
2973 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002974 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002975
2976 if (left > PAGE_SIZE - 1)
2977 left = PAGE_SIZE - 1;
2978
Al Viro70f6cbb2015-12-24 00:13:10 -05002979 p = kbuf = memdup_user_nul(buffer, left);
2980 if (IS_ERR(kbuf))
2981 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002982
2983 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2984 GFP_KERNEL);
2985 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002986 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002987 return -ENOMEM;
2988 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002989 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002990 while (!err && left) {
2991 unsigned long val_a, val_b;
2992 bool neg;
2993
Al Viro70f6cbb2015-12-24 00:13:10 -05002994 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002995 sizeof(tr_a), &c);
2996 if (err)
2997 break;
2998 if (val_a >= bitmap_len || neg) {
2999 err = -EINVAL;
3000 break;
3001 }
3002
3003 val_b = val_a;
3004 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003005 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003006 left--;
3007 }
3008
3009 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05003010 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003011 &neg, tr_b, sizeof(tr_b),
3012 &c);
3013 if (err)
3014 break;
3015 if (val_b >= bitmap_len || neg ||
3016 val_a > val_b) {
3017 err = -EINVAL;
3018 break;
3019 }
3020 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003021 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003022 left--;
3023 }
3024 }
3025
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003026 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003027 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003028 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003029 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003030 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003031 } else {
3032 unsigned long bit_a, bit_b = 0;
3033
3034 while (left) {
3035 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3036 if (bit_a >= bitmap_len)
3037 break;
3038 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3039 bit_a + 1) - 1;
3040
3041 if (!first) {
3042 err = proc_put_char(&buffer, &left, ',');
3043 if (err)
3044 break;
3045 }
3046 err = proc_put_long(&buffer, &left, bit_a, false);
3047 if (err)
3048 break;
3049 if (bit_a != bit_b) {
3050 err = proc_put_char(&buffer, &left, '-');
3051 if (err)
3052 break;
3053 err = proc_put_long(&buffer, &left, bit_b, false);
3054 if (err)
3055 break;
3056 }
3057
3058 first = 0; bit_b++;
3059 }
3060 if (!err)
3061 err = proc_put_char(&buffer, &left, '\n');
3062 }
3063
3064 if (!err) {
3065 if (write) {
3066 if (*ppos)
3067 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3068 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003069 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003070 }
3071 kfree(tmp_bitmap);
3072 *lenp -= left;
3073 *ppos += *lenp;
3074 return 0;
3075 } else {
3076 kfree(tmp_bitmap);
3077 return err;
3078 }
3079}
3080
Jovi Zhang55610502011-01-12 17:00:45 -08003081#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003082
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003083int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003084 void __user *buffer, size_t *lenp, loff_t *ppos)
3085{
3086 return -ENOSYS;
3087}
3088
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003089int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090 void __user *buffer, size_t *lenp, loff_t *ppos)
3091{
3092 return -ENOSYS;
3093}
3094
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003095int proc_douintvec(struct ctl_table *table, int write,
3096 void __user *buffer, size_t *lenp, loff_t *ppos)
3097{
3098 return -ENOSYS;
3099}
3100
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003101int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003102 void __user *buffer, size_t *lenp, loff_t *ppos)
3103{
3104 return -ENOSYS;
3105}
3106
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003107int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003108 void __user *buffer, size_t *lenp, loff_t *ppos)
3109{
3110 return -ENOSYS;
3111}
3112
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003113int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003114 void __user *buffer, size_t *lenp, loff_t *ppos)
3115{
3116 return -ENOSYS;
3117}
3118
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003119int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003120 void __user *buffer, size_t *lenp, loff_t *ppos)
3121{
3122 return -ENOSYS;
3123}
3124
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003125int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003126 void __user *buffer, size_t *lenp, loff_t *ppos)
3127{
3128 return -ENOSYS;
3129}
3130
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003131int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003132 void __user *buffer,
3133 size_t *lenp, loff_t *ppos)
3134{
3135 return -ENOSYS;
3136}
3137
3138
Jovi Zhang55610502011-01-12 17:00:45 -08003139#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003140
Linus Torvalds1da177e2005-04-16 15:20:36 -07003141/*
3142 * No sense putting this after each symbol definition, twice,
3143 * exception granted :-)
3144 */
3145EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003146EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003147EXPORT_SYMBOL(proc_dointvec_jiffies);
3148EXPORT_SYMBOL(proc_dointvec_minmax);
3149EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3150EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3151EXPORT_SYMBOL(proc_dostring);
3152EXPORT_SYMBOL(proc_doulongvec_minmax);
3153EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);