1457c8996SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * sysctl.c: General linux system control interface 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Begun 24 March 1995, Stephen Tweedie 61da177e4SLinus Torvalds * Added /proc support, Dec 1995 71da177e4SLinus Torvalds * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. 81da177e4SLinus Torvalds * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. 91da177e4SLinus Torvalds * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. 101da177e4SLinus Torvalds * Dynamic registration fixes, Stephen Tweedie. 111da177e4SLinus Torvalds * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. 121da177e4SLinus Torvalds * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris 131da177e4SLinus Torvalds * Horn. 141da177e4SLinus Torvalds * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. 151da177e4SLinus Torvalds * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. 161da177e4SLinus Torvalds * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill 171da177e4SLinus Torvalds * Wendling. 181da177e4SLinus Torvalds * The list_for_each() macro wasn't appropriate for the sysctl loop. 191da177e4SLinus Torvalds * Removed it and replaced it with older style, 03/23/00, Bill Wendling 201da177e4SLinus Torvalds */ 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds #include <linux/module.h> 23e2e40f2cSChristoph Hellwig #include <linux/aio.h> 241da177e4SLinus Torvalds #include <linux/mm.h> 251da177e4SLinus Torvalds #include <linux/swap.h> 261da177e4SLinus Torvalds #include <linux/slab.h> 271da177e4SLinus Torvalds #include <linux/sysctl.h> 285a04cca6SAkinobu Mita #include <linux/bitmap.h> 29d33ed52dSDave Young #include <linux/signal.h> 30f39650deSAndy Shevchenko #include <linux/panic.h> 31455cd5abSDan Rosenberg #include <linux/printk.h> 321da177e4SLinus Torvalds #include <linux/proc_fs.h> 3372c2d582SAndrew Morgan #include <linux/security.h> 341da177e4SLinus Torvalds #include <linux/ctype.h> 35fd4b616bSSteven Rostedt #include <linux/kmemleak.h> 3662239ac2SAdrian Bunk #include <linux/fs.h> 371da177e4SLinus Torvalds #include <linux/init.h> 381da177e4SLinus Torvalds #include <linux/kernel.h> 390296b228SKay Sievers #include <linux/kobject.h> 4020380731SArnaldo Carvalho de Melo #include <linux/net.h> 411da177e4SLinus Torvalds #include <linux/sysrq.h> 421da177e4SLinus Torvalds #include <linux/highuid.h> 431da177e4SLinus Torvalds #include <linux/writeback.h> 443fff4c42SIngo Molnar #include <linux/ratelimit.h> 4576ab0f53SMel Gorman #include <linux/compaction.h> 461da177e4SLinus Torvalds #include <linux/hugetlb.h> 471da177e4SLinus Torvalds #include <linux/initrd.h> 480b77f5bfSDavid Howells #include <linux/key.h> 491da177e4SLinus Torvalds #include <linux/times.h> 501da177e4SLinus Torvalds #include <linux/limits.h> 511da177e4SLinus Torvalds #include <linux/dcache.h> 526e006701SAlexey Dobriyan #include <linux/dnotify.h> 531da177e4SLinus Torvalds #include <linux/syscalls.h> 54c748e134SAdrian Bunk #include <linux/vmstat.h> 55c255d844SPavel Machek #include <linux/nfs_fs.h> 56c255d844SPavel Machek #include <linux/acpi.h> 5710a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 58b0fc494fSSteven Rostedt #include <linux/ftrace.h> 59cdd6c482SIngo Molnar #include <linux/perf_event.h> 60b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 61b492e95bSJens Axboe #include <linux/pipe_fs_i.h> 628e4228e1SDavid Rientjes #include <linux/oom.h> 6317f60a7dSEric Paris #include <linux/kmod.h> 6473efc039SDan Ballard #include <linux/capability.h> 6540401530SAl Viro #include <linux/binfmts.h> 66cf4aebc2SClark Williams #include <linux/sched/sysctl.h> 67f7ccbae4SIngo Molnar #include <linux/sched/coredump.h> 687984754bSKees Cook #include <linux/kexec.h> 691be7f75dSAlexei Starovoitov #include <linux/bpf.h> 70d2921684SEric W. Biederman #include <linux/mount.h> 71cefdca0aSPeter Xu #include <linux/userfaultfd_k.h> 722374c09bSChristoph Hellwig #include <linux/coredump.h> 732374c09bSChristoph Hellwig #include <linux/latencytop.h> 742374c09bSChristoph Hellwig #include <linux/pid.h> 750cd7c741SPeter Zijlstra #include <linux/delayacct.h> 761da177e4SLinus Torvalds 777f2923c4SChristian Brauner #include "../lib/kstrtox.h" 787f2923c4SChristian Brauner 797c0f6ba6SLinus Torvalds #include <linux/uaccess.h> 801da177e4SLinus Torvalds #include <asm/processor.h> 811da177e4SLinus Torvalds 8229cbc78bSAndi Kleen #ifdef CONFIG_X86 8329cbc78bSAndi Kleen #include <asm/nmi.h> 840741f4d2SChuck Ebbert #include <asm/stacktrace.h> 856e7c4025SIngo Molnar #include <asm/io.h> 8629cbc78bSAndi Kleen #endif 87d550bbd4SDavid Howells #ifdef CONFIG_SPARC 88d550bbd4SDavid Howells #include <asm/setup.h> 89d550bbd4SDavid Howells #endif 90c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 91c55b7c3eSDave Young #include <linux/acct.h> 92c55b7c3eSDave Young #endif 934f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 944f0e056fSDave Young #include <linux/rtmutex.h> 954f0e056fSDave Young #endif 962edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 972edf5e49SDave Young #include <linux/lockdep.h> 982edf5e49SDave Young #endif 9915485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 10015485a46SDave Young #include <scsi/sg.h> 10115485a46SDave Young #endif 102964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 103964c9dffSAlexander Popov #include <linux/stackleak.h> 104964c9dffSAlexander Popov #endif 10558687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 106504d7cf1SDon Zickus #include <linux/nmi.h> 107504d7cf1SDon Zickus #endif 108504d7cf1SDon Zickus 1091da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 1101da177e4SLinus Torvalds 111c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1122508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 113c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 114c4f3b63fSRavikiran G Thirumalai #endif 115c4f3b63fSRavikiran G Thirumalai 116270750dbSAaron Tomlin static int __maybe_unused neg_one = -1; 117cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 1185509a5d2SDave Hansen static int __maybe_unused four = 4; 1199002b214SWill Deacon static unsigned long zero_ul; 120fc3501d4SSven Wegener static unsigned long one_ul = 1; 12132a5ad9cSChristian Brauner static unsigned long long_max = LONG_MAX; 122c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 123c843966cSJohannes Weiner static int two_hundred = 200; 124795ae7a0SJohannes Weiner static int one_thousand = 1000; 125af91322eSDave Young #ifdef CONFIG_PRINTK 126af91322eSDave Young static int ten_thousand = 10000; 127af91322eSDave Young #endif 128c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS 129c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024; 130c5dfd78eSArnaldo Carvalho de Melo #endif 131c4f3b63fSRavikiran G Thirumalai 1329e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1339e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1349e4a5bdaSAndrea Righi 1351da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1361da177e4SLinus Torvalds static int maxolduid = 65535; 1371da177e4SLinus Torvalds static int minolduid; 1381da177e4SLinus Torvalds 1391da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 14073efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP; 1411da177e4SLinus Torvalds 142a2e51445SDmitry Vyukov /* 143a2e51445SDmitry Vyukov * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs 144a2e51445SDmitry Vyukov * and hung_task_check_interval_secs 145a2e51445SDmitry Vyukov */ 14680df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK 14780df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); 14880df2847SLiu Hua #endif 14980df2847SLiu Hua 150d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 151d14f1729SDave Young #include <linux/inotify.h> 152d14f1729SDave Young #endif 1535b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY 1545b8fea65SAmir Goldstein #include <linux/fanotify.h> 1555b8fea65SAmir Goldstein #endif 156b6fca725SVineet Gupta 157d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 158f4aacea2SKees Cook 159a19ac337SLuis R. Rodriguez /** 160a19ac337SLuis R. Rodriguez * enum sysctl_writes_mode - supported sysctl write modes 161a19ac337SLuis R. Rodriguez * 162a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value 163a19ac337SLuis R. Rodriguez * to be written, and multiple writes on the same sysctl file descriptor 164a19ac337SLuis R. Rodriguez * will rewrite the sysctl value, regardless of file position. No warning 165a19ac337SLuis R. Rodriguez * is issued when the initial position is not 0. 166a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is 167a19ac337SLuis R. Rodriguez * not 0. 168a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at 169a19ac337SLuis R. Rodriguez * file position 0 and the value must be fully contained in the buffer 170a19ac337SLuis R. Rodriguez * sent to the write syscall. If dealing with strings respect the file 171a19ac337SLuis R. Rodriguez * position, but restrict this to the max length of the buffer, anything 17265f50f25SWeitao Hou * passed the max length will be ignored. Multiple writes will append 173a19ac337SLuis R. Rodriguez * to the buffer. 174a19ac337SLuis R. Rodriguez * 175a19ac337SLuis R. Rodriguez * These write modes control how current file position affects the behavior of 176a19ac337SLuis R. Rodriguez * updating sysctl values through the proc interface on each write. 177a19ac337SLuis R. Rodriguez */ 178a19ac337SLuis R. Rodriguez enum sysctl_writes_mode { 179a19ac337SLuis R. Rodriguez SYSCTL_WRITES_LEGACY = -1, 180a19ac337SLuis R. Rodriguez SYSCTL_WRITES_WARN = 0, 181a19ac337SLuis R. Rodriguez SYSCTL_WRITES_STRICT = 1, 182a19ac337SLuis R. Rodriguez }; 183f4aacea2SKees Cook 184a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; 185f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 186ceb18132SLuis R. Rodriguez 18767f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 18867f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 1891da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1901da177e4SLinus Torvalds #endif 1911da177e4SLinus Torvalds 1925e771905SMel Gorman #ifdef CONFIG_COMPACTION 1935e771905SMel Gorman static int min_extfrag_threshold; 1945e771905SMel Gorman static int max_extfrag_threshold = 1000; 1955e771905SMel Gorman #endif 1965e771905SMel Gorman 197f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */ 198f461d2dcSChristoph Hellwig 1995447e8e0SArnd Bergmann #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL) 200d46edd67SSong Liu static int bpf_stats_handler(struct ctl_table *table, int write, 2017787b6fcSTobias Klauser void *buffer, size_t *lenp, loff_t *ppos) 202d46edd67SSong Liu { 203d46edd67SSong Liu struct static_key *key = (struct static_key *)table->data; 204d46edd67SSong Liu static int saved_val; 205d46edd67SSong Liu int val, ret; 206d46edd67SSong Liu struct ctl_table tmp = { 207d46edd67SSong Liu .data = &val, 208d46edd67SSong Liu .maxlen = sizeof(val), 209d46edd67SSong Liu .mode = table->mode, 210d46edd67SSong Liu .extra1 = SYSCTL_ZERO, 211d46edd67SSong Liu .extra2 = SYSCTL_ONE, 212d46edd67SSong Liu }; 213d46edd67SSong Liu 214d46edd67SSong Liu if (write && !capable(CAP_SYS_ADMIN)) 215d46edd67SSong Liu return -EPERM; 216d46edd67SSong Liu 217d46edd67SSong Liu mutex_lock(&bpf_stats_enabled_mutex); 218d46edd67SSong Liu val = saved_val; 219d46edd67SSong Liu ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 220d46edd67SSong Liu if (write && !ret && val != saved_val) { 221d46edd67SSong Liu if (val) 222d46edd67SSong Liu static_key_slow_inc(key); 223d46edd67SSong Liu else 224d46edd67SSong Liu static_key_slow_dec(key); 225d46edd67SSong Liu saved_val = val; 226d46edd67SSong Liu } 227d46edd67SSong Liu mutex_unlock(&bpf_stats_enabled_mutex); 228d46edd67SSong Liu return ret; 229d46edd67SSong Liu } 23008389d88SDaniel Borkmann 23108389d88SDaniel Borkmann static int bpf_unpriv_handler(struct ctl_table *table, int write, 23208389d88SDaniel Borkmann void *buffer, size_t *lenp, loff_t *ppos) 23308389d88SDaniel Borkmann { 23408389d88SDaniel Borkmann int ret, unpriv_enable = *(int *)table->data; 23508389d88SDaniel Borkmann bool locked_state = unpriv_enable == 1; 23608389d88SDaniel Borkmann struct ctl_table tmp = *table; 23708389d88SDaniel Borkmann 23808389d88SDaniel Borkmann if (write && !capable(CAP_SYS_ADMIN)) 23908389d88SDaniel Borkmann return -EPERM; 24008389d88SDaniel Borkmann 24108389d88SDaniel Borkmann tmp.data = &unpriv_enable; 24208389d88SDaniel Borkmann ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 24308389d88SDaniel Borkmann if (write && !ret) { 24408389d88SDaniel Borkmann if (locked_state && unpriv_enable != 1) 24508389d88SDaniel Borkmann return -EPERM; 24608389d88SDaniel Borkmann *(int *)table->data = unpriv_enable; 24708389d88SDaniel Borkmann } 24808389d88SDaniel Borkmann return ret; 24908389d88SDaniel Borkmann } 25008389d88SDaniel Borkmann #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */ 251d46edd67SSong Liu 252f461d2dcSChristoph Hellwig /* 253f461d2dcSChristoph Hellwig * /proc/sys support 254f461d2dcSChristoph Hellwig */ 255f461d2dcSChristoph Hellwig 256f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL 257f461d2dcSChristoph Hellwig 258f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write, 25932927393SChristoph Hellwig char *buffer, size_t *lenp, loff_t *ppos) 260f461d2dcSChristoph Hellwig { 261f461d2dcSChristoph Hellwig size_t len; 26232927393SChristoph Hellwig char c, *p; 263f461d2dcSChristoph Hellwig 264f461d2dcSChristoph Hellwig if (!data || !maxlen || !*lenp) { 265f461d2dcSChristoph Hellwig *lenp = 0; 266f461d2dcSChristoph Hellwig return 0; 267f461d2dcSChristoph Hellwig } 268f461d2dcSChristoph Hellwig 269f461d2dcSChristoph Hellwig if (write) { 270f461d2dcSChristoph Hellwig if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { 271f461d2dcSChristoph Hellwig /* Only continue writes not past the end of buffer. */ 272f461d2dcSChristoph Hellwig len = strlen(data); 273f461d2dcSChristoph Hellwig if (len > maxlen - 1) 274f461d2dcSChristoph Hellwig len = maxlen - 1; 275f461d2dcSChristoph Hellwig 276f461d2dcSChristoph Hellwig if (*ppos > len) 277f461d2dcSChristoph Hellwig return 0; 278f461d2dcSChristoph Hellwig len = *ppos; 279f461d2dcSChristoph Hellwig } else { 280f461d2dcSChristoph Hellwig /* Start writing from beginning of buffer. */ 281f461d2dcSChristoph Hellwig len = 0; 282f461d2dcSChristoph Hellwig } 283f461d2dcSChristoph Hellwig 284f461d2dcSChristoph Hellwig *ppos += *lenp; 285f461d2dcSChristoph Hellwig p = buffer; 286f461d2dcSChristoph Hellwig while ((p - buffer) < *lenp && len < maxlen - 1) { 28732927393SChristoph Hellwig c = *(p++); 288f461d2dcSChristoph Hellwig if (c == 0 || c == '\n') 289f461d2dcSChristoph Hellwig break; 290f461d2dcSChristoph Hellwig data[len++] = c; 291f461d2dcSChristoph Hellwig } 292f461d2dcSChristoph Hellwig data[len] = 0; 293f461d2dcSChristoph Hellwig } else { 294f461d2dcSChristoph Hellwig len = strlen(data); 295f461d2dcSChristoph Hellwig if (len > maxlen) 296f461d2dcSChristoph Hellwig len = maxlen; 297f461d2dcSChristoph Hellwig 298f461d2dcSChristoph Hellwig if (*ppos > len) { 299f461d2dcSChristoph Hellwig *lenp = 0; 300f461d2dcSChristoph Hellwig return 0; 301f461d2dcSChristoph Hellwig } 302f461d2dcSChristoph Hellwig 303f461d2dcSChristoph Hellwig data += *ppos; 304f461d2dcSChristoph Hellwig len -= *ppos; 305f461d2dcSChristoph Hellwig 306f461d2dcSChristoph Hellwig if (len > *lenp) 307f461d2dcSChristoph Hellwig len = *lenp; 308f461d2dcSChristoph Hellwig if (len) 30932927393SChristoph Hellwig memcpy(buffer, data, len); 310f461d2dcSChristoph Hellwig if (len < *lenp) { 31132927393SChristoph Hellwig buffer[len] = '\n'; 312f461d2dcSChristoph Hellwig len++; 313f461d2dcSChristoph Hellwig } 314f461d2dcSChristoph Hellwig *lenp = len; 315f461d2dcSChristoph Hellwig *ppos += len; 316f461d2dcSChristoph Hellwig } 317f461d2dcSChristoph Hellwig return 0; 318f461d2dcSChristoph Hellwig } 319f461d2dcSChristoph Hellwig 320f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table) 321f461d2dcSChristoph Hellwig { 322f461d2dcSChristoph Hellwig pr_warn_once("%s wrote to %s when file position was not 0!\n" 323f461d2dcSChristoph Hellwig "This will not be supported in the future. To silence this\n" 324f461d2dcSChristoph Hellwig "warning, set kernel.sysctl_writes_strict = -1\n", 325f461d2dcSChristoph Hellwig current->comm, table->procname); 326f461d2dcSChristoph Hellwig } 327f461d2dcSChristoph Hellwig 328f461d2dcSChristoph Hellwig /** 329f461d2dcSChristoph Hellwig * proc_first_pos_non_zero_ignore - check if first position is allowed 330f461d2dcSChristoph Hellwig * @ppos: file position 331f461d2dcSChristoph Hellwig * @table: the sysctl table 332f461d2dcSChristoph Hellwig * 333f461d2dcSChristoph Hellwig * Returns true if the first position is non-zero and the sysctl_writes_strict 334f461d2dcSChristoph Hellwig * mode indicates this is not allowed for numeric input types. String proc 335f461d2dcSChristoph Hellwig * handlers can ignore the return value. 336f461d2dcSChristoph Hellwig */ 337f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos, 338f461d2dcSChristoph Hellwig struct ctl_table *table) 339f461d2dcSChristoph Hellwig { 340f461d2dcSChristoph Hellwig if (!*ppos) 341f461d2dcSChristoph Hellwig return false; 342f461d2dcSChristoph Hellwig 343f461d2dcSChristoph Hellwig switch (sysctl_writes_strict) { 344f461d2dcSChristoph Hellwig case SYSCTL_WRITES_STRICT: 345f461d2dcSChristoph Hellwig return true; 346f461d2dcSChristoph Hellwig case SYSCTL_WRITES_WARN: 347f461d2dcSChristoph Hellwig warn_sysctl_write(table); 348f461d2dcSChristoph Hellwig return false; 349f461d2dcSChristoph Hellwig default: 350f461d2dcSChristoph Hellwig return false; 351f461d2dcSChristoph Hellwig } 352f461d2dcSChristoph Hellwig } 353f461d2dcSChristoph Hellwig 354f461d2dcSChristoph Hellwig /** 355f461d2dcSChristoph Hellwig * proc_dostring - read a string sysctl 356f461d2dcSChristoph Hellwig * @table: the sysctl table 357f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 358f461d2dcSChristoph Hellwig * @buffer: the user buffer 359f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 360f461d2dcSChristoph Hellwig * @ppos: file position 361f461d2dcSChristoph Hellwig * 362f461d2dcSChristoph Hellwig * Reads/writes a string from/to the user buffer. If the kernel 363f461d2dcSChristoph Hellwig * buffer provided is not large enough to hold the string, the 364f461d2dcSChristoph Hellwig * string is truncated. The copied string is %NULL-terminated. 365f461d2dcSChristoph Hellwig * If the string is being read by the user process, it is copied 366f461d2dcSChristoph Hellwig * and a newline '\n' is added. It is truncated if the buffer is 367f461d2dcSChristoph Hellwig * not large enough. 368f461d2dcSChristoph Hellwig * 369f461d2dcSChristoph Hellwig * Returns 0 on success. 370f461d2dcSChristoph Hellwig */ 371f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 37232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 373f461d2dcSChristoph Hellwig { 374f461d2dcSChristoph Hellwig if (write) 375f461d2dcSChristoph Hellwig proc_first_pos_non_zero_ignore(ppos, table); 376f461d2dcSChristoph Hellwig 37732927393SChristoph Hellwig return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, 37832927393SChristoph Hellwig ppos); 379f461d2dcSChristoph Hellwig } 380f461d2dcSChristoph Hellwig 381f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf) 382f461d2dcSChristoph Hellwig { 383f461d2dcSChristoph Hellwig size_t ret; 384f461d2dcSChristoph Hellwig char *tmp = skip_spaces(*buf); 385f461d2dcSChristoph Hellwig ret = tmp - *buf; 386f461d2dcSChristoph Hellwig *buf = tmp; 387f461d2dcSChristoph Hellwig return ret; 388f461d2dcSChristoph Hellwig } 389f461d2dcSChristoph Hellwig 390f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v) 391f461d2dcSChristoph Hellwig { 392f461d2dcSChristoph Hellwig while (*size) { 393f461d2dcSChristoph Hellwig if (**buf != v) 394f461d2dcSChristoph Hellwig break; 395f461d2dcSChristoph Hellwig (*size)--; 396f461d2dcSChristoph Hellwig (*buf)++; 397f461d2dcSChristoph Hellwig } 398f461d2dcSChristoph Hellwig } 399f461d2dcSChristoph Hellwig 400f461d2dcSChristoph Hellwig /** 401f461d2dcSChristoph Hellwig * strtoul_lenient - parse an ASCII formatted integer from a buffer and only 402f461d2dcSChristoph Hellwig * fail on overflow 403f461d2dcSChristoph Hellwig * 404f461d2dcSChristoph Hellwig * @cp: kernel buffer containing the string to parse 405f461d2dcSChristoph Hellwig * @endp: pointer to store the trailing characters 406f461d2dcSChristoph Hellwig * @base: the base to use 407f461d2dcSChristoph Hellwig * @res: where the parsed integer will be stored 408f461d2dcSChristoph Hellwig * 409f461d2dcSChristoph Hellwig * In case of success 0 is returned and @res will contain the parsed integer, 410f461d2dcSChristoph Hellwig * @endp will hold any trailing characters. 411f461d2dcSChristoph Hellwig * This function will fail the parse on overflow. If there wasn't an overflow 412f461d2dcSChristoph Hellwig * the function will defer the decision what characters count as invalid to the 413f461d2dcSChristoph Hellwig * caller. 414f461d2dcSChristoph Hellwig */ 415f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base, 416f461d2dcSChristoph Hellwig unsigned long *res) 417f461d2dcSChristoph Hellwig { 418f461d2dcSChristoph Hellwig unsigned long long result; 419f461d2dcSChristoph Hellwig unsigned int rv; 420f461d2dcSChristoph Hellwig 421f461d2dcSChristoph Hellwig cp = _parse_integer_fixup_radix(cp, &base); 422f461d2dcSChristoph Hellwig rv = _parse_integer(cp, base, &result); 423f461d2dcSChristoph Hellwig if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) 424f461d2dcSChristoph Hellwig return -ERANGE; 425f461d2dcSChristoph Hellwig 426f461d2dcSChristoph Hellwig cp += rv; 427f461d2dcSChristoph Hellwig 428f461d2dcSChristoph Hellwig if (endp) 429f461d2dcSChristoph Hellwig *endp = (char *)cp; 430f461d2dcSChristoph Hellwig 431f461d2dcSChristoph Hellwig *res = (unsigned long)result; 432f461d2dcSChristoph Hellwig return 0; 433f461d2dcSChristoph Hellwig } 434f461d2dcSChristoph Hellwig 435f461d2dcSChristoph Hellwig #define TMPBUFLEN 22 436f461d2dcSChristoph Hellwig /** 437f461d2dcSChristoph Hellwig * proc_get_long - reads an ASCII formatted integer from a user buffer 438f461d2dcSChristoph Hellwig * 439f461d2dcSChristoph Hellwig * @buf: a kernel buffer 440f461d2dcSChristoph Hellwig * @size: size of the kernel buffer 441f461d2dcSChristoph Hellwig * @val: this is where the number will be stored 442f461d2dcSChristoph Hellwig * @neg: set to %TRUE if number is negative 443f461d2dcSChristoph Hellwig * @perm_tr: a vector which contains the allowed trailers 444f461d2dcSChristoph Hellwig * @perm_tr_len: size of the perm_tr vector 445f461d2dcSChristoph Hellwig * @tr: pointer to store the trailer character 446f461d2dcSChristoph Hellwig * 447f461d2dcSChristoph Hellwig * In case of success %0 is returned and @buf and @size are updated with 448f461d2dcSChristoph Hellwig * the amount of bytes read. If @tr is non-NULL and a trailing 449f461d2dcSChristoph Hellwig * character exists (size is non-zero after returning from this 450f461d2dcSChristoph Hellwig * function), @tr is updated with the trailing character. 451f461d2dcSChristoph Hellwig */ 452f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size, 453f461d2dcSChristoph Hellwig unsigned long *val, bool *neg, 454f461d2dcSChristoph Hellwig const char *perm_tr, unsigned perm_tr_len, char *tr) 455f461d2dcSChristoph Hellwig { 456f461d2dcSChristoph Hellwig int len; 457f461d2dcSChristoph Hellwig char *p, tmp[TMPBUFLEN]; 458f461d2dcSChristoph Hellwig 459f461d2dcSChristoph Hellwig if (!*size) 460f461d2dcSChristoph Hellwig return -EINVAL; 461f461d2dcSChristoph Hellwig 462f461d2dcSChristoph Hellwig len = *size; 463f461d2dcSChristoph Hellwig if (len > TMPBUFLEN - 1) 464f461d2dcSChristoph Hellwig len = TMPBUFLEN - 1; 465f461d2dcSChristoph Hellwig 466f461d2dcSChristoph Hellwig memcpy(tmp, *buf, len); 467f461d2dcSChristoph Hellwig 468f461d2dcSChristoph Hellwig tmp[len] = 0; 469f461d2dcSChristoph Hellwig p = tmp; 470f461d2dcSChristoph Hellwig if (*p == '-' && *size > 1) { 471f461d2dcSChristoph Hellwig *neg = true; 472f461d2dcSChristoph Hellwig p++; 473f461d2dcSChristoph Hellwig } else 474f461d2dcSChristoph Hellwig *neg = false; 475f461d2dcSChristoph Hellwig if (!isdigit(*p)) 476f461d2dcSChristoph Hellwig return -EINVAL; 477f461d2dcSChristoph Hellwig 478f461d2dcSChristoph Hellwig if (strtoul_lenient(p, &p, 0, val)) 479f461d2dcSChristoph Hellwig return -EINVAL; 480f461d2dcSChristoph Hellwig 481f461d2dcSChristoph Hellwig len = p - tmp; 482f461d2dcSChristoph Hellwig 483f461d2dcSChristoph Hellwig /* We don't know if the next char is whitespace thus we may accept 484f461d2dcSChristoph Hellwig * invalid integers (e.g. 1234...a) or two integers instead of one 485f461d2dcSChristoph Hellwig * (e.g. 123...1). So lets not allow such large numbers. */ 486f461d2dcSChristoph Hellwig if (len == TMPBUFLEN - 1) 487f461d2dcSChristoph Hellwig return -EINVAL; 488f461d2dcSChristoph Hellwig 489f461d2dcSChristoph Hellwig if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 490f461d2dcSChristoph Hellwig return -EINVAL; 491f461d2dcSChristoph Hellwig 492f461d2dcSChristoph Hellwig if (tr && (len < *size)) 493f461d2dcSChristoph Hellwig *tr = *p; 494f461d2dcSChristoph Hellwig 495f461d2dcSChristoph Hellwig *buf += len; 496f461d2dcSChristoph Hellwig *size -= len; 497f461d2dcSChristoph Hellwig 498f461d2dcSChristoph Hellwig return 0; 499f461d2dcSChristoph Hellwig } 500f461d2dcSChristoph Hellwig 501f461d2dcSChristoph Hellwig /** 502f461d2dcSChristoph Hellwig * proc_put_long - converts an integer to a decimal ASCII formatted string 503f461d2dcSChristoph Hellwig * 504f461d2dcSChristoph Hellwig * @buf: the user buffer 505f461d2dcSChristoph Hellwig * @size: the size of the user buffer 506f461d2dcSChristoph Hellwig * @val: the integer to be converted 507f461d2dcSChristoph Hellwig * @neg: sign of the number, %TRUE for negative 508f461d2dcSChristoph Hellwig * 50932927393SChristoph Hellwig * In case of success @buf and @size are updated with the amount of bytes 51032927393SChristoph Hellwig * written. 511f461d2dcSChristoph Hellwig */ 51232927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg) 513f461d2dcSChristoph Hellwig { 514f461d2dcSChristoph Hellwig int len; 515f461d2dcSChristoph Hellwig char tmp[TMPBUFLEN], *p = tmp; 516f461d2dcSChristoph Hellwig 517f461d2dcSChristoph Hellwig sprintf(p, "%s%lu", neg ? "-" : "", val); 518f461d2dcSChristoph Hellwig len = strlen(tmp); 519f461d2dcSChristoph Hellwig if (len > *size) 520f461d2dcSChristoph Hellwig len = *size; 52132927393SChristoph Hellwig memcpy(*buf, tmp, len); 522f461d2dcSChristoph Hellwig *size -= len; 523f461d2dcSChristoph Hellwig *buf += len; 524f461d2dcSChristoph Hellwig } 525f461d2dcSChristoph Hellwig #undef TMPBUFLEN 526f461d2dcSChristoph Hellwig 52732927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c) 528f461d2dcSChristoph Hellwig { 529f461d2dcSChristoph Hellwig if (*size) { 53032927393SChristoph Hellwig char **buffer = (char **)buf; 53132927393SChristoph Hellwig **buffer = c; 53232927393SChristoph Hellwig 53332927393SChristoph Hellwig (*size)--; 53432927393SChristoph Hellwig (*buffer)++; 535f461d2dcSChristoph Hellwig *buf = *buffer; 536f461d2dcSChristoph Hellwig } 537f461d2dcSChristoph Hellwig } 538f461d2dcSChristoph Hellwig 539f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 540f461d2dcSChristoph Hellwig int *valp, 541f461d2dcSChristoph Hellwig int write, void *data) 542f461d2dcSChristoph Hellwig { 543f461d2dcSChristoph Hellwig if (write) { 544f461d2dcSChristoph Hellwig if (*negp) { 545f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX + 1) 546f461d2dcSChristoph Hellwig return -EINVAL; 547f461d2dcSChristoph Hellwig *valp = -*lvalp; 548f461d2dcSChristoph Hellwig } else { 549f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX) 550f461d2dcSChristoph Hellwig return -EINVAL; 551f461d2dcSChristoph Hellwig *valp = *lvalp; 552f461d2dcSChristoph Hellwig } 553f461d2dcSChristoph Hellwig } else { 554f461d2dcSChristoph Hellwig int val = *valp; 555f461d2dcSChristoph Hellwig if (val < 0) { 556f461d2dcSChristoph Hellwig *negp = true; 557f461d2dcSChristoph Hellwig *lvalp = -(unsigned long)val; 558f461d2dcSChristoph Hellwig } else { 559f461d2dcSChristoph Hellwig *negp = false; 560f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 561f461d2dcSChristoph Hellwig } 562f461d2dcSChristoph Hellwig } 563f461d2dcSChristoph Hellwig return 0; 564f461d2dcSChristoph Hellwig } 565f461d2dcSChristoph Hellwig 566f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp, 567f461d2dcSChristoph Hellwig unsigned int *valp, 568f461d2dcSChristoph Hellwig int write, void *data) 569f461d2dcSChristoph Hellwig { 570f461d2dcSChristoph Hellwig if (write) { 571f461d2dcSChristoph Hellwig if (*lvalp > UINT_MAX) 572f461d2dcSChristoph Hellwig return -EINVAL; 573f461d2dcSChristoph Hellwig *valp = *lvalp; 574f461d2dcSChristoph Hellwig } else { 575f461d2dcSChristoph Hellwig unsigned int val = *valp; 576f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 577f461d2dcSChristoph Hellwig } 578f461d2dcSChristoph Hellwig return 0; 579f461d2dcSChristoph Hellwig } 580f461d2dcSChristoph Hellwig 581f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 582f461d2dcSChristoph Hellwig 583f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 58432927393SChristoph Hellwig int write, void *buffer, 585f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 586f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 587f461d2dcSChristoph Hellwig int write, void *data), 588f461d2dcSChristoph Hellwig void *data) 589f461d2dcSChristoph Hellwig { 590f461d2dcSChristoph Hellwig int *i, vleft, first = 1, err = 0; 591f461d2dcSChristoph Hellwig size_t left; 59232927393SChristoph Hellwig char *p; 593f461d2dcSChristoph Hellwig 594f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 595f461d2dcSChristoph Hellwig *lenp = 0; 596f461d2dcSChristoph Hellwig return 0; 597f461d2dcSChristoph Hellwig } 598f461d2dcSChristoph Hellwig 599f461d2dcSChristoph Hellwig i = (int *) tbl_data; 600f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 601f461d2dcSChristoph Hellwig left = *lenp; 602f461d2dcSChristoph Hellwig 603f461d2dcSChristoph Hellwig if (!conv) 604f461d2dcSChristoph Hellwig conv = do_proc_dointvec_conv; 605f461d2dcSChristoph Hellwig 606f461d2dcSChristoph Hellwig if (write) { 607f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 608f461d2dcSChristoph Hellwig goto out; 609f461d2dcSChristoph Hellwig 610f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 611f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 61232927393SChristoph Hellwig p = buffer; 613f461d2dcSChristoph Hellwig } 614f461d2dcSChristoph Hellwig 615f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first=0) { 616f461d2dcSChristoph Hellwig unsigned long lval; 617f461d2dcSChristoph Hellwig bool neg; 618f461d2dcSChristoph Hellwig 619f461d2dcSChristoph Hellwig if (write) { 620f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 621f461d2dcSChristoph Hellwig 622f461d2dcSChristoph Hellwig if (!left) 623f461d2dcSChristoph Hellwig break; 624f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 625f461d2dcSChristoph Hellwig proc_wspace_sep, 626f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 627f461d2dcSChristoph Hellwig if (err) 628f461d2dcSChristoph Hellwig break; 629f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 1, data)) { 630f461d2dcSChristoph Hellwig err = -EINVAL; 631f461d2dcSChristoph Hellwig break; 632f461d2dcSChristoph Hellwig } 633f461d2dcSChristoph Hellwig } else { 634f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 0, data)) { 635f461d2dcSChristoph Hellwig err = -EINVAL; 636f461d2dcSChristoph Hellwig break; 637f461d2dcSChristoph Hellwig } 638f461d2dcSChristoph Hellwig if (!first) 63932927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 64032927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, neg); 641f461d2dcSChristoph Hellwig } 642f461d2dcSChristoph Hellwig } 643f461d2dcSChristoph Hellwig 644f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 64532927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 646f461d2dcSChristoph Hellwig if (write && !err && left) 647f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 64832927393SChristoph Hellwig if (write && first) 649f461d2dcSChristoph Hellwig return err ? : -EINVAL; 650f461d2dcSChristoph Hellwig *lenp -= left; 651f461d2dcSChristoph Hellwig out: 652f461d2dcSChristoph Hellwig *ppos += *lenp; 653f461d2dcSChristoph Hellwig return err; 654f461d2dcSChristoph Hellwig } 655f461d2dcSChristoph Hellwig 656f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write, 65732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 658f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 659f461d2dcSChristoph Hellwig int write, void *data), 660f461d2dcSChristoph Hellwig void *data) 661f461d2dcSChristoph Hellwig { 662f461d2dcSChristoph Hellwig return __do_proc_dointvec(table->data, table, write, 663f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 664f461d2dcSChristoph Hellwig } 665f461d2dcSChristoph Hellwig 666f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data, 667f461d2dcSChristoph Hellwig struct ctl_table *table, 66832927393SChristoph Hellwig void *buffer, 669f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 670f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 671f461d2dcSChristoph Hellwig unsigned int *valp, 672f461d2dcSChristoph Hellwig int write, void *data), 673f461d2dcSChristoph Hellwig void *data) 674f461d2dcSChristoph Hellwig { 675f461d2dcSChristoph Hellwig unsigned long lval; 676f461d2dcSChristoph Hellwig int err = 0; 677f461d2dcSChristoph Hellwig size_t left; 678f461d2dcSChristoph Hellwig bool neg; 67932927393SChristoph Hellwig char *p = buffer; 680f461d2dcSChristoph Hellwig 681f461d2dcSChristoph Hellwig left = *lenp; 682f461d2dcSChristoph Hellwig 683f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 684f461d2dcSChristoph Hellwig goto bail_early; 685f461d2dcSChristoph Hellwig 686f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 687f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 688f461d2dcSChristoph Hellwig 689f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 690f461d2dcSChristoph Hellwig if (!left) { 691f461d2dcSChristoph Hellwig err = -EINVAL; 692f461d2dcSChristoph Hellwig goto out_free; 693f461d2dcSChristoph Hellwig } 694f461d2dcSChristoph Hellwig 695f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 696f461d2dcSChristoph Hellwig proc_wspace_sep, 697f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 698f461d2dcSChristoph Hellwig if (err || neg) { 699f461d2dcSChristoph Hellwig err = -EINVAL; 700f461d2dcSChristoph Hellwig goto out_free; 701f461d2dcSChristoph Hellwig } 702f461d2dcSChristoph Hellwig 703f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 1, data)) { 704f461d2dcSChristoph Hellwig err = -EINVAL; 705f461d2dcSChristoph Hellwig goto out_free; 706f461d2dcSChristoph Hellwig } 707f461d2dcSChristoph Hellwig 708f461d2dcSChristoph Hellwig if (!err && left) 709f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 710f461d2dcSChristoph Hellwig 711f461d2dcSChristoph Hellwig out_free: 712f461d2dcSChristoph Hellwig if (err) 713f461d2dcSChristoph Hellwig return -EINVAL; 714f461d2dcSChristoph Hellwig 715f461d2dcSChristoph Hellwig return 0; 716f461d2dcSChristoph Hellwig 717f461d2dcSChristoph Hellwig /* This is in keeping with old __do_proc_dointvec() */ 718f461d2dcSChristoph Hellwig bail_early: 719f461d2dcSChristoph Hellwig *ppos += *lenp; 720f461d2dcSChristoph Hellwig return err; 721f461d2dcSChristoph Hellwig } 722f461d2dcSChristoph Hellwig 72332927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer, 724f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 725f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 726f461d2dcSChristoph Hellwig unsigned int *valp, 727f461d2dcSChristoph Hellwig int write, void *data), 728f461d2dcSChristoph Hellwig void *data) 729f461d2dcSChristoph Hellwig { 730f461d2dcSChristoph Hellwig unsigned long lval; 731f461d2dcSChristoph Hellwig int err = 0; 732f461d2dcSChristoph Hellwig size_t left; 733f461d2dcSChristoph Hellwig 734f461d2dcSChristoph Hellwig left = *lenp; 735f461d2dcSChristoph Hellwig 736f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 0, data)) { 737f461d2dcSChristoph Hellwig err = -EINVAL; 738f461d2dcSChristoph Hellwig goto out; 739f461d2dcSChristoph Hellwig } 740f461d2dcSChristoph Hellwig 74132927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, false); 74232927393SChristoph Hellwig if (!left) 743f461d2dcSChristoph Hellwig goto out; 744f461d2dcSChristoph Hellwig 74532927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 746f461d2dcSChristoph Hellwig 747f461d2dcSChristoph Hellwig out: 748f461d2dcSChristoph Hellwig *lenp -= left; 749f461d2dcSChristoph Hellwig *ppos += *lenp; 750f461d2dcSChristoph Hellwig 751f461d2dcSChristoph Hellwig return err; 752f461d2dcSChristoph Hellwig } 753f461d2dcSChristoph Hellwig 754f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, 75532927393SChristoph Hellwig int write, void *buffer, 756f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 757f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 758f461d2dcSChristoph Hellwig unsigned int *valp, 759f461d2dcSChristoph Hellwig int write, void *data), 760f461d2dcSChristoph Hellwig void *data) 761f461d2dcSChristoph Hellwig { 762f461d2dcSChristoph Hellwig unsigned int *i, vleft; 763f461d2dcSChristoph Hellwig 764f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 765f461d2dcSChristoph Hellwig *lenp = 0; 766f461d2dcSChristoph Hellwig return 0; 767f461d2dcSChristoph Hellwig } 768f461d2dcSChristoph Hellwig 769f461d2dcSChristoph Hellwig i = (unsigned int *) tbl_data; 770f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 771f461d2dcSChristoph Hellwig 772f461d2dcSChristoph Hellwig /* 773f461d2dcSChristoph Hellwig * Arrays are not supported, keep this simple. *Do not* add 774f461d2dcSChristoph Hellwig * support for them. 775f461d2dcSChristoph Hellwig */ 776f461d2dcSChristoph Hellwig if (vleft != 1) { 777f461d2dcSChristoph Hellwig *lenp = 0; 778f461d2dcSChristoph Hellwig return -EINVAL; 779f461d2dcSChristoph Hellwig } 780f461d2dcSChristoph Hellwig 781f461d2dcSChristoph Hellwig if (!conv) 782f461d2dcSChristoph Hellwig conv = do_proc_douintvec_conv; 783f461d2dcSChristoph Hellwig 784f461d2dcSChristoph Hellwig if (write) 785f461d2dcSChristoph Hellwig return do_proc_douintvec_w(i, table, buffer, lenp, ppos, 786f461d2dcSChristoph Hellwig conv, data); 787f461d2dcSChristoph Hellwig return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); 788f461d2dcSChristoph Hellwig } 789f461d2dcSChristoph Hellwig 790f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write, 79132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 792f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 793f461d2dcSChristoph Hellwig unsigned int *valp, 794f461d2dcSChristoph Hellwig int write, void *data), 795f461d2dcSChristoph Hellwig void *data) 796f461d2dcSChristoph Hellwig { 797f461d2dcSChristoph Hellwig return __do_proc_douintvec(table->data, table, write, 798f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 799f461d2dcSChristoph Hellwig } 800f461d2dcSChristoph Hellwig 801f461d2dcSChristoph Hellwig /** 802f461d2dcSChristoph Hellwig * proc_dointvec - read a vector of integers 803f461d2dcSChristoph Hellwig * @table: the sysctl table 804f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 805f461d2dcSChristoph Hellwig * @buffer: the user buffer 806f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 807f461d2dcSChristoph Hellwig * @ppos: file position 808f461d2dcSChristoph Hellwig * 809f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 810f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 811f461d2dcSChristoph Hellwig * 812f461d2dcSChristoph Hellwig * Returns 0 on success. 813f461d2dcSChristoph Hellwig */ 81432927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer, 81532927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 816f461d2dcSChristoph Hellwig { 817f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 818f461d2dcSChristoph Hellwig } 819f461d2dcSChristoph Hellwig 820f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION 821f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, 82232927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos) 823f461d2dcSChristoph Hellwig { 824f461d2dcSChristoph Hellwig int ret, old; 825f461d2dcSChristoph Hellwig 826f461d2dcSChristoph Hellwig if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) 827f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 828f461d2dcSChristoph Hellwig 829f461d2dcSChristoph Hellwig old = *(int *)table->data; 830f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 831f461d2dcSChristoph Hellwig if (ret) 832f461d2dcSChristoph Hellwig return ret; 833f461d2dcSChristoph Hellwig if (old != *(int *)table->data) 834f461d2dcSChristoph Hellwig pr_warn_once("sysctl attribute %s changed by %s[%d]\n", 835f461d2dcSChristoph Hellwig table->procname, current->comm, 836f461d2dcSChristoph Hellwig task_pid_nr(current)); 837f461d2dcSChristoph Hellwig return ret; 838f461d2dcSChristoph Hellwig } 839f461d2dcSChristoph Hellwig #endif 840f461d2dcSChristoph Hellwig 841f461d2dcSChristoph Hellwig /** 842f461d2dcSChristoph Hellwig * proc_douintvec - read a vector of unsigned integers 843f461d2dcSChristoph Hellwig * @table: the sysctl table 844f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 845f461d2dcSChristoph Hellwig * @buffer: the user buffer 846f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 847f461d2dcSChristoph Hellwig * @ppos: file position 848f461d2dcSChristoph Hellwig * 849f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 850f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 851f461d2dcSChristoph Hellwig * 852f461d2dcSChristoph Hellwig * Returns 0 on success. 853f461d2dcSChristoph Hellwig */ 85432927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer, 85532927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 856f461d2dcSChristoph Hellwig { 857f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 858f461d2dcSChristoph Hellwig do_proc_douintvec_conv, NULL); 859f461d2dcSChristoph Hellwig } 860f461d2dcSChristoph Hellwig 861f461d2dcSChristoph Hellwig /* 862f461d2dcSChristoph Hellwig * Taint values can only be increased 863f461d2dcSChristoph Hellwig * This means we can safely use a temporary. 864f461d2dcSChristoph Hellwig */ 865f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write, 86632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 867f461d2dcSChristoph Hellwig { 868f461d2dcSChristoph Hellwig struct ctl_table t; 869f461d2dcSChristoph Hellwig unsigned long tmptaint = get_taint(); 870f461d2dcSChristoph Hellwig int err; 871f461d2dcSChristoph Hellwig 872f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 873f461d2dcSChristoph Hellwig return -EPERM; 874f461d2dcSChristoph Hellwig 875f461d2dcSChristoph Hellwig t = *table; 876f461d2dcSChristoph Hellwig t.data = &tmptaint; 877f461d2dcSChristoph Hellwig err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 878f461d2dcSChristoph Hellwig if (err < 0) 879f461d2dcSChristoph Hellwig return err; 880f461d2dcSChristoph Hellwig 881f461d2dcSChristoph Hellwig if (write) { 882db38d5c1SRafael Aquini int i; 883db38d5c1SRafael Aquini 884db38d5c1SRafael Aquini /* 885db38d5c1SRafael Aquini * If we are relying on panic_on_taint not producing 886db38d5c1SRafael Aquini * false positives due to userspace input, bail out 887db38d5c1SRafael Aquini * before setting the requested taint flags. 888db38d5c1SRafael Aquini */ 889db38d5c1SRafael Aquini if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint)) 890db38d5c1SRafael Aquini return -EINVAL; 891db38d5c1SRafael Aquini 892f461d2dcSChristoph Hellwig /* 893f461d2dcSChristoph Hellwig * Poor man's atomic or. Not worth adding a primitive 894f461d2dcSChristoph Hellwig * to everyone's atomic.h for this 895f461d2dcSChristoph Hellwig */ 896e77132e7SRafael Aquini for (i = 0; i < TAINT_FLAGS_COUNT; i++) 897e77132e7SRafael Aquini if ((1UL << i) & tmptaint) 898f461d2dcSChristoph Hellwig add_taint(i, LOCKDEP_STILL_OK); 899f461d2dcSChristoph Hellwig } 900f461d2dcSChristoph Hellwig 901f461d2dcSChristoph Hellwig return err; 902f461d2dcSChristoph Hellwig } 903f461d2dcSChristoph Hellwig 904f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK 905f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 90632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 907f461d2dcSChristoph Hellwig { 908f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 909f461d2dcSChristoph Hellwig return -EPERM; 910f461d2dcSChristoph Hellwig 911f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 912f461d2dcSChristoph Hellwig } 913f461d2dcSChristoph Hellwig #endif 914f461d2dcSChristoph Hellwig 915f461d2dcSChristoph Hellwig /** 916f461d2dcSChristoph Hellwig * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure 917f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 918f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 919f461d2dcSChristoph Hellwig * 920f461d2dcSChristoph Hellwig * The do_proc_dointvec_minmax_conv_param structure provides the 921f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 922f461d2dcSChristoph Hellwig * parameters that use the proc_dointvec_minmax() handler. 923f461d2dcSChristoph Hellwig */ 924f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param { 925f461d2dcSChristoph Hellwig int *min; 926f461d2dcSChristoph Hellwig int *max; 927f461d2dcSChristoph Hellwig }; 928f461d2dcSChristoph Hellwig 929f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 930f461d2dcSChristoph Hellwig int *valp, 931f461d2dcSChristoph Hellwig int write, void *data) 932f461d2dcSChristoph Hellwig { 933f461d2dcSChristoph Hellwig int tmp, ret; 934f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param *param = data; 935f461d2dcSChristoph Hellwig /* 936f461d2dcSChristoph Hellwig * If writing, first do so via a temporary local int so we can 937f461d2dcSChristoph Hellwig * bounds-check it before touching *valp. 938f461d2dcSChristoph Hellwig */ 939f461d2dcSChristoph Hellwig int *ip = write ? &tmp : valp; 940f461d2dcSChristoph Hellwig 941f461d2dcSChristoph Hellwig ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); 942f461d2dcSChristoph Hellwig if (ret) 943f461d2dcSChristoph Hellwig return ret; 944f461d2dcSChristoph Hellwig 945f461d2dcSChristoph Hellwig if (write) { 946f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 947f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 948f461d2dcSChristoph Hellwig return -EINVAL; 949f461d2dcSChristoph Hellwig *valp = tmp; 950f461d2dcSChristoph Hellwig } 951f461d2dcSChristoph Hellwig 952f461d2dcSChristoph Hellwig return 0; 953f461d2dcSChristoph Hellwig } 954f461d2dcSChristoph Hellwig 955f461d2dcSChristoph Hellwig /** 956f461d2dcSChristoph Hellwig * proc_dointvec_minmax - read a vector of integers with min/max values 957f461d2dcSChristoph Hellwig * @table: the sysctl table 958f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 959f461d2dcSChristoph Hellwig * @buffer: the user buffer 960f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 961f461d2dcSChristoph Hellwig * @ppos: file position 962f461d2dcSChristoph Hellwig * 963f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 964f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 965f461d2dcSChristoph Hellwig * 966f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 967f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 968f461d2dcSChristoph Hellwig * 969f461d2dcSChristoph Hellwig * Returns 0 on success or -EINVAL on write when the range check fails. 970f461d2dcSChristoph Hellwig */ 971f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 97232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 973f461d2dcSChristoph Hellwig { 974f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param param = { 975f461d2dcSChristoph Hellwig .min = (int *) table->extra1, 976f461d2dcSChristoph Hellwig .max = (int *) table->extra2, 977f461d2dcSChristoph Hellwig }; 978f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 979f461d2dcSChristoph Hellwig do_proc_dointvec_minmax_conv, ¶m); 980f461d2dcSChristoph Hellwig } 981f461d2dcSChristoph Hellwig 982f461d2dcSChristoph Hellwig /** 983f461d2dcSChristoph Hellwig * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure 984f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 985f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 986f461d2dcSChristoph Hellwig * 987f461d2dcSChristoph Hellwig * The do_proc_douintvec_minmax_conv_param structure provides the 988f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 989f461d2dcSChristoph Hellwig * parameters that use the proc_douintvec_minmax() handler. 990f461d2dcSChristoph Hellwig */ 991f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param { 992f461d2dcSChristoph Hellwig unsigned int *min; 993f461d2dcSChristoph Hellwig unsigned int *max; 994f461d2dcSChristoph Hellwig }; 995f461d2dcSChristoph Hellwig 996f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, 997f461d2dcSChristoph Hellwig unsigned int *valp, 998f461d2dcSChristoph Hellwig int write, void *data) 999f461d2dcSChristoph Hellwig { 1000f461d2dcSChristoph Hellwig int ret; 1001f461d2dcSChristoph Hellwig unsigned int tmp; 1002f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param *param = data; 1003f461d2dcSChristoph Hellwig /* write via temporary local uint for bounds-checking */ 1004f461d2dcSChristoph Hellwig unsigned int *up = write ? &tmp : valp; 1005f461d2dcSChristoph Hellwig 1006f461d2dcSChristoph Hellwig ret = do_proc_douintvec_conv(lvalp, up, write, data); 1007f461d2dcSChristoph Hellwig if (ret) 1008f461d2dcSChristoph Hellwig return ret; 1009f461d2dcSChristoph Hellwig 1010f461d2dcSChristoph Hellwig if (write) { 1011f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 1012f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 1013f461d2dcSChristoph Hellwig return -ERANGE; 1014f461d2dcSChristoph Hellwig 1015f461d2dcSChristoph Hellwig *valp = tmp; 1016f461d2dcSChristoph Hellwig } 1017f461d2dcSChristoph Hellwig 1018f461d2dcSChristoph Hellwig return 0; 1019f461d2dcSChristoph Hellwig } 1020f461d2dcSChristoph Hellwig 1021f461d2dcSChristoph Hellwig /** 1022f461d2dcSChristoph Hellwig * proc_douintvec_minmax - read a vector of unsigned ints with min/max values 1023f461d2dcSChristoph Hellwig * @table: the sysctl table 1024f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1025f461d2dcSChristoph Hellwig * @buffer: the user buffer 1026f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1027f461d2dcSChristoph Hellwig * @ppos: file position 1028f461d2dcSChristoph Hellwig * 1029f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 1030f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. Negative 1031f461d2dcSChristoph Hellwig * strings are not allowed. 1032f461d2dcSChristoph Hellwig * 1033f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1034f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). There is a final sanity 1035f461d2dcSChristoph Hellwig * check for UINT_MAX to avoid having to support wrap around uses from 1036f461d2dcSChristoph Hellwig * userspace. 1037f461d2dcSChristoph Hellwig * 1038f461d2dcSChristoph Hellwig * Returns 0 on success or -ERANGE on write when the range check fails. 1039f461d2dcSChristoph Hellwig */ 1040f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 104132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1042f461d2dcSChristoph Hellwig { 1043f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param param = { 1044f461d2dcSChristoph Hellwig .min = (unsigned int *) table->extra1, 1045f461d2dcSChristoph Hellwig .max = (unsigned int *) table->extra2, 1046f461d2dcSChristoph Hellwig }; 1047f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1048f461d2dcSChristoph Hellwig do_proc_douintvec_minmax_conv, ¶m); 1049f461d2dcSChristoph Hellwig } 1050f461d2dcSChristoph Hellwig 1051cb944413SEric Dumazet /** 1052cb944413SEric Dumazet * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values 1053cb944413SEric Dumazet * @table: the sysctl table 1054cb944413SEric Dumazet * @write: %TRUE if this is a write to the sysctl file 1055cb944413SEric Dumazet * @buffer: the user buffer 1056cb944413SEric Dumazet * @lenp: the size of the user buffer 1057cb944413SEric Dumazet * @ppos: file position 1058cb944413SEric Dumazet * 1059cb944413SEric Dumazet * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars 1060cb944413SEric Dumazet * values from/to the user buffer, treated as an ASCII string. Negative 1061cb944413SEric Dumazet * strings are not allowed. 1062cb944413SEric Dumazet * 1063cb944413SEric Dumazet * This routine will ensure the values are within the range specified by 1064cb944413SEric Dumazet * table->extra1 (min) and table->extra2 (max). 1065cb944413SEric Dumazet * 1066cb944413SEric Dumazet * Returns 0 on success or an error on write when the range check fails. 1067cb944413SEric Dumazet */ 1068cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write, 1069cb944413SEric Dumazet void *buffer, size_t *lenp, loff_t *ppos) 1070cb944413SEric Dumazet { 1071cb944413SEric Dumazet struct ctl_table tmp; 1072cb944413SEric Dumazet unsigned int min = 0, max = 255U, val; 1073cb944413SEric Dumazet u8 *data = table->data; 1074cb944413SEric Dumazet struct do_proc_douintvec_minmax_conv_param param = { 1075cb944413SEric Dumazet .min = &min, 1076cb944413SEric Dumazet .max = &max, 1077cb944413SEric Dumazet }; 1078cb944413SEric Dumazet int res; 1079cb944413SEric Dumazet 1080cb944413SEric Dumazet /* Do not support arrays yet. */ 1081cb944413SEric Dumazet if (table->maxlen != sizeof(u8)) 1082cb944413SEric Dumazet return -EINVAL; 1083cb944413SEric Dumazet 1084cb944413SEric Dumazet if (table->extra1) { 1085cb944413SEric Dumazet min = *(unsigned int *) table->extra1; 1086cb944413SEric Dumazet if (min > 255U) 1087cb944413SEric Dumazet return -EINVAL; 1088cb944413SEric Dumazet } 1089cb944413SEric Dumazet if (table->extra2) { 1090cb944413SEric Dumazet max = *(unsigned int *) table->extra2; 1091cb944413SEric Dumazet if (max > 255U) 1092cb944413SEric Dumazet return -EINVAL; 1093cb944413SEric Dumazet } 1094cb944413SEric Dumazet 1095cb944413SEric Dumazet tmp = *table; 1096cb944413SEric Dumazet 1097cb944413SEric Dumazet tmp.maxlen = sizeof(val); 1098cb944413SEric Dumazet tmp.data = &val; 1099cb944413SEric Dumazet val = *data; 1100cb944413SEric Dumazet res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos, 1101cb944413SEric Dumazet do_proc_douintvec_minmax_conv, ¶m); 1102cb944413SEric Dumazet if (res) 1103cb944413SEric Dumazet return res; 1104cb944413SEric Dumazet if (write) 1105cb944413SEric Dumazet *data = val; 1106cb944413SEric Dumazet return 0; 1107cb944413SEric Dumazet } 1108cb944413SEric Dumazet EXPORT_SYMBOL_GPL(proc_dou8vec_minmax); 1109cb944413SEric Dumazet 1110f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp, 1111f461d2dcSChristoph Hellwig unsigned int *valp, 1112f461d2dcSChristoph Hellwig int write, void *data) 1113f461d2dcSChristoph Hellwig { 1114f461d2dcSChristoph Hellwig if (write) { 1115f461d2dcSChristoph Hellwig unsigned int val; 1116f461d2dcSChristoph Hellwig 1117f461d2dcSChristoph Hellwig val = round_pipe_size(*lvalp); 1118f461d2dcSChristoph Hellwig if (val == 0) 1119f461d2dcSChristoph Hellwig return -EINVAL; 1120f461d2dcSChristoph Hellwig 1121f461d2dcSChristoph Hellwig *valp = val; 1122f461d2dcSChristoph Hellwig } else { 1123f461d2dcSChristoph Hellwig unsigned int val = *valp; 1124f461d2dcSChristoph Hellwig *lvalp = (unsigned long) val; 1125f461d2dcSChristoph Hellwig } 1126f461d2dcSChristoph Hellwig 1127f461d2dcSChristoph Hellwig return 0; 1128f461d2dcSChristoph Hellwig } 1129f461d2dcSChristoph Hellwig 1130f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write, 113132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1132f461d2dcSChristoph Hellwig { 1133f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1134f461d2dcSChristoph Hellwig do_proc_dopipe_max_size_conv, NULL); 1135f461d2dcSChristoph Hellwig } 1136f461d2dcSChristoph Hellwig 1137f461d2dcSChristoph Hellwig static void validate_coredump_safety(void) 1138f461d2dcSChristoph Hellwig { 1139f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1140f461d2dcSChristoph Hellwig if (suid_dumpable == SUID_DUMP_ROOT && 1141f461d2dcSChristoph Hellwig core_pattern[0] != '/' && core_pattern[0] != '|') { 1142f461d2dcSChristoph Hellwig printk(KERN_WARNING 1143f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n" 1144f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n" 1145f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n" 1146f461d2dcSChristoph Hellwig ); 1147f461d2dcSChristoph Hellwig } 1148f461d2dcSChristoph Hellwig #endif 1149f461d2dcSChristoph Hellwig } 1150f461d2dcSChristoph Hellwig 1151f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 115232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1153f461d2dcSChristoph Hellwig { 1154f461d2dcSChristoph Hellwig int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 1155f461d2dcSChristoph Hellwig if (!error) 1156f461d2dcSChristoph Hellwig validate_coredump_safety(); 1157f461d2dcSChristoph Hellwig return error; 1158f461d2dcSChristoph Hellwig } 1159f461d2dcSChristoph Hellwig 1160f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1161f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write, 116232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1163f461d2dcSChristoph Hellwig { 1164f461d2dcSChristoph Hellwig int error = proc_dostring(table, write, buffer, lenp, ppos); 1165f461d2dcSChristoph Hellwig if (!error) 1166f461d2dcSChristoph Hellwig validate_coredump_safety(); 1167f461d2dcSChristoph Hellwig return error; 1168f461d2dcSChristoph Hellwig } 1169f461d2dcSChristoph Hellwig #endif 1170f461d2dcSChristoph Hellwig 1171f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ 1172f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write, 117332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1174f461d2dcSChristoph Hellwig { 1175f461d2dcSChristoph Hellwig int tmp, ret; 1176f461d2dcSChristoph Hellwig 1177f461d2dcSChristoph Hellwig tmp = sysrq_mask(); 1178f461d2dcSChristoph Hellwig 1179f461d2dcSChristoph Hellwig ret = __do_proc_dointvec(&tmp, table, write, buffer, 1180f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1181f461d2dcSChristoph Hellwig if (ret || !write) 1182f461d2dcSChristoph Hellwig return ret; 1183f461d2dcSChristoph Hellwig 1184f461d2dcSChristoph Hellwig if (write) 1185f461d2dcSChristoph Hellwig sysrq_toggle_support(tmp); 1186f461d2dcSChristoph Hellwig 1187f461d2dcSChristoph Hellwig return 0; 1188f461d2dcSChristoph Hellwig } 1189f461d2dcSChristoph Hellwig #endif 1190f461d2dcSChristoph Hellwig 119132927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, 119232927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos, 119332927393SChristoph Hellwig unsigned long convmul, unsigned long convdiv) 1194f461d2dcSChristoph Hellwig { 1195f461d2dcSChristoph Hellwig unsigned long *i, *min, *max; 1196f461d2dcSChristoph Hellwig int vleft, first = 1, err = 0; 1197f461d2dcSChristoph Hellwig size_t left; 119832927393SChristoph Hellwig char *p; 1199f461d2dcSChristoph Hellwig 1200f461d2dcSChristoph Hellwig if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 1201f461d2dcSChristoph Hellwig *lenp = 0; 1202f461d2dcSChristoph Hellwig return 0; 1203f461d2dcSChristoph Hellwig } 1204f461d2dcSChristoph Hellwig 1205f461d2dcSChristoph Hellwig i = (unsigned long *) data; 1206f461d2dcSChristoph Hellwig min = (unsigned long *) table->extra1; 1207f461d2dcSChristoph Hellwig max = (unsigned long *) table->extra2; 1208f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(unsigned long); 1209f461d2dcSChristoph Hellwig left = *lenp; 1210f461d2dcSChristoph Hellwig 1211f461d2dcSChristoph Hellwig if (write) { 1212f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 1213f461d2dcSChristoph Hellwig goto out; 1214f461d2dcSChristoph Hellwig 1215f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 1216f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 121732927393SChristoph Hellwig p = buffer; 1218f461d2dcSChristoph Hellwig } 1219f461d2dcSChristoph Hellwig 1220f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first = 0) { 1221f461d2dcSChristoph Hellwig unsigned long val; 1222f461d2dcSChristoph Hellwig 1223f461d2dcSChristoph Hellwig if (write) { 1224f461d2dcSChristoph Hellwig bool neg; 1225f461d2dcSChristoph Hellwig 1226f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 1227f461d2dcSChristoph Hellwig if (!left) 1228f461d2dcSChristoph Hellwig break; 1229f461d2dcSChristoph Hellwig 1230f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val, &neg, 1231f461d2dcSChristoph Hellwig proc_wspace_sep, 1232f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 1233f461d2dcSChristoph Hellwig if (err) 1234f461d2dcSChristoph Hellwig break; 1235f461d2dcSChristoph Hellwig if (neg) 1236f461d2dcSChristoph Hellwig continue; 1237f461d2dcSChristoph Hellwig val = convmul * val / convdiv; 1238f461d2dcSChristoph Hellwig if ((min && val < *min) || (max && val > *max)) { 1239f461d2dcSChristoph Hellwig err = -EINVAL; 1240f461d2dcSChristoph Hellwig break; 1241f461d2dcSChristoph Hellwig } 1242f461d2dcSChristoph Hellwig *i = val; 1243f461d2dcSChristoph Hellwig } else { 1244f461d2dcSChristoph Hellwig val = convdiv * (*i) / convmul; 124532927393SChristoph Hellwig if (!first) 124632927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 124732927393SChristoph Hellwig proc_put_long(&buffer, &left, val, false); 1248f461d2dcSChristoph Hellwig } 1249f461d2dcSChristoph Hellwig } 1250f461d2dcSChristoph Hellwig 1251f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 125232927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1253f461d2dcSChristoph Hellwig if (write && !err) 1254f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 125532927393SChristoph Hellwig if (write && first) 1256f461d2dcSChristoph Hellwig return err ? : -EINVAL; 1257f461d2dcSChristoph Hellwig *lenp -= left; 1258f461d2dcSChristoph Hellwig out: 1259f461d2dcSChristoph Hellwig *ppos += *lenp; 1260f461d2dcSChristoph Hellwig return err; 1261f461d2dcSChristoph Hellwig } 1262f461d2dcSChristoph Hellwig 1263f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 126432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, 1265f461d2dcSChristoph Hellwig unsigned long convdiv) 1266f461d2dcSChristoph Hellwig { 1267f461d2dcSChristoph Hellwig return __do_proc_doulongvec_minmax(table->data, table, write, 1268f461d2dcSChristoph Hellwig buffer, lenp, ppos, convmul, convdiv); 1269f461d2dcSChristoph Hellwig } 1270f461d2dcSChristoph Hellwig 1271f461d2dcSChristoph Hellwig /** 1272f461d2dcSChristoph Hellwig * proc_doulongvec_minmax - read a vector of long integers with min/max values 1273f461d2dcSChristoph Hellwig * @table: the sysctl table 1274f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1275f461d2dcSChristoph Hellwig * @buffer: the user buffer 1276f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1277f461d2dcSChristoph Hellwig * @ppos: file position 1278f461d2dcSChristoph Hellwig * 1279f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1280f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1281f461d2dcSChristoph Hellwig * 1282f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1283f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1284f461d2dcSChristoph Hellwig * 1285f461d2dcSChristoph Hellwig * Returns 0 on success. 1286f461d2dcSChristoph Hellwig */ 1287f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 128832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1289f461d2dcSChristoph Hellwig { 1290f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 1291f461d2dcSChristoph Hellwig } 1292f461d2dcSChristoph Hellwig 1293f461d2dcSChristoph Hellwig /** 1294f461d2dcSChristoph Hellwig * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 1295f461d2dcSChristoph Hellwig * @table: the sysctl table 1296f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1297f461d2dcSChristoph Hellwig * @buffer: the user buffer 1298f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1299f461d2dcSChristoph Hellwig * @ppos: file position 1300f461d2dcSChristoph Hellwig * 1301f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1302f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. The values 1303f461d2dcSChristoph Hellwig * are treated as milliseconds, and converted to jiffies when they are stored. 1304f461d2dcSChristoph Hellwig * 1305f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1306f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1307f461d2dcSChristoph Hellwig * 1308f461d2dcSChristoph Hellwig * Returns 0 on success. 1309f461d2dcSChristoph Hellwig */ 1310f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 131132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1312f461d2dcSChristoph Hellwig { 1313f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, 1314f461d2dcSChristoph Hellwig lenp, ppos, HZ, 1000l); 1315f461d2dcSChristoph Hellwig } 1316f461d2dcSChristoph Hellwig 1317f461d2dcSChristoph Hellwig 1318f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 1319f461d2dcSChristoph Hellwig int *valp, 1320f461d2dcSChristoph Hellwig int write, void *data) 1321f461d2dcSChristoph Hellwig { 1322f461d2dcSChristoph Hellwig if (write) { 1323f461d2dcSChristoph Hellwig if (*lvalp > INT_MAX / HZ) 1324f461d2dcSChristoph Hellwig return 1; 1325f461d2dcSChristoph Hellwig *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 1326f461d2dcSChristoph Hellwig } else { 1327f461d2dcSChristoph Hellwig int val = *valp; 1328f461d2dcSChristoph Hellwig unsigned long lval; 1329f461d2dcSChristoph Hellwig if (val < 0) { 1330f461d2dcSChristoph Hellwig *negp = true; 1331f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1332f461d2dcSChristoph Hellwig } else { 1333f461d2dcSChristoph Hellwig *negp = false; 1334f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1335f461d2dcSChristoph Hellwig } 1336f461d2dcSChristoph Hellwig *lvalp = lval / HZ; 1337f461d2dcSChristoph Hellwig } 1338f461d2dcSChristoph Hellwig return 0; 1339f461d2dcSChristoph Hellwig } 1340f461d2dcSChristoph Hellwig 1341f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 1342f461d2dcSChristoph Hellwig int *valp, 1343f461d2dcSChristoph Hellwig int write, void *data) 1344f461d2dcSChristoph Hellwig { 1345f461d2dcSChristoph Hellwig if (write) { 1346f461d2dcSChristoph Hellwig if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 1347f461d2dcSChristoph Hellwig return 1; 1348f461d2dcSChristoph Hellwig *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 1349f461d2dcSChristoph Hellwig } else { 1350f461d2dcSChristoph Hellwig int val = *valp; 1351f461d2dcSChristoph Hellwig unsigned long lval; 1352f461d2dcSChristoph Hellwig if (val < 0) { 1353f461d2dcSChristoph Hellwig *negp = true; 1354f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1355f461d2dcSChristoph Hellwig } else { 1356f461d2dcSChristoph Hellwig *negp = false; 1357f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1358f461d2dcSChristoph Hellwig } 1359f461d2dcSChristoph Hellwig *lvalp = jiffies_to_clock_t(lval); 1360f461d2dcSChristoph Hellwig } 1361f461d2dcSChristoph Hellwig return 0; 1362f461d2dcSChristoph Hellwig } 1363f461d2dcSChristoph Hellwig 1364f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 1365f461d2dcSChristoph Hellwig int *valp, 1366f461d2dcSChristoph Hellwig int write, void *data) 1367f461d2dcSChristoph Hellwig { 1368f461d2dcSChristoph Hellwig if (write) { 1369f461d2dcSChristoph Hellwig unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 1370f461d2dcSChristoph Hellwig 1371f461d2dcSChristoph Hellwig if (jif > INT_MAX) 1372f461d2dcSChristoph Hellwig return 1; 1373f461d2dcSChristoph Hellwig *valp = (int)jif; 1374f461d2dcSChristoph Hellwig } else { 1375f461d2dcSChristoph Hellwig int val = *valp; 1376f461d2dcSChristoph Hellwig unsigned long lval; 1377f461d2dcSChristoph Hellwig if (val < 0) { 1378f461d2dcSChristoph Hellwig *negp = true; 1379f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1380f461d2dcSChristoph Hellwig } else { 1381f461d2dcSChristoph Hellwig *negp = false; 1382f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1383f461d2dcSChristoph Hellwig } 1384f461d2dcSChristoph Hellwig *lvalp = jiffies_to_msecs(lval); 1385f461d2dcSChristoph Hellwig } 1386f461d2dcSChristoph Hellwig return 0; 1387f461d2dcSChristoph Hellwig } 1388f461d2dcSChristoph Hellwig 1389f461d2dcSChristoph Hellwig /** 1390f461d2dcSChristoph Hellwig * proc_dointvec_jiffies - read a vector of integers as seconds 1391f461d2dcSChristoph Hellwig * @table: the sysctl table 1392f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1393f461d2dcSChristoph Hellwig * @buffer: the user buffer 1394f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1395f461d2dcSChristoph Hellwig * @ppos: file position 1396f461d2dcSChristoph Hellwig * 1397f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1398f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1399f461d2dcSChristoph Hellwig * The values read are assumed to be in seconds, and are converted into 1400f461d2dcSChristoph Hellwig * jiffies. 1401f461d2dcSChristoph Hellwig * 1402f461d2dcSChristoph Hellwig * Returns 0 on success. 1403f461d2dcSChristoph Hellwig */ 1404f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 140532927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1406f461d2dcSChristoph Hellwig { 1407f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1408f461d2dcSChristoph Hellwig do_proc_dointvec_jiffies_conv,NULL); 1409f461d2dcSChristoph Hellwig } 1410f461d2dcSChristoph Hellwig 1411f461d2dcSChristoph Hellwig /** 1412f461d2dcSChristoph Hellwig * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 1413f461d2dcSChristoph Hellwig * @table: the sysctl table 1414f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1415f461d2dcSChristoph Hellwig * @buffer: the user buffer 1416f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1417f461d2dcSChristoph Hellwig * @ppos: pointer to the file position 1418f461d2dcSChristoph Hellwig * 1419f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1420f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1421f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/USER_HZ seconds, and 1422f461d2dcSChristoph Hellwig * are converted into jiffies. 1423f461d2dcSChristoph Hellwig * 1424f461d2dcSChristoph Hellwig * Returns 0 on success. 1425f461d2dcSChristoph Hellwig */ 1426f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 142732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1428f461d2dcSChristoph Hellwig { 1429f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1430f461d2dcSChristoph Hellwig do_proc_dointvec_userhz_jiffies_conv,NULL); 1431f461d2dcSChristoph Hellwig } 1432f461d2dcSChristoph Hellwig 1433f461d2dcSChristoph Hellwig /** 1434f461d2dcSChristoph Hellwig * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 1435f461d2dcSChristoph Hellwig * @table: the sysctl table 1436f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1437f461d2dcSChristoph Hellwig * @buffer: the user buffer 1438f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1439f461d2dcSChristoph Hellwig * @ppos: file position 1440f461d2dcSChristoph Hellwig * @ppos: the current position in the file 1441f461d2dcSChristoph Hellwig * 1442f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1443f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1444f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/1000 seconds, and 1445f461d2dcSChristoph Hellwig * are converted into jiffies. 1446f461d2dcSChristoph Hellwig * 1447f461d2dcSChristoph Hellwig * Returns 0 on success. 1448f461d2dcSChristoph Hellwig */ 144932927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer, 145032927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1451f461d2dcSChristoph Hellwig { 1452f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 1453f461d2dcSChristoph Hellwig do_proc_dointvec_ms_jiffies_conv, NULL); 1454f461d2dcSChristoph Hellwig } 1455f461d2dcSChristoph Hellwig 145632927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer, 145732927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1458f461d2dcSChristoph Hellwig { 1459f461d2dcSChristoph Hellwig struct pid *new_pid; 1460f461d2dcSChristoph Hellwig pid_t tmp; 1461f461d2dcSChristoph Hellwig int r; 1462f461d2dcSChristoph Hellwig 1463f461d2dcSChristoph Hellwig tmp = pid_vnr(cad_pid); 1464f461d2dcSChristoph Hellwig 1465f461d2dcSChristoph Hellwig r = __do_proc_dointvec(&tmp, table, write, buffer, 1466f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1467f461d2dcSChristoph Hellwig if (r || !write) 1468f461d2dcSChristoph Hellwig return r; 1469f461d2dcSChristoph Hellwig 1470f461d2dcSChristoph Hellwig new_pid = find_get_pid(tmp); 1471f461d2dcSChristoph Hellwig if (!new_pid) 1472f461d2dcSChristoph Hellwig return -ESRCH; 1473f461d2dcSChristoph Hellwig 1474f461d2dcSChristoph Hellwig put_pid(xchg(&cad_pid, new_pid)); 1475f461d2dcSChristoph Hellwig return 0; 1476f461d2dcSChristoph Hellwig } 1477f461d2dcSChristoph Hellwig 1478f461d2dcSChristoph Hellwig /** 1479f461d2dcSChristoph Hellwig * proc_do_large_bitmap - read/write from/to a large bitmap 1480f461d2dcSChristoph Hellwig * @table: the sysctl table 1481f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1482f461d2dcSChristoph Hellwig * @buffer: the user buffer 1483f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1484f461d2dcSChristoph Hellwig * @ppos: file position 1485f461d2dcSChristoph Hellwig * 1486f461d2dcSChristoph Hellwig * The bitmap is stored at table->data and the bitmap length (in bits) 1487f461d2dcSChristoph Hellwig * in table->maxlen. 1488f461d2dcSChristoph Hellwig * 1489f461d2dcSChristoph Hellwig * We use a range comma separated format (e.g. 1,3-4,10-10) so that 1490f461d2dcSChristoph Hellwig * large bitmaps may be represented in a compact manner. Writing into 1491f461d2dcSChristoph Hellwig * the file will clear the bitmap then update it with the given input. 1492f461d2dcSChristoph Hellwig * 1493f461d2dcSChristoph Hellwig * Returns 0 on success. 1494f461d2dcSChristoph Hellwig */ 1495f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 149632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1497f461d2dcSChristoph Hellwig { 1498f461d2dcSChristoph Hellwig int err = 0; 1499f461d2dcSChristoph Hellwig size_t left = *lenp; 1500f461d2dcSChristoph Hellwig unsigned long bitmap_len = table->maxlen; 1501f461d2dcSChristoph Hellwig unsigned long *bitmap = *(unsigned long **) table->data; 1502f461d2dcSChristoph Hellwig unsigned long *tmp_bitmap = NULL; 1503f461d2dcSChristoph Hellwig char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1504f461d2dcSChristoph Hellwig 1505f461d2dcSChristoph Hellwig if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { 1506f461d2dcSChristoph Hellwig *lenp = 0; 1507f461d2dcSChristoph Hellwig return 0; 1508f461d2dcSChristoph Hellwig } 1509f461d2dcSChristoph Hellwig 1510f461d2dcSChristoph Hellwig if (write) { 151132927393SChristoph Hellwig char *p = buffer; 1512f461d2dcSChristoph Hellwig size_t skipped = 0; 1513f461d2dcSChristoph Hellwig 1514f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) { 1515f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 1516f461d2dcSChristoph Hellwig /* How much of the buffer we'll skip this pass */ 1517f461d2dcSChristoph Hellwig skipped = *lenp - left; 1518f461d2dcSChristoph Hellwig } 1519f461d2dcSChristoph Hellwig 1520f461d2dcSChristoph Hellwig tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); 152132927393SChristoph Hellwig if (!tmp_bitmap) 1522f461d2dcSChristoph Hellwig return -ENOMEM; 1523f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1524f461d2dcSChristoph Hellwig while (!err && left) { 1525f461d2dcSChristoph Hellwig unsigned long val_a, val_b; 1526f461d2dcSChristoph Hellwig bool neg; 1527f461d2dcSChristoph Hellwig size_t saved_left; 1528f461d2dcSChristoph Hellwig 1529f461d2dcSChristoph Hellwig /* In case we stop parsing mid-number, we can reset */ 1530f461d2dcSChristoph Hellwig saved_left = left; 1531f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_a, &neg, tr_a, 1532f461d2dcSChristoph Hellwig sizeof(tr_a), &c); 1533f461d2dcSChristoph Hellwig /* 1534f461d2dcSChristoph Hellwig * If we consumed the entirety of a truncated buffer or 1535f461d2dcSChristoph Hellwig * only one char is left (may be a "-"), then stop here, 1536f461d2dcSChristoph Hellwig * reset, & come back for more. 1537f461d2dcSChristoph Hellwig */ 1538f461d2dcSChristoph Hellwig if ((left <= 1) && skipped) { 1539f461d2dcSChristoph Hellwig left = saved_left; 1540f461d2dcSChristoph Hellwig break; 1541f461d2dcSChristoph Hellwig } 1542f461d2dcSChristoph Hellwig 1543f461d2dcSChristoph Hellwig if (err) 1544f461d2dcSChristoph Hellwig break; 1545f461d2dcSChristoph Hellwig if (val_a >= bitmap_len || neg) { 1546f461d2dcSChristoph Hellwig err = -EINVAL; 1547f461d2dcSChristoph Hellwig break; 1548f461d2dcSChristoph Hellwig } 1549f461d2dcSChristoph Hellwig 1550f461d2dcSChristoph Hellwig val_b = val_a; 1551f461d2dcSChristoph Hellwig if (left) { 1552f461d2dcSChristoph Hellwig p++; 1553f461d2dcSChristoph Hellwig left--; 1554f461d2dcSChristoph Hellwig } 1555f461d2dcSChristoph Hellwig 1556f461d2dcSChristoph Hellwig if (c == '-') { 1557f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_b, 1558f461d2dcSChristoph Hellwig &neg, tr_b, sizeof(tr_b), 1559f461d2dcSChristoph Hellwig &c); 1560f461d2dcSChristoph Hellwig /* 1561f461d2dcSChristoph Hellwig * If we consumed all of a truncated buffer or 1562f461d2dcSChristoph Hellwig * then stop here, reset, & come back for more. 1563f461d2dcSChristoph Hellwig */ 1564f461d2dcSChristoph Hellwig if (!left && skipped) { 1565f461d2dcSChristoph Hellwig left = saved_left; 1566f461d2dcSChristoph Hellwig break; 1567f461d2dcSChristoph Hellwig } 1568f461d2dcSChristoph Hellwig 1569f461d2dcSChristoph Hellwig if (err) 1570f461d2dcSChristoph Hellwig break; 1571f461d2dcSChristoph Hellwig if (val_b >= bitmap_len || neg || 1572f461d2dcSChristoph Hellwig val_a > val_b) { 1573f461d2dcSChristoph Hellwig err = -EINVAL; 1574f461d2dcSChristoph Hellwig break; 1575f461d2dcSChristoph Hellwig } 1576f461d2dcSChristoph Hellwig if (left) { 1577f461d2dcSChristoph Hellwig p++; 1578f461d2dcSChristoph Hellwig left--; 1579f461d2dcSChristoph Hellwig } 1580f461d2dcSChristoph Hellwig } 1581f461d2dcSChristoph Hellwig 1582f461d2dcSChristoph Hellwig bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 1583f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1584f461d2dcSChristoph Hellwig } 1585f461d2dcSChristoph Hellwig left += skipped; 1586f461d2dcSChristoph Hellwig } else { 1587f461d2dcSChristoph Hellwig unsigned long bit_a, bit_b = 0; 15889a52c5f3SJiapeng Chong bool first = 1; 1589f461d2dcSChristoph Hellwig 1590f461d2dcSChristoph Hellwig while (left) { 1591f461d2dcSChristoph Hellwig bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 1592f461d2dcSChristoph Hellwig if (bit_a >= bitmap_len) 1593f461d2dcSChristoph Hellwig break; 1594f461d2dcSChristoph Hellwig bit_b = find_next_zero_bit(bitmap, bitmap_len, 1595f461d2dcSChristoph Hellwig bit_a + 1) - 1; 1596f461d2dcSChristoph Hellwig 159732927393SChristoph Hellwig if (!first) 159832927393SChristoph Hellwig proc_put_char(&buffer, &left, ','); 159932927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_a, false); 1600f461d2dcSChristoph Hellwig if (bit_a != bit_b) { 160132927393SChristoph Hellwig proc_put_char(&buffer, &left, '-'); 160232927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_b, false); 1603f461d2dcSChristoph Hellwig } 1604f461d2dcSChristoph Hellwig 1605f461d2dcSChristoph Hellwig first = 0; bit_b++; 1606f461d2dcSChristoph Hellwig } 160732927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1608f461d2dcSChristoph Hellwig } 1609f461d2dcSChristoph Hellwig 1610f461d2dcSChristoph Hellwig if (!err) { 1611f461d2dcSChristoph Hellwig if (write) { 1612f461d2dcSChristoph Hellwig if (*ppos) 1613f461d2dcSChristoph Hellwig bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 1614f461d2dcSChristoph Hellwig else 1615f461d2dcSChristoph Hellwig bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 1616f461d2dcSChristoph Hellwig } 1617f461d2dcSChristoph Hellwig *lenp -= left; 1618f461d2dcSChristoph Hellwig *ppos += *lenp; 1619f461d2dcSChristoph Hellwig } 1620f461d2dcSChristoph Hellwig 1621f461d2dcSChristoph Hellwig bitmap_free(tmp_bitmap); 1622f461d2dcSChristoph Hellwig return err; 1623f461d2dcSChristoph Hellwig } 1624f461d2dcSChristoph Hellwig 1625f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */ 1626f461d2dcSChristoph Hellwig 1627f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 162832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1629f461d2dcSChristoph Hellwig { 1630f461d2dcSChristoph Hellwig return -ENOSYS; 1631f461d2dcSChristoph Hellwig } 1632f461d2dcSChristoph Hellwig 1633f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, 163432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1635f461d2dcSChristoph Hellwig { 1636f461d2dcSChristoph Hellwig return -ENOSYS; 1637f461d2dcSChristoph Hellwig } 1638f461d2dcSChristoph Hellwig 1639f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, 164032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1641f461d2dcSChristoph Hellwig { 1642f461d2dcSChristoph Hellwig return -ENOSYS; 1643f461d2dcSChristoph Hellwig } 1644f461d2dcSChristoph Hellwig 1645f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 164632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1647f461d2dcSChristoph Hellwig { 1648f461d2dcSChristoph Hellwig return -ENOSYS; 1649f461d2dcSChristoph Hellwig } 1650f461d2dcSChristoph Hellwig 1651f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 165232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1653f461d2dcSChristoph Hellwig { 1654f461d2dcSChristoph Hellwig return -ENOSYS; 1655f461d2dcSChristoph Hellwig } 1656f461d2dcSChristoph Hellwig 1657cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write, 1658cb944413SEric Dumazet void *buffer, size_t *lenp, loff_t *ppos) 1659cb944413SEric Dumazet { 1660cb944413SEric Dumazet return -ENOSYS; 1661cb944413SEric Dumazet } 1662cb944413SEric Dumazet 1663f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 166432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1665f461d2dcSChristoph Hellwig { 1666f461d2dcSChristoph Hellwig return -ENOSYS; 1667f461d2dcSChristoph Hellwig } 1668f461d2dcSChristoph Hellwig 1669f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 167032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1671f461d2dcSChristoph Hellwig { 1672f461d2dcSChristoph Hellwig return -ENOSYS; 1673f461d2dcSChristoph Hellwig } 1674f461d2dcSChristoph Hellwig 1675f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 167632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1677f461d2dcSChristoph Hellwig { 1678f461d2dcSChristoph Hellwig return -ENOSYS; 1679f461d2dcSChristoph Hellwig } 1680f461d2dcSChristoph Hellwig 1681f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 168232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1683f461d2dcSChristoph Hellwig { 1684f461d2dcSChristoph Hellwig return -ENOSYS; 1685f461d2dcSChristoph Hellwig } 1686f461d2dcSChristoph Hellwig 1687f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 168832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1689f461d2dcSChristoph Hellwig { 1690f461d2dcSChristoph Hellwig return -ENOSYS; 1691f461d2dcSChristoph Hellwig } 1692f461d2dcSChristoph Hellwig 1693f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 169432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1695f461d2dcSChristoph Hellwig { 1696f461d2dcSChristoph Hellwig return -ENOSYS; 1697f461d2dcSChristoph Hellwig } 1698f461d2dcSChristoph Hellwig 1699f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 1700f461d2dcSChristoph Hellwig 1701f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL) 1702f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write, 170332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1704f461d2dcSChristoph Hellwig { 1705f461d2dcSChristoph Hellwig struct static_key *key = (struct static_key *)table->data; 1706f461d2dcSChristoph Hellwig static DEFINE_MUTEX(static_key_mutex); 1707f461d2dcSChristoph Hellwig int val, ret; 1708f461d2dcSChristoph Hellwig struct ctl_table tmp = { 1709f461d2dcSChristoph Hellwig .data = &val, 1710f461d2dcSChristoph Hellwig .maxlen = sizeof(val), 1711f461d2dcSChristoph Hellwig .mode = table->mode, 1712f461d2dcSChristoph Hellwig .extra1 = SYSCTL_ZERO, 1713f461d2dcSChristoph Hellwig .extra2 = SYSCTL_ONE, 1714f461d2dcSChristoph Hellwig }; 1715f461d2dcSChristoph Hellwig 1716f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 1717f461d2dcSChristoph Hellwig return -EPERM; 1718f461d2dcSChristoph Hellwig 1719f461d2dcSChristoph Hellwig mutex_lock(&static_key_mutex); 1720f461d2dcSChristoph Hellwig val = static_key_enabled(key); 1721f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 1722f461d2dcSChristoph Hellwig if (write && !ret) { 1723f461d2dcSChristoph Hellwig if (val) 1724f461d2dcSChristoph Hellwig static_key_enable(key); 1725f461d2dcSChristoph Hellwig else 1726f461d2dcSChristoph Hellwig static_key_disable(key); 1727f461d2dcSChristoph Hellwig } 1728f461d2dcSChristoph Hellwig mutex_unlock(&static_key_mutex); 1729f461d2dcSChristoph Hellwig return ret; 1730f461d2dcSChristoph Hellwig } 1731f461d2dcSChristoph Hellwig 1732d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 17332bba22c5SMike Galbraith { 17342bba22c5SMike Galbraith .procname = "sched_child_runs_first", 17352bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 17362bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 17372bba22c5SMike Galbraith .mode = 0644, 17386d456111SEric W. Biederman .proc_handler = proc_dointvec, 17392bba22c5SMike Galbraith }, 17401d1c2509SPeter Zijlstra #ifdef CONFIG_SCHEDSTATS 17411d1c2509SPeter Zijlstra { 17421d1c2509SPeter Zijlstra .procname = "sched_schedstats", 17431d1c2509SPeter Zijlstra .data = NULL, 17441d1c2509SPeter Zijlstra .maxlen = sizeof(unsigned int), 17451d1c2509SPeter Zijlstra .mode = 0644, 17461d1c2509SPeter Zijlstra .proc_handler = sysctl_schedstats, 17471d1c2509SPeter Zijlstra .extra1 = SYSCTL_ZERO, 17481d1c2509SPeter Zijlstra .extra2 = SYSCTL_ONE, 17491d1c2509SPeter Zijlstra }, 17501d1c2509SPeter Zijlstra #endif /* CONFIG_SCHEDSTATS */ 17510cd7c741SPeter Zijlstra #ifdef CONFIG_TASK_DELAY_ACCT 17520cd7c741SPeter Zijlstra { 17530cd7c741SPeter Zijlstra .procname = "task_delayacct", 17540cd7c741SPeter Zijlstra .data = NULL, 17550cd7c741SPeter Zijlstra .maxlen = sizeof(unsigned int), 17560cd7c741SPeter Zijlstra .mode = 0644, 17570cd7c741SPeter Zijlstra .proc_handler = sysctl_delayacct, 17580cd7c741SPeter Zijlstra .extra1 = SYSCTL_ZERO, 17590cd7c741SPeter Zijlstra .extra2 = SYSCTL_ONE, 17600cd7c741SPeter Zijlstra }, 17610cd7c741SPeter Zijlstra #endif /* CONFIG_TASK_DELAY_ACCT */ 1762b7cc6ec7SMel Gorman #ifdef CONFIG_NUMA_BALANCING 17633a7053b3SMel Gorman { 176454a43d54SAndi Kleen .procname = "numa_balancing", 176554a43d54SAndi Kleen .data = NULL, /* filled in by handler */ 176654a43d54SAndi Kleen .maxlen = sizeof(unsigned int), 176754a43d54SAndi Kleen .mode = 0644, 176854a43d54SAndi Kleen .proc_handler = sysctl_numa_balancing, 1769eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1770eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 177154a43d54SAndi Kleen }, 1772cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */ 17731799e35dSIngo Molnar { 17749f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 17759f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 17769f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 17779f0c1e56SPeter Zijlstra .mode = 0644, 17786d456111SEric W. Biederman .proc_handler = sched_rt_handler, 17799f0c1e56SPeter Zijlstra }, 17809f0c1e56SPeter Zijlstra { 17819f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 17829f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 17839f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 17849f0c1e56SPeter Zijlstra .mode = 0644, 17856d456111SEric W. Biederman .proc_handler = sched_rt_handler, 17869f0c1e56SPeter Zijlstra }, 1787ce0dbbbbSClark Williams { 1788b4098bfcSPeter Zijlstra .procname = "sched_deadline_period_max_us", 1789b4098bfcSPeter Zijlstra .data = &sysctl_sched_dl_period_max, 1790b4098bfcSPeter Zijlstra .maxlen = sizeof(unsigned int), 1791b4098bfcSPeter Zijlstra .mode = 0644, 1792b4098bfcSPeter Zijlstra .proc_handler = proc_dointvec, 1793b4098bfcSPeter Zijlstra }, 1794b4098bfcSPeter Zijlstra { 1795b4098bfcSPeter Zijlstra .procname = "sched_deadline_period_min_us", 1796b4098bfcSPeter Zijlstra .data = &sysctl_sched_dl_period_min, 1797b4098bfcSPeter Zijlstra .maxlen = sizeof(unsigned int), 1798b4098bfcSPeter Zijlstra .mode = 0644, 1799b4098bfcSPeter Zijlstra .proc_handler = proc_dointvec, 1800b4098bfcSPeter Zijlstra }, 1801b4098bfcSPeter Zijlstra { 1802ce0dbbbbSClark Williams .procname = "sched_rr_timeslice_ms", 1803975e155eSShile Zhang .data = &sysctl_sched_rr_timeslice, 1804ce0dbbbbSClark Williams .maxlen = sizeof(int), 1805ce0dbbbbSClark Williams .mode = 0644, 1806ce0dbbbbSClark Williams .proc_handler = sched_rr_handler, 1807ce0dbbbbSClark Williams }, 1808e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK 1809e8f14172SPatrick Bellasi { 1810e8f14172SPatrick Bellasi .procname = "sched_util_clamp_min", 1811e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_min, 1812e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1813e8f14172SPatrick Bellasi .mode = 0644, 1814e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1815e8f14172SPatrick Bellasi }, 1816e8f14172SPatrick Bellasi { 1817e8f14172SPatrick Bellasi .procname = "sched_util_clamp_max", 1818e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_max, 1819e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1820e8f14172SPatrick Bellasi .mode = 0644, 1821e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1822e8f14172SPatrick Bellasi }, 182313685c4aSQais Yousef { 182413685c4aSQais Yousef .procname = "sched_util_clamp_min_rt_default", 182513685c4aSQais Yousef .data = &sysctl_sched_uclamp_util_min_rt_default, 182613685c4aSQais Yousef .maxlen = sizeof(unsigned int), 182713685c4aSQais Yousef .mode = 0644, 182813685c4aSQais Yousef .proc_handler = sysctl_sched_uclamp_handler, 182913685c4aSQais Yousef }, 1830e8f14172SPatrick Bellasi #endif 18315091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 18325091faa4SMike Galbraith { 18335091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 18345091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 18355091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 18365091faa4SMike Galbraith .mode = 0644, 18371747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 1838eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1839eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18405091faa4SMike Galbraith }, 18415091faa4SMike Galbraith #endif 1842ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 1843ec12cb7fSPaul Turner { 1844ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 1845ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 1846ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 1847ec12cb7fSPaul Turner .mode = 0644, 1848ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 1849eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 1850ec12cb7fSPaul Turner }, 1851ec12cb7fSPaul Turner #endif 18528d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) 18538d5d0cfbSQuentin Perret { 18548d5d0cfbSQuentin Perret .procname = "sched_energy_aware", 18558d5d0cfbSQuentin Perret .data = &sysctl_sched_energy_aware, 18568d5d0cfbSQuentin Perret .maxlen = sizeof(unsigned int), 18578d5d0cfbSQuentin Perret .mode = 0644, 18588d5d0cfbSQuentin Perret .proc_handler = sched_energy_aware_handler, 1859eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1860eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18618d5d0cfbSQuentin Perret }, 18628d5d0cfbSQuentin Perret #endif 1863f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 1864f20786ffSPeter Zijlstra { 1865f20786ffSPeter Zijlstra .procname = "prove_locking", 1866f20786ffSPeter Zijlstra .data = &prove_locking, 1867f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1868f20786ffSPeter Zijlstra .mode = 0644, 18696d456111SEric W. Biederman .proc_handler = proc_dointvec, 1870f20786ffSPeter Zijlstra }, 1871f20786ffSPeter Zijlstra #endif 1872f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 1873f20786ffSPeter Zijlstra { 1874f20786ffSPeter Zijlstra .procname = "lock_stat", 1875f20786ffSPeter Zijlstra .data = &lock_stat, 1876f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1877f20786ffSPeter Zijlstra .mode = 0644, 18786d456111SEric W. Biederman .proc_handler = proc_dointvec, 1879f20786ffSPeter Zijlstra }, 1880f20786ffSPeter Zijlstra #endif 188177e54a1fSIngo Molnar { 18821da177e4SLinus Torvalds .procname = "panic", 18831da177e4SLinus Torvalds .data = &panic_timeout, 18841da177e4SLinus Torvalds .maxlen = sizeof(int), 18851da177e4SLinus Torvalds .mode = 0644, 18866d456111SEric W. Biederman .proc_handler = proc_dointvec, 18871da177e4SLinus Torvalds }, 1888046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 18891da177e4SLinus Torvalds { 18901da177e4SLinus Torvalds .procname = "core_uses_pid", 18911da177e4SLinus Torvalds .data = &core_uses_pid, 18921da177e4SLinus Torvalds .maxlen = sizeof(int), 18931da177e4SLinus Torvalds .mode = 0644, 18946d456111SEric W. Biederman .proc_handler = proc_dointvec, 18951da177e4SLinus Torvalds }, 18961da177e4SLinus Torvalds { 18971da177e4SLinus Torvalds .procname = "core_pattern", 18981da177e4SLinus Torvalds .data = core_pattern, 189971ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 19001da177e4SLinus Torvalds .mode = 0644, 190154b50199SKees Cook .proc_handler = proc_dostring_coredump, 19021da177e4SLinus Torvalds }, 1903a293980cSNeil Horman { 1904a293980cSNeil Horman .procname = "core_pipe_limit", 1905a293980cSNeil Horman .data = &core_pipe_limit, 1906a293980cSNeil Horman .maxlen = sizeof(unsigned int), 1907a293980cSNeil Horman .mode = 0644, 19086d456111SEric W. Biederman .proc_handler = proc_dointvec, 1909a293980cSNeil Horman }, 1910046d662fSAlex Kelly #endif 191134f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 19121da177e4SLinus Torvalds { 19131da177e4SLinus Torvalds .procname = "tainted", 191425ddbb18SAndi Kleen .maxlen = sizeof(long), 191534f5a398STheodore Ts'o .mode = 0644, 19166d456111SEric W. Biederman .proc_handler = proc_taint, 19171da177e4SLinus Torvalds }, 1918f4aacea2SKees Cook { 1919f4aacea2SKees Cook .procname = "sysctl_writes_strict", 1920f4aacea2SKees Cook .data = &sysctl_writes_strict, 1921f4aacea2SKees Cook .maxlen = sizeof(int), 1922f4aacea2SKees Cook .mode = 0644, 1923f4aacea2SKees Cook .proc_handler = proc_dointvec_minmax, 1924f4aacea2SKees Cook .extra1 = &neg_one, 1925eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1926f4aacea2SKees Cook }, 192734f5a398STheodore Ts'o #endif 19289745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 19299745512cSArjan van de Ven { 19309745512cSArjan van de Ven .procname = "latencytop", 19319745512cSArjan van de Ven .data = &latencytop_enabled, 19329745512cSArjan van de Ven .maxlen = sizeof(int), 19339745512cSArjan van de Ven .mode = 0644, 1934cb251765SMel Gorman .proc_handler = sysctl_latencytop, 19359745512cSArjan van de Ven }, 19369745512cSArjan van de Ven #endif 19371da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 19381da177e4SLinus Torvalds { 19391da177e4SLinus Torvalds .procname = "real-root-dev", 19401da177e4SLinus Torvalds .data = &real_root_dev, 19411da177e4SLinus Torvalds .maxlen = sizeof(int), 19421da177e4SLinus Torvalds .mode = 0644, 19436d456111SEric W. Biederman .proc_handler = proc_dointvec, 19441da177e4SLinus Torvalds }, 19451da177e4SLinus Torvalds #endif 194645807a1dSIngo Molnar { 194745807a1dSIngo Molnar .procname = "print-fatal-signals", 194845807a1dSIngo Molnar .data = &print_fatal_signals, 194945807a1dSIngo Molnar .maxlen = sizeof(int), 195045807a1dSIngo Molnar .mode = 0644, 19516d456111SEric W. Biederman .proc_handler = proc_dointvec, 195245807a1dSIngo Molnar }, 195372c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 19541da177e4SLinus Torvalds { 19551da177e4SLinus Torvalds .procname = "reboot-cmd", 19561da177e4SLinus Torvalds .data = reboot_command, 19571da177e4SLinus Torvalds .maxlen = 256, 19581da177e4SLinus Torvalds .mode = 0644, 19596d456111SEric W. Biederman .proc_handler = proc_dostring, 19601da177e4SLinus Torvalds }, 19611da177e4SLinus Torvalds { 19621da177e4SLinus Torvalds .procname = "stop-a", 19631da177e4SLinus Torvalds .data = &stop_a_enabled, 19641da177e4SLinus Torvalds .maxlen = sizeof (int), 19651da177e4SLinus Torvalds .mode = 0644, 19666d456111SEric W. Biederman .proc_handler = proc_dointvec, 19671da177e4SLinus Torvalds }, 19681da177e4SLinus Torvalds { 19691da177e4SLinus Torvalds .procname = "scons-poweroff", 19701da177e4SLinus Torvalds .data = &scons_pwroff, 19711da177e4SLinus Torvalds .maxlen = sizeof (int), 19721da177e4SLinus Torvalds .mode = 0644, 19736d456111SEric W. Biederman .proc_handler = proc_dointvec, 19741da177e4SLinus Torvalds }, 19751da177e4SLinus Torvalds #endif 19760871420fSDavid S. Miller #ifdef CONFIG_SPARC64 19770871420fSDavid S. Miller { 19780871420fSDavid S. Miller .procname = "tsb-ratio", 19790871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 19800871420fSDavid S. Miller .maxlen = sizeof (int), 19810871420fSDavid S. Miller .mode = 0644, 19826d456111SEric W. Biederman .proc_handler = proc_dointvec, 19830871420fSDavid S. Miller }, 19840871420fSDavid S. Miller #endif 1985b67114dbSHelge Deller #ifdef CONFIG_PARISC 19861da177e4SLinus Torvalds { 19871da177e4SLinus Torvalds .procname = "soft-power", 19881da177e4SLinus Torvalds .data = &pwrsw_enabled, 19891da177e4SLinus Torvalds .maxlen = sizeof (int), 19901da177e4SLinus Torvalds .mode = 0644, 19916d456111SEric W. Biederman .proc_handler = proc_dointvec, 19921da177e4SLinus Torvalds }, 1993bf14e3b9SVineet Gupta #endif 1994bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW 19951da177e4SLinus Torvalds { 19961da177e4SLinus Torvalds .procname = "unaligned-trap", 19971da177e4SLinus Torvalds .data = &unaligned_enabled, 19981da177e4SLinus Torvalds .maxlen = sizeof (int), 19991da177e4SLinus Torvalds .mode = 0644, 20006d456111SEric W. Biederman .proc_handler = proc_dointvec, 20011da177e4SLinus Torvalds }, 20021da177e4SLinus Torvalds #endif 20031da177e4SLinus Torvalds { 20041da177e4SLinus Torvalds .procname = "ctrl-alt-del", 20051da177e4SLinus Torvalds .data = &C_A_D, 20061da177e4SLinus Torvalds .maxlen = sizeof(int), 20071da177e4SLinus Torvalds .mode = 0644, 20086d456111SEric W. Biederman .proc_handler = proc_dointvec, 20091da177e4SLinus Torvalds }, 2010606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 2011b0fc494fSSteven Rostedt { 2012b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 2013b0fc494fSSteven Rostedt .data = &ftrace_enabled, 2014b0fc494fSSteven Rostedt .maxlen = sizeof(int), 2015b0fc494fSSteven Rostedt .mode = 0644, 20166d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 2017b0fc494fSSteven Rostedt }, 2018b0fc494fSSteven Rostedt #endif 2019f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 2020f38f1d2aSSteven Rostedt { 2021f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 2022f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 2023f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 2024f38f1d2aSSteven Rostedt .mode = 0644, 20256d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 2026f38f1d2aSSteven Rostedt }, 2027f38f1d2aSSteven Rostedt #endif 2028944ac425SSteven Rostedt #ifdef CONFIG_TRACING 2029944ac425SSteven Rostedt { 20303299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 2031944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 2032944ac425SSteven Rostedt .maxlen = sizeof(int), 2033944ac425SSteven Rostedt .mode = 0644, 20346d456111SEric W. Biederman .proc_handler = proc_dointvec, 2035944ac425SSteven Rostedt }, 2036de7edd31SSteven Rostedt (Red Hat) { 2037de7edd31SSteven Rostedt (Red Hat) .procname = "traceoff_on_warning", 2038de7edd31SSteven Rostedt (Red Hat) .data = &__disable_trace_on_warning, 2039de7edd31SSteven Rostedt (Red Hat) .maxlen = sizeof(__disable_trace_on_warning), 2040de7edd31SSteven Rostedt (Red Hat) .mode = 0644, 2041de7edd31SSteven Rostedt (Red Hat) .proc_handler = proc_dointvec, 2042de7edd31SSteven Rostedt (Red Hat) }, 20430daa2302SSteven Rostedt (Red Hat) { 20440daa2302SSteven Rostedt (Red Hat) .procname = "tracepoint_printk", 20450daa2302SSteven Rostedt (Red Hat) .data = &tracepoint_printk, 20460daa2302SSteven Rostedt (Red Hat) .maxlen = sizeof(tracepoint_printk), 20470daa2302SSteven Rostedt (Red Hat) .mode = 0644, 204842391745SSteven Rostedt (Red Hat) .proc_handler = tracepoint_printk_sysctl, 20490daa2302SSteven Rostedt (Red Hat) }, 2050944ac425SSteven Rostedt #endif 20512965faa5SDave Young #ifdef CONFIG_KEXEC_CORE 20527984754bSKees Cook { 20537984754bSKees Cook .procname = "kexec_load_disabled", 20547984754bSKees Cook .data = &kexec_load_disabled, 20557984754bSKees Cook .maxlen = sizeof(int), 20567984754bSKees Cook .mode = 0644, 20577984754bSKees Cook /* only handle a transition from default "0" to "1" */ 20587984754bSKees Cook .proc_handler = proc_dointvec_minmax, 2059eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2060eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20617984754bSKees Cook }, 20627984754bSKees Cook #endif 2063a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 20641da177e4SLinus Torvalds { 20651da177e4SLinus Torvalds .procname = "modprobe", 20661da177e4SLinus Torvalds .data = &modprobe_path, 20671da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 20681da177e4SLinus Torvalds .mode = 0644, 20696d456111SEric W. Biederman .proc_handler = proc_dostring, 20701da177e4SLinus Torvalds }, 20713d43321bSKees Cook { 20723d43321bSKees Cook .procname = "modules_disabled", 20733d43321bSKees Cook .data = &modules_disabled, 20743d43321bSKees Cook .maxlen = sizeof(int), 20753d43321bSKees Cook .mode = 0644, 20763d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 20776d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2078eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2079eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20803d43321bSKees Cook }, 20811da177e4SLinus Torvalds #endif 208286d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER 20831da177e4SLinus Torvalds { 20841da177e4SLinus Torvalds .procname = "hotplug", 2085312c004dSKay Sievers .data = &uevent_helper, 2086312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 20871da177e4SLinus Torvalds .mode = 0644, 20886d456111SEric W. Biederman .proc_handler = proc_dostring, 20891da177e4SLinus Torvalds }, 209086d56134SMichael Marineau #endif 20911da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 20921da177e4SLinus Torvalds { 20931da177e4SLinus Torvalds .procname = "sg-big-buff", 20941da177e4SLinus Torvalds .data = &sg_big_buff, 20951da177e4SLinus Torvalds .maxlen = sizeof (int), 20961da177e4SLinus Torvalds .mode = 0444, 20976d456111SEric W. Biederman .proc_handler = proc_dointvec, 20981da177e4SLinus Torvalds }, 20991da177e4SLinus Torvalds #endif 21001da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 21011da177e4SLinus Torvalds { 21021da177e4SLinus Torvalds .procname = "acct", 21031da177e4SLinus Torvalds .data = &acct_parm, 21041da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 21051da177e4SLinus Torvalds .mode = 0644, 21066d456111SEric W. Biederman .proc_handler = proc_dointvec, 21071da177e4SLinus Torvalds }, 21081da177e4SLinus Torvalds #endif 21091da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 21101da177e4SLinus Torvalds { 21111da177e4SLinus Torvalds .procname = "sysrq", 2112eaee4172SDmitry Safonov .data = NULL, 21131da177e4SLinus Torvalds .maxlen = sizeof (int), 21141da177e4SLinus Torvalds .mode = 0644, 211597f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 21161da177e4SLinus Torvalds }, 21171da177e4SLinus Torvalds #endif 2118d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 21191da177e4SLinus Torvalds { 21201da177e4SLinus Torvalds .procname = "cad_pid", 21219ec52099SCedric Le Goater .data = NULL, 21221da177e4SLinus Torvalds .maxlen = sizeof (int), 21231da177e4SLinus Torvalds .mode = 0600, 21246d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 21251da177e4SLinus Torvalds }, 2126d6f8ff73SRandy Dunlap #endif 21271da177e4SLinus Torvalds { 21281da177e4SLinus Torvalds .procname = "threads-max", 212916db3d3fSHeinrich Schuchardt .data = NULL, 21301da177e4SLinus Torvalds .maxlen = sizeof(int), 21311da177e4SLinus Torvalds .mode = 0644, 213216db3d3fSHeinrich Schuchardt .proc_handler = sysctl_max_threads, 21331da177e4SLinus Torvalds }, 21341da177e4SLinus Torvalds { 21351da177e4SLinus Torvalds .procname = "random", 21361da177e4SLinus Torvalds .mode = 0555, 21371da177e4SLinus Torvalds .child = random_table, 21381da177e4SLinus Torvalds }, 21391da177e4SLinus Torvalds { 214017f60a7dSEric Paris .procname = "usermodehelper", 214117f60a7dSEric Paris .mode = 0555, 214217f60a7dSEric Paris .child = usermodehelper_table, 214317f60a7dSEric Paris }, 2144ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER 2145ceb18132SLuis R. Rodriguez { 2146ceb18132SLuis R. Rodriguez .procname = "firmware_config", 2147ceb18132SLuis R. Rodriguez .mode = 0555, 2148ceb18132SLuis R. Rodriguez .child = firmware_config_table, 2149ceb18132SLuis R. Rodriguez }, 2150ceb18132SLuis R. Rodriguez #endif 215117f60a7dSEric Paris { 21521da177e4SLinus Torvalds .procname = "overflowuid", 21531da177e4SLinus Torvalds .data = &overflowuid, 21541da177e4SLinus Torvalds .maxlen = sizeof(int), 21551da177e4SLinus Torvalds .mode = 0644, 21566d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21571da177e4SLinus Torvalds .extra1 = &minolduid, 21581da177e4SLinus Torvalds .extra2 = &maxolduid, 21591da177e4SLinus Torvalds }, 21601da177e4SLinus Torvalds { 21611da177e4SLinus Torvalds .procname = "overflowgid", 21621da177e4SLinus Torvalds .data = &overflowgid, 21631da177e4SLinus Torvalds .maxlen = sizeof(int), 21641da177e4SLinus Torvalds .mode = 0644, 21656d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21661da177e4SLinus Torvalds .extra1 = &minolduid, 21671da177e4SLinus Torvalds .extra2 = &maxolduid, 21681da177e4SLinus Torvalds }, 2169347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 21701da177e4SLinus Torvalds { 21711da177e4SLinus Torvalds .procname = "userprocess_debug", 2172ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 21731da177e4SLinus Torvalds .maxlen = sizeof(int), 21741da177e4SLinus Torvalds .mode = 0644, 21756d456111SEric W. Biederman .proc_handler = proc_dointvec, 21761da177e4SLinus Torvalds }, 21771da177e4SLinus Torvalds #endif 217860c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP 217960c958d8SGuilherme G. Piccoli { 218060c958d8SGuilherme G. Piccoli .procname = "oops_all_cpu_backtrace", 218160c958d8SGuilherme G. Piccoli .data = &sysctl_oops_all_cpu_backtrace, 218260c958d8SGuilherme G. Piccoli .maxlen = sizeof(int), 218360c958d8SGuilherme G. Piccoli .mode = 0644, 218460c958d8SGuilherme G. Piccoli .proc_handler = proc_dointvec_minmax, 218560c958d8SGuilherme G. Piccoli .extra1 = SYSCTL_ZERO, 218660c958d8SGuilherme G. Piccoli .extra2 = SYSCTL_ONE, 218760c958d8SGuilherme G. Piccoli }, 218860c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */ 21891da177e4SLinus Torvalds { 21901da177e4SLinus Torvalds .procname = "pid_max", 21911da177e4SLinus Torvalds .data = &pid_max, 21921da177e4SLinus Torvalds .maxlen = sizeof (int), 21931da177e4SLinus Torvalds .mode = 0644, 21946d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21951da177e4SLinus Torvalds .extra1 = &pid_max_min, 21961da177e4SLinus Torvalds .extra2 = &pid_max_max, 21971da177e4SLinus Torvalds }, 21981da177e4SLinus Torvalds { 21991da177e4SLinus Torvalds .procname = "panic_on_oops", 22001da177e4SLinus Torvalds .data = &panic_on_oops, 22011da177e4SLinus Torvalds .maxlen = sizeof(int), 22021da177e4SLinus Torvalds .mode = 0644, 22036d456111SEric W. Biederman .proc_handler = proc_dointvec, 22041da177e4SLinus Torvalds }, 220581c9d43fSFeng Tang { 220681c9d43fSFeng Tang .procname = "panic_print", 220781c9d43fSFeng Tang .data = &panic_print, 220881c9d43fSFeng Tang .maxlen = sizeof(unsigned long), 220981c9d43fSFeng Tang .mode = 0644, 221081c9d43fSFeng Tang .proc_handler = proc_doulongvec_minmax, 221181c9d43fSFeng Tang }, 22127ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 22137ef3d2fdSJoe Perches { 22147ef3d2fdSJoe Perches .procname = "printk", 22157ef3d2fdSJoe Perches .data = &console_loglevel, 22167ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 22177ef3d2fdSJoe Perches .mode = 0644, 22186d456111SEric W. Biederman .proc_handler = proc_dointvec, 22197ef3d2fdSJoe Perches }, 22201da177e4SLinus Torvalds { 22211da177e4SLinus Torvalds .procname = "printk_ratelimit", 2222717115e1SDave Young .data = &printk_ratelimit_state.interval, 22231da177e4SLinus Torvalds .maxlen = sizeof(int), 22241da177e4SLinus Torvalds .mode = 0644, 22256d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 22261da177e4SLinus Torvalds }, 22271da177e4SLinus Torvalds { 22281da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 2229717115e1SDave Young .data = &printk_ratelimit_state.burst, 22301da177e4SLinus Torvalds .maxlen = sizeof(int), 22311da177e4SLinus Torvalds .mode = 0644, 22326d456111SEric W. Biederman .proc_handler = proc_dointvec, 22331da177e4SLinus Torvalds }, 2234af91322eSDave Young { 2235af91322eSDave Young .procname = "printk_delay", 2236af91322eSDave Young .data = &printk_delay_msec, 2237af91322eSDave Young .maxlen = sizeof(int), 2238af91322eSDave Young .mode = 0644, 22396d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2240eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2241af91322eSDave Young .extra2 = &ten_thousand, 2242af91322eSDave Young }, 22431da177e4SLinus Torvalds { 2244750afe7bSBorislav Petkov .procname = "printk_devkmsg", 2245750afe7bSBorislav Petkov .data = devkmsg_log_str, 2246750afe7bSBorislav Petkov .maxlen = DEVKMSG_STR_MAX_SIZE, 2247750afe7bSBorislav Petkov .mode = 0644, 2248750afe7bSBorislav Petkov .proc_handler = devkmsg_sysctl_set_loglvl, 2249750afe7bSBorislav Petkov }, 2250750afe7bSBorislav Petkov { 2251eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 2252eaf06b24SDan Rosenberg .data = &dmesg_restrict, 2253eaf06b24SDan Rosenberg .maxlen = sizeof(int), 2254eaf06b24SDan Rosenberg .mode = 0644, 2255620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2256eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2257eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2258eaf06b24SDan Rosenberg }, 2259455cd5abSDan Rosenberg { 2260455cd5abSDan Rosenberg .procname = "kptr_restrict", 2261455cd5abSDan Rosenberg .data = &kptr_restrict, 2262455cd5abSDan Rosenberg .maxlen = sizeof(int), 2263455cd5abSDan Rosenberg .mode = 0644, 2264620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2265eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2266455cd5abSDan Rosenberg .extra2 = &two, 2267455cd5abSDan Rosenberg }, 2268df6e61d4SJoe Perches #endif 2269eaf06b24SDan Rosenberg { 22701da177e4SLinus Torvalds .procname = "ngroups_max", 22711da177e4SLinus Torvalds .data = &ngroups_max, 22721da177e4SLinus Torvalds .maxlen = sizeof (int), 22731da177e4SLinus Torvalds .mode = 0444, 22746d456111SEric W. Biederman .proc_handler = proc_dointvec, 22751da177e4SLinus Torvalds }, 227673efc039SDan Ballard { 227773efc039SDan Ballard .procname = "cap_last_cap", 227873efc039SDan Ballard .data = (void *)&cap_last_cap, 227973efc039SDan Ballard .maxlen = sizeof(int), 228073efc039SDan Ballard .mode = 0444, 228173efc039SDan Ballard .proc_handler = proc_dointvec, 228273efc039SDan Ballard }, 228358687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 2284504d7cf1SDon Zickus { 228558687acbSDon Zickus .procname = "watchdog", 22863c00ea82SFrederic Weisbecker .data = &watchdog_user_enabled, 2287504d7cf1SDon Zickus .maxlen = sizeof(int), 2288504d7cf1SDon Zickus .mode = 0644, 2289195daf66SUlrich Obergfell .proc_handler = proc_watchdog, 2290eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2291eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 229258687acbSDon Zickus }, 229358687acbSDon Zickus { 229458687acbSDon Zickus .procname = "watchdog_thresh", 2295586692a5SMandeep Singh Baines .data = &watchdog_thresh, 229658687acbSDon Zickus .maxlen = sizeof(int), 229758687acbSDon Zickus .mode = 0644, 2298195daf66SUlrich Obergfell .proc_handler = proc_watchdog_thresh, 2299eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 230058687acbSDon Zickus .extra2 = &sixty, 2301504d7cf1SDon Zickus }, 23022508ce18SDon Zickus { 2303195daf66SUlrich Obergfell .procname = "nmi_watchdog", 23047feeb9cdSThomas Gleixner .data = &nmi_watchdog_user_enabled, 2305195daf66SUlrich Obergfell .maxlen = sizeof(int), 230651d4052bSThomas Gleixner .mode = NMI_WATCHDOG_SYSCTL_PERM, 2307195daf66SUlrich Obergfell .proc_handler = proc_nmi_watchdog, 2308eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2309eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2310195daf66SUlrich Obergfell }, 2311195daf66SUlrich Obergfell { 231205a4a952SNicholas Piggin .procname = "watchdog_cpumask", 231305a4a952SNicholas Piggin .data = &watchdog_cpumask_bits, 231405a4a952SNicholas Piggin .maxlen = NR_CPUS, 231505a4a952SNicholas Piggin .mode = 0644, 231605a4a952SNicholas Piggin .proc_handler = proc_watchdog_cpumask, 231705a4a952SNicholas Piggin }, 231805a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR 231905a4a952SNicholas Piggin { 2320195daf66SUlrich Obergfell .procname = "soft_watchdog", 23217feeb9cdSThomas Gleixner .data = &soft_watchdog_user_enabled, 2322195daf66SUlrich Obergfell .maxlen = sizeof(int), 2323195daf66SUlrich Obergfell .mode = 0644, 2324195daf66SUlrich Obergfell .proc_handler = proc_soft_watchdog, 2325eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2326eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2327195daf66SUlrich Obergfell }, 2328195daf66SUlrich Obergfell { 23292508ce18SDon Zickus .procname = "softlockup_panic", 23302508ce18SDon Zickus .data = &softlockup_panic, 23312508ce18SDon Zickus .maxlen = sizeof(int), 23322508ce18SDon Zickus .mode = 0644, 23332508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 2334eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2335eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 23362508ce18SDon Zickus }, 2337ed235875SAaron Tomlin #ifdef CONFIG_SMP 2338ed235875SAaron Tomlin { 2339ed235875SAaron Tomlin .procname = "softlockup_all_cpu_backtrace", 2340ed235875SAaron Tomlin .data = &sysctl_softlockup_all_cpu_backtrace, 2341ed235875SAaron Tomlin .maxlen = sizeof(int), 2342ed235875SAaron Tomlin .mode = 0644, 2343ed235875SAaron Tomlin .proc_handler = proc_dointvec_minmax, 2344eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2345eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2346ed235875SAaron Tomlin }, 234705a4a952SNicholas Piggin #endif /* CONFIG_SMP */ 234805a4a952SNicholas Piggin #endif 234905a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR 235005a4a952SNicholas Piggin { 235105a4a952SNicholas Piggin .procname = "hardlockup_panic", 235205a4a952SNicholas Piggin .data = &hardlockup_panic, 235305a4a952SNicholas Piggin .maxlen = sizeof(int), 235405a4a952SNicholas Piggin .mode = 0644, 235505a4a952SNicholas Piggin .proc_handler = proc_dointvec_minmax, 2356eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2357eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 235805a4a952SNicholas Piggin }, 235905a4a952SNicholas Piggin #ifdef CONFIG_SMP 236055537871SJiri Kosina { 236155537871SJiri Kosina .procname = "hardlockup_all_cpu_backtrace", 236255537871SJiri Kosina .data = &sysctl_hardlockup_all_cpu_backtrace, 236355537871SJiri Kosina .maxlen = sizeof(int), 236455537871SJiri Kosina .mode = 0644, 236555537871SJiri Kosina .proc_handler = proc_dointvec_minmax, 2366eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2367eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 236855537871SJiri Kosina }, 2369ed235875SAaron Tomlin #endif /* CONFIG_SMP */ 23705dc30558SDon Zickus #endif 237105a4a952SNicholas Piggin #endif 237205a4a952SNicholas Piggin 23735dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 23745dc30558SDon Zickus { 23755dc30558SDon Zickus .procname = "unknown_nmi_panic", 23765dc30558SDon Zickus .data = &unknown_nmi_panic, 23775dc30558SDon Zickus .maxlen = sizeof (int), 23785dc30558SDon Zickus .mode = 0644, 23795dc30558SDon Zickus .proc_handler = proc_dointvec, 23805dc30558SDon Zickus }, 2381504d7cf1SDon Zickus #endif 2382b6522fa4SXiaoming Ni 2383b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \ 2384b6522fa4SXiaoming Ni defined(CONFIG_DEBUG_STACKOVERFLOW) 2385b6522fa4SXiaoming Ni { 2386b6522fa4SXiaoming Ni .procname = "panic_on_stackoverflow", 2387b6522fa4SXiaoming Ni .data = &sysctl_panic_on_stackoverflow, 2388b6522fa4SXiaoming Ni .maxlen = sizeof(int), 2389b6522fa4SXiaoming Ni .mode = 0644, 2390b6522fa4SXiaoming Ni .proc_handler = proc_dointvec, 2391b6522fa4SXiaoming Ni }, 2392b6522fa4SXiaoming Ni #endif 23931da177e4SLinus Torvalds #if defined(CONFIG_X86) 23941da177e4SLinus Torvalds { 23958da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 23968da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 23978da5addaSDon Zickus .maxlen = sizeof(int), 23988da5addaSDon Zickus .mode = 0644, 23996d456111SEric W. Biederman .proc_handler = proc_dointvec, 24008da5addaSDon Zickus }, 24018da5addaSDon Zickus { 24025211a242SKurt Garloff .procname = "panic_on_io_nmi", 24035211a242SKurt Garloff .data = &panic_on_io_nmi, 24045211a242SKurt Garloff .maxlen = sizeof(int), 24055211a242SKurt Garloff .mode = 0644, 24066d456111SEric W. Biederman .proc_handler = proc_dointvec, 24075211a242SKurt Garloff }, 24085211a242SKurt Garloff { 24091da177e4SLinus Torvalds .procname = "bootloader_type", 24101da177e4SLinus Torvalds .data = &bootloader_type, 24111da177e4SLinus Torvalds .maxlen = sizeof (int), 24121da177e4SLinus Torvalds .mode = 0444, 24136d456111SEric W. Biederman .proc_handler = proc_dointvec, 24141da177e4SLinus Torvalds }, 24150741f4d2SChuck Ebbert { 24165031296cSH. Peter Anvin .procname = "bootloader_version", 24175031296cSH. Peter Anvin .data = &bootloader_version, 24185031296cSH. Peter Anvin .maxlen = sizeof (int), 24195031296cSH. Peter Anvin .mode = 0444, 24206d456111SEric W. Biederman .proc_handler = proc_dointvec, 24215031296cSH. Peter Anvin }, 24225031296cSH. Peter Anvin { 24236e7c4025SIngo Molnar .procname = "io_delay_type", 24246e7c4025SIngo Molnar .data = &io_delay_type, 24256e7c4025SIngo Molnar .maxlen = sizeof(int), 24266e7c4025SIngo Molnar .mode = 0644, 24276d456111SEric W. Biederman .proc_handler = proc_dointvec, 24286e7c4025SIngo Molnar }, 24291da177e4SLinus Torvalds #endif 24307a9166e3SLuke Yang #if defined(CONFIG_MMU) 24311da177e4SLinus Torvalds { 24321da177e4SLinus Torvalds .procname = "randomize_va_space", 24331da177e4SLinus Torvalds .data = &randomize_va_space, 24341da177e4SLinus Torvalds .maxlen = sizeof(int), 24351da177e4SLinus Torvalds .mode = 0644, 24366d456111SEric W. Biederman .proc_handler = proc_dointvec, 24371da177e4SLinus Torvalds }, 24387a9166e3SLuke Yang #endif 24390152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 2440951f22d5SMartin Schwidefsky { 2441951f22d5SMartin Schwidefsky .procname = "spin_retry", 2442951f22d5SMartin Schwidefsky .data = &spin_retry, 2443951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 2444951f22d5SMartin Schwidefsky .mode = 0644, 24456d456111SEric W. Biederman .proc_handler = proc_dointvec, 2446951f22d5SMartin Schwidefsky }, 2447951f22d5SMartin Schwidefsky #endif 2448673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 2449c255d844SPavel Machek { 2450c255d844SPavel Machek .procname = "acpi_video_flags", 245177afcf78SPavel Machek .data = &acpi_realmode_flags, 2452c255d844SPavel Machek .maxlen = sizeof (unsigned long), 2453c255d844SPavel Machek .mode = 0644, 24546d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 2455c255d844SPavel Machek }, 2456c255d844SPavel Machek #endif 2457b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN 2458d2b176edSJes Sorensen { 2459d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 2460d2b176edSJes Sorensen .data = &no_unaligned_warning, 2461d2b176edSJes Sorensen .maxlen = sizeof (int), 2462d2b176edSJes Sorensen .mode = 0644, 24636d456111SEric W. Biederman .proc_handler = proc_dointvec, 2464d2b176edSJes Sorensen }, 2465b6fca725SVineet Gupta #endif 2466b6fca725SVineet Gupta #ifdef CONFIG_IA64 246788fc241fSDoug Chapman { 246888fc241fSDoug Chapman .procname = "unaligned-dump-stack", 246988fc241fSDoug Chapman .data = &unaligned_dump_stack, 247088fc241fSDoug Chapman .maxlen = sizeof (int), 247188fc241fSDoug Chapman .mode = 0644, 24726d456111SEric W. Biederman .proc_handler = proc_dointvec, 247388fc241fSDoug Chapman }, 2474d2b176edSJes Sorensen #endif 2475e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 24760ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP 24770ec9dc9bSGuilherme G. Piccoli { 24780ec9dc9bSGuilherme G. Piccoli .procname = "hung_task_all_cpu_backtrace", 24790ec9dc9bSGuilherme G. Piccoli .data = &sysctl_hung_task_all_cpu_backtrace, 24800ec9dc9bSGuilherme G. Piccoli .maxlen = sizeof(int), 24810ec9dc9bSGuilherme G. Piccoli .mode = 0644, 24820ec9dc9bSGuilherme G. Piccoli .proc_handler = proc_dointvec_minmax, 24830ec9dc9bSGuilherme G. Piccoli .extra1 = SYSCTL_ZERO, 24840ec9dc9bSGuilherme G. Piccoli .extra2 = SYSCTL_ONE, 24850ec9dc9bSGuilherme G. Piccoli }, 24860ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */ 2487e162b39aSMandeep Singh Baines { 2488e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 2489e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 2490e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 2491e162b39aSMandeep Singh Baines .mode = 0644, 24926d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2493eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2494eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2495e162b39aSMandeep Singh Baines }, 249682a1fcb9SIngo Molnar { 249782a1fcb9SIngo Molnar .procname = "hung_task_check_count", 249882a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 2499cd64647fSLi Zefan .maxlen = sizeof(int), 250082a1fcb9SIngo Molnar .mode = 0644, 2501cd64647fSLi Zefan .proc_handler = proc_dointvec_minmax, 2502eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 250382a1fcb9SIngo Molnar }, 250482a1fcb9SIngo Molnar { 250582a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 250682a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 250790739081SIngo Molnar .maxlen = sizeof(unsigned long), 250882a1fcb9SIngo Molnar .mode = 0644, 25096d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 251080df2847SLiu Hua .extra2 = &hung_task_timeout_max, 251182a1fcb9SIngo Molnar }, 251282a1fcb9SIngo Molnar { 2513a2e51445SDmitry Vyukov .procname = "hung_task_check_interval_secs", 2514a2e51445SDmitry Vyukov .data = &sysctl_hung_task_check_interval_secs, 2515a2e51445SDmitry Vyukov .maxlen = sizeof(unsigned long), 2516a2e51445SDmitry Vyukov .mode = 0644, 2517a2e51445SDmitry Vyukov .proc_handler = proc_dohung_task_timeout_secs, 2518a2e51445SDmitry Vyukov .extra2 = &hung_task_timeout_max, 2519a2e51445SDmitry Vyukov }, 2520a2e51445SDmitry Vyukov { 252182a1fcb9SIngo Molnar .procname = "hung_task_warnings", 252282a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 2523270750dbSAaron Tomlin .maxlen = sizeof(int), 252482a1fcb9SIngo Molnar .mode = 0644, 2525270750dbSAaron Tomlin .proc_handler = proc_dointvec_minmax, 2526270750dbSAaron Tomlin .extra1 = &neg_one, 252782a1fcb9SIngo Molnar }, 2528c4f3b63fSRavikiran G Thirumalai #endif 252923f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 253023f78d4aSIngo Molnar { 253123f78d4aSIngo Molnar .procname = "max_lock_depth", 253223f78d4aSIngo Molnar .data = &max_lock_depth, 253323f78d4aSIngo Molnar .maxlen = sizeof(int), 253423f78d4aSIngo Molnar .mode = 0644, 25356d456111SEric W. Biederman .proc_handler = proc_dointvec, 253623f78d4aSIngo Molnar }, 253723f78d4aSIngo Molnar #endif 253810a0a8d4SJeremy Fitzhardinge { 253910a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 254010a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 254110a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 254210a0a8d4SJeremy Fitzhardinge .mode = 0644, 25436d456111SEric W. Biederman .proc_handler = proc_dostring, 254410a0a8d4SJeremy Fitzhardinge }, 25450b77f5bfSDavid Howells #ifdef CONFIG_KEYS 25460b77f5bfSDavid Howells { 25470b77f5bfSDavid Howells .procname = "keys", 25480b77f5bfSDavid Howells .mode = 0555, 25490b77f5bfSDavid Howells .child = key_sysctls, 25500b77f5bfSDavid Howells }, 25510b77f5bfSDavid Howells #endif 2552cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 2553aa4a2218SVince Weaver /* 2554aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 2555aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 2556aa4a2218SVince Weaver * 2557aa4a2218SVince Weaver * So it's an ABI, do not remove! 2558aa4a2218SVince Weaver */ 25591ccd1549SPeter Zijlstra { 2560cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 2561cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 2562cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 25631ccd1549SPeter Zijlstra .mode = 0644, 25646d456111SEric W. Biederman .proc_handler = proc_dointvec, 25651ccd1549SPeter Zijlstra }, 2566c5078f78SPeter Zijlstra { 2567cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 2568cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 2569cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 2570c5078f78SPeter Zijlstra .mode = 0644, 25716d456111SEric W. Biederman .proc_handler = proc_dointvec, 2572c5078f78SPeter Zijlstra }, 2573a78ac325SPeter Zijlstra { 2574cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 2575cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 2576cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 2577a78ac325SPeter Zijlstra .mode = 0644, 2578163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 2579eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2580a78ac325SPeter Zijlstra }, 258114c63f17SDave Hansen { 258214c63f17SDave Hansen .procname = "perf_cpu_time_max_percent", 258314c63f17SDave Hansen .data = &sysctl_perf_cpu_time_max_percent, 258414c63f17SDave Hansen .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), 258514c63f17SDave Hansen .mode = 0644, 258614c63f17SDave Hansen .proc_handler = perf_cpu_time_max_percent_handler, 2587eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 258814c63f17SDave Hansen .extra2 = &one_hundred, 258914c63f17SDave Hansen }, 2590c5dfd78eSArnaldo Carvalho de Melo { 2591c5dfd78eSArnaldo Carvalho de Melo .procname = "perf_event_max_stack", 2592a831100aSArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_stack, 2593c5dfd78eSArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_stack), 2594c5dfd78eSArnaldo Carvalho de Melo .mode = 0644, 2595c5dfd78eSArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2596eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2597c5dfd78eSArnaldo Carvalho de Melo .extra2 = &six_hundred_forty_kb, 2598c5dfd78eSArnaldo Carvalho de Melo }, 2599c85b0334SArnaldo Carvalho de Melo { 2600c85b0334SArnaldo Carvalho de Melo .procname = "perf_event_max_contexts_per_stack", 2601c85b0334SArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_contexts_per_stack, 2602c85b0334SArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), 2603c85b0334SArnaldo Carvalho de Melo .mode = 0644, 2604c85b0334SArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2605eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2606c85b0334SArnaldo Carvalho de Melo .extra2 = &one_thousand, 2607c85b0334SArnaldo Carvalho de Melo }, 26081ccd1549SPeter Zijlstra #endif 26099e3961a0SPrarit Bhargava { 26109e3961a0SPrarit Bhargava .procname = "panic_on_warn", 26119e3961a0SPrarit Bhargava .data = &panic_on_warn, 26129e3961a0SPrarit Bhargava .maxlen = sizeof(int), 26139e3961a0SPrarit Bhargava .mode = 0644, 26149e3961a0SPrarit Bhargava .proc_handler = proc_dointvec_minmax, 2615eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2616eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 26179e3961a0SPrarit Bhargava }, 2618bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 2619bc7a34b8SThomas Gleixner { 2620bc7a34b8SThomas Gleixner .procname = "timer_migration", 2621bc7a34b8SThomas Gleixner .data = &sysctl_timer_migration, 2622bc7a34b8SThomas Gleixner .maxlen = sizeof(unsigned int), 2623bc7a34b8SThomas Gleixner .mode = 0644, 2624bc7a34b8SThomas Gleixner .proc_handler = timer_migration_handler, 2625eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2626eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2627bc7a34b8SThomas Gleixner }, 2628bc7a34b8SThomas Gleixner #endif 26291be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL 26301be7f75dSAlexei Starovoitov { 26311be7f75dSAlexei Starovoitov .procname = "unprivileged_bpf_disabled", 26321be7f75dSAlexei Starovoitov .data = &sysctl_unprivileged_bpf_disabled, 26331be7f75dSAlexei Starovoitov .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), 26341be7f75dSAlexei Starovoitov .mode = 0644, 263508389d88SDaniel Borkmann .proc_handler = bpf_unpriv_handler, 263608389d88SDaniel Borkmann .extra1 = SYSCTL_ZERO, 263708389d88SDaniel Borkmann .extra2 = &two, 26381be7f75dSAlexei Starovoitov }, 2639492ecee8SAlexei Starovoitov { 2640492ecee8SAlexei Starovoitov .procname = "bpf_stats_enabled", 2641a8e11e5cSEric Dumazet .data = &bpf_stats_enabled_key.key, 2642a8e11e5cSEric Dumazet .maxlen = sizeof(bpf_stats_enabled_key), 2643492ecee8SAlexei Starovoitov .mode = 0644, 2644d46edd67SSong Liu .proc_handler = bpf_stats_handler, 2645492ecee8SAlexei Starovoitov }, 26463fcc5530SAlexei Starovoitov #endif 2647b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU) 2648088e9d25SDaniel Bristot de Oliveira { 2649088e9d25SDaniel Bristot de Oliveira .procname = "panic_on_rcu_stall", 2650088e9d25SDaniel Bristot de Oliveira .data = &sysctl_panic_on_rcu_stall, 2651088e9d25SDaniel Bristot de Oliveira .maxlen = sizeof(sysctl_panic_on_rcu_stall), 2652088e9d25SDaniel Bristot de Oliveira .mode = 0644, 2653088e9d25SDaniel Bristot de Oliveira .proc_handler = proc_dointvec_minmax, 2654eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2655eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2656088e9d25SDaniel Bristot de Oliveira }, 2657088e9d25SDaniel Bristot de Oliveira #endif 2658dfe56404Schao #if defined(CONFIG_TREE_RCU) 2659dfe56404Schao { 2660dfe56404Schao .procname = "max_rcu_stall_to_panic", 2661dfe56404Schao .data = &sysctl_max_rcu_stall_to_panic, 2662dfe56404Schao .maxlen = sizeof(sysctl_max_rcu_stall_to_panic), 2663dfe56404Schao .mode = 0644, 2664dfe56404Schao .proc_handler = proc_dointvec_minmax, 2665dfe56404Schao .extra1 = SYSCTL_ONE, 2666dfe56404Schao .extra2 = SYSCTL_INT_MAX, 2667dfe56404Schao }, 2668dfe56404Schao #endif 2669964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 2670964c9dffSAlexander Popov { 2671964c9dffSAlexander Popov .procname = "stack_erasing", 2672964c9dffSAlexander Popov .data = NULL, 2673964c9dffSAlexander Popov .maxlen = sizeof(int), 2674964c9dffSAlexander Popov .mode = 0600, 2675964c9dffSAlexander Popov .proc_handler = stack_erasing_sysctl, 2676eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2677eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2678964c9dffSAlexander Popov }, 2679964c9dffSAlexander Popov #endif 26806fce56ecSEric W. Biederman { } 26811da177e4SLinus Torvalds }; 26821da177e4SLinus Torvalds 2683d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 26841da177e4SLinus Torvalds { 26851da177e4SLinus Torvalds .procname = "overcommit_memory", 26861da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 26871da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 26881da177e4SLinus Torvalds .mode = 0644, 268956f3547bSFeng Tang .proc_handler = overcommit_policy_handler, 2690eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2691cb16e95fSPetr Holasek .extra2 = &two, 26921da177e4SLinus Torvalds }, 26931da177e4SLinus Torvalds { 2694fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 2695fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 2696fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 2697fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 2698cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2699eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2700cb16e95fSPetr Holasek .extra2 = &two, 2701fadd8fbdSKAMEZAWA Hiroyuki }, 2702fadd8fbdSKAMEZAWA Hiroyuki { 2703fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 2704fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 2705fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 2706fe071d7eSDavid Rientjes .mode = 0644, 27076d456111SEric W. Biederman .proc_handler = proc_dointvec, 2708fe071d7eSDavid Rientjes }, 2709fe071d7eSDavid Rientjes { 2710fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 2711fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 2712fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 2713fef1bdd6SDavid Rientjes .mode = 0644, 27146d456111SEric W. Biederman .proc_handler = proc_dointvec, 2715fef1bdd6SDavid Rientjes }, 2716fef1bdd6SDavid Rientjes { 27171da177e4SLinus Torvalds .procname = "overcommit_ratio", 27181da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 27191da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 27201da177e4SLinus Torvalds .mode = 0644, 272149f0ce5fSJerome Marchand .proc_handler = overcommit_ratio_handler, 272249f0ce5fSJerome Marchand }, 272349f0ce5fSJerome Marchand { 272449f0ce5fSJerome Marchand .procname = "overcommit_kbytes", 272549f0ce5fSJerome Marchand .data = &sysctl_overcommit_kbytes, 272649f0ce5fSJerome Marchand .maxlen = sizeof(sysctl_overcommit_kbytes), 272749f0ce5fSJerome Marchand .mode = 0644, 272849f0ce5fSJerome Marchand .proc_handler = overcommit_kbytes_handler, 27291da177e4SLinus Torvalds }, 27301da177e4SLinus Torvalds { 27311da177e4SLinus Torvalds .procname = "page-cluster", 27321da177e4SLinus Torvalds .data = &page_cluster, 27331da177e4SLinus Torvalds .maxlen = sizeof(int), 27341da177e4SLinus Torvalds .mode = 0644, 2735cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2736eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27371da177e4SLinus Torvalds }, 27381da177e4SLinus Torvalds { 27391da177e4SLinus Torvalds .procname = "dirty_background_ratio", 27401da177e4SLinus Torvalds .data = &dirty_background_ratio, 27411da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 27421da177e4SLinus Torvalds .mode = 0644, 27436d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 2744eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27451da177e4SLinus Torvalds .extra2 = &one_hundred, 27461da177e4SLinus Torvalds }, 27471da177e4SLinus Torvalds { 27482da02997SDavid Rientjes .procname = "dirty_background_bytes", 27492da02997SDavid Rientjes .data = &dirty_background_bytes, 27502da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 27512da02997SDavid Rientjes .mode = 0644, 27526d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 2753fc3501d4SSven Wegener .extra1 = &one_ul, 27542da02997SDavid Rientjes }, 27552da02997SDavid Rientjes { 27561da177e4SLinus Torvalds .procname = "dirty_ratio", 27571da177e4SLinus Torvalds .data = &vm_dirty_ratio, 27581da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 27591da177e4SLinus Torvalds .mode = 0644, 27606d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 2761eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27621da177e4SLinus Torvalds .extra2 = &one_hundred, 27631da177e4SLinus Torvalds }, 27641da177e4SLinus Torvalds { 27652da02997SDavid Rientjes .procname = "dirty_bytes", 27662da02997SDavid Rientjes .data = &vm_dirty_bytes, 27672da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 27682da02997SDavid Rientjes .mode = 0644, 27696d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 27709e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 27712da02997SDavid Rientjes }, 27722da02997SDavid Rientjes { 27731da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 2774f6ef9438SBart Samwel .data = &dirty_writeback_interval, 2775f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 27761da177e4SLinus Torvalds .mode = 0644, 27776d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 27781da177e4SLinus Torvalds }, 27791da177e4SLinus Torvalds { 27801da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 2781f6ef9438SBart Samwel .data = &dirty_expire_interval, 2782f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 27831da177e4SLinus Torvalds .mode = 0644, 2784cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2785eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27861da177e4SLinus Torvalds }, 27871da177e4SLinus Torvalds { 27881efff914STheodore Ts'o .procname = "dirtytime_expire_seconds", 27891efff914STheodore Ts'o .data = &dirtytime_expire_interval, 27902d87b309SRandy Dunlap .maxlen = sizeof(dirtytime_expire_interval), 27911efff914STheodore Ts'o .mode = 0644, 27921efff914STheodore Ts'o .proc_handler = dirtytime_interval_handler, 2793eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27941efff914STheodore Ts'o }, 27951efff914STheodore Ts'o { 27961da177e4SLinus Torvalds .procname = "swappiness", 27971da177e4SLinus Torvalds .data = &vm_swappiness, 27981da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 27991da177e4SLinus Torvalds .mode = 0644, 28006d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2801eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2802c843966cSJohannes Weiner .extra2 = &two_hundred, 28031da177e4SLinus Torvalds }, 28041da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 28051da177e4SLinus Torvalds { 28061da177e4SLinus Torvalds .procname = "nr_hugepages", 2807e5ff2159SAndi Kleen .data = NULL, 28081da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 28091da177e4SLinus Torvalds .mode = 0644, 28106d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 28111da177e4SLinus Torvalds }, 281206808b08SLee Schermerhorn #ifdef CONFIG_NUMA 281306808b08SLee Schermerhorn { 281406808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 281506808b08SLee Schermerhorn .data = NULL, 281606808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 281706808b08SLee Schermerhorn .mode = 0644, 281806808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 281906808b08SLee Schermerhorn }, 28204518085eSKemi Wang { 28214518085eSKemi Wang .procname = "numa_stat", 28224518085eSKemi Wang .data = &sysctl_vm_numa_stat, 28234518085eSKemi Wang .maxlen = sizeof(int), 28244518085eSKemi Wang .mode = 0644, 28254518085eSKemi Wang .proc_handler = sysctl_vm_numa_stat_handler, 2826eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2827eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 28284518085eSKemi Wang }, 282906808b08SLee Schermerhorn #endif 28301da177e4SLinus Torvalds { 28311da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 28321da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 28331da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 28341da177e4SLinus Torvalds .mode = 0644, 28356d456111SEric W. Biederman .proc_handler = proc_dointvec, 28361da177e4SLinus Torvalds }, 2837396faf03SMel Gorman { 2838d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 2839e5ff2159SAndi Kleen .data = NULL, 2840e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 2841d1c3fb1fSNishanth Aravamudan .mode = 0644, 28426d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 2843d1c3fb1fSNishanth Aravamudan }, 28441da177e4SLinus Torvalds #endif 28451da177e4SLinus Torvalds { 28461da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 28471da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 28481da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 28491da177e4SLinus Torvalds .mode = 0644, 28506d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 28511da177e4SLinus Torvalds }, 28521da177e4SLinus Torvalds { 28539d0243bcSAndrew Morton .procname = "drop_caches", 28549d0243bcSAndrew Morton .data = &sysctl_drop_caches, 28559d0243bcSAndrew Morton .maxlen = sizeof(int), 2856204cb79aSJohannes Weiner .mode = 0200, 28579d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 2858eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 28595509a5d2SDave Hansen .extra2 = &four, 28609d0243bcSAndrew Morton }, 286176ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 286276ab0f53SMel Gorman { 286376ab0f53SMel Gorman .procname = "compact_memory", 2864ef498438SPintu Kumar .data = NULL, 286576ab0f53SMel Gorman .maxlen = sizeof(int), 286676ab0f53SMel Gorman .mode = 0200, 286776ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 286876ab0f53SMel Gorman }, 28695e771905SMel Gorman { 2870facdaa91SNitin Gupta .procname = "compaction_proactiveness", 2871facdaa91SNitin Gupta .data = &sysctl_compaction_proactiveness, 2872d34c0a75SNitin Gupta .maxlen = sizeof(sysctl_compaction_proactiveness), 2873facdaa91SNitin Gupta .mode = 0644, 2874*65d759c8SCharan Teja Reddy .proc_handler = compaction_proactiveness_sysctl_handler, 2875facdaa91SNitin Gupta .extra1 = SYSCTL_ZERO, 2876facdaa91SNitin Gupta .extra2 = &one_hundred, 2877facdaa91SNitin Gupta }, 2878facdaa91SNitin Gupta { 28795e771905SMel Gorman .procname = "extfrag_threshold", 28805e771905SMel Gorman .data = &sysctl_extfrag_threshold, 28815e771905SMel Gorman .maxlen = sizeof(int), 28825e771905SMel Gorman .mode = 0644, 28836b7e5cadSMatthew Wilcox .proc_handler = proc_dointvec_minmax, 28845e771905SMel Gorman .extra1 = &min_extfrag_threshold, 28855e771905SMel Gorman .extra2 = &max_extfrag_threshold, 28865e771905SMel Gorman }, 28875bbe3547SEric B Munson { 28885bbe3547SEric B Munson .procname = "compact_unevictable_allowed", 28895bbe3547SEric B Munson .data = &sysctl_compact_unevictable_allowed, 28905bbe3547SEric B Munson .maxlen = sizeof(int), 28915bbe3547SEric B Munson .mode = 0644, 28926923aa0dSSebastian Andrzej Siewior .proc_handler = proc_dointvec_minmax_warn_RT_change, 2893eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2894eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 28955bbe3547SEric B Munson }, 28965e771905SMel Gorman 289776ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 28989d0243bcSAndrew Morton { 28991da177e4SLinus Torvalds .procname = "min_free_kbytes", 29001da177e4SLinus Torvalds .data = &min_free_kbytes, 29011da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 29021da177e4SLinus Torvalds .mode = 0644, 29036d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 2904eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29051da177e4SLinus Torvalds }, 29068ad4b1fbSRohit Seth { 29071c30844dSMel Gorman .procname = "watermark_boost_factor", 29081c30844dSMel Gorman .data = &watermark_boost_factor, 29091c30844dSMel Gorman .maxlen = sizeof(watermark_boost_factor), 29101c30844dSMel Gorman .mode = 0644, 291126363af5SChristoph Hellwig .proc_handler = proc_dointvec_minmax, 2912eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29131c30844dSMel Gorman }, 29141c30844dSMel Gorman { 2915795ae7a0SJohannes Weiner .procname = "watermark_scale_factor", 2916795ae7a0SJohannes Weiner .data = &watermark_scale_factor, 2917795ae7a0SJohannes Weiner .maxlen = sizeof(watermark_scale_factor), 2918795ae7a0SJohannes Weiner .mode = 0644, 2919795ae7a0SJohannes Weiner .proc_handler = watermark_scale_factor_sysctl_handler, 2920eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2921795ae7a0SJohannes Weiner .extra2 = &one_thousand, 2922795ae7a0SJohannes Weiner }, 2923795ae7a0SJohannes Weiner { 292474f44822SMel Gorman .procname = "percpu_pagelist_high_fraction", 292574f44822SMel Gorman .data = &percpu_pagelist_high_fraction, 292674f44822SMel Gorman .maxlen = sizeof(percpu_pagelist_high_fraction), 29278ad4b1fbSRohit Seth .mode = 0644, 292874f44822SMel Gorman .proc_handler = percpu_pagelist_high_fraction_sysctl_handler, 2929eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29308ad4b1fbSRohit Seth }, 29315ef64cc8SLinus Torvalds { 29325ef64cc8SLinus Torvalds .procname = "page_lock_unfairness", 29335ef64cc8SLinus Torvalds .data = &sysctl_page_lock_unfairness, 29345ef64cc8SLinus Torvalds .maxlen = sizeof(sysctl_page_lock_unfairness), 29355ef64cc8SLinus Torvalds .mode = 0644, 29365ef64cc8SLinus Torvalds .proc_handler = proc_dointvec_minmax, 29375ef64cc8SLinus Torvalds .extra1 = SYSCTL_ZERO, 29385ef64cc8SLinus Torvalds }, 29391da177e4SLinus Torvalds #ifdef CONFIG_MMU 29401da177e4SLinus Torvalds { 29411da177e4SLinus Torvalds .procname = "max_map_count", 29421da177e4SLinus Torvalds .data = &sysctl_max_map_count, 29431da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 29441da177e4SLinus Torvalds .mode = 0644, 29453e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 2946eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29471da177e4SLinus Torvalds }, 2948dd8632a1SPaul Mundt #else 2949dd8632a1SPaul Mundt { 2950dd8632a1SPaul Mundt .procname = "nr_trim_pages", 2951dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 2952dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 2953dd8632a1SPaul Mundt .mode = 0644, 29546d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2955eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2956dd8632a1SPaul Mundt }, 29571da177e4SLinus Torvalds #endif 29581da177e4SLinus Torvalds { 29591da177e4SLinus Torvalds .procname = "laptop_mode", 29601da177e4SLinus Torvalds .data = &laptop_mode, 29611da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 29621da177e4SLinus Torvalds .mode = 0644, 29636d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 29641da177e4SLinus Torvalds }, 29651da177e4SLinus Torvalds { 29661da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 29671da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 29681da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 29691da177e4SLinus Torvalds .mode = 0644, 29703b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 2971eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29721da177e4SLinus Torvalds }, 297367f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 297467f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 29751da177e4SLinus Torvalds { 29761da177e4SLinus Torvalds .procname = "legacy_va_layout", 29771da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 29781da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 29791da177e4SLinus Torvalds .mode = 0644, 29803b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 2981eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29821da177e4SLinus Torvalds }, 29831da177e4SLinus Torvalds #endif 29841743660bSChristoph Lameter #ifdef CONFIG_NUMA 29851743660bSChristoph Lameter { 29861743660bSChristoph Lameter .procname = "zone_reclaim_mode", 2987a5f5f91dSMel Gorman .data = &node_reclaim_mode, 2988a5f5f91dSMel Gorman .maxlen = sizeof(node_reclaim_mode), 29891743660bSChristoph Lameter .mode = 0644, 29903b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 2991eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29921743660bSChristoph Lameter }, 29939614634fSChristoph Lameter { 29949614634fSChristoph Lameter .procname = "min_unmapped_ratio", 29959614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 29969614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 29979614634fSChristoph Lameter .mode = 0644, 29986d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 2999eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30009614634fSChristoph Lameter .extra2 = &one_hundred, 30019614634fSChristoph Lameter }, 30020ff38490SChristoph Lameter { 30030ff38490SChristoph Lameter .procname = "min_slab_ratio", 30040ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 30050ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 30060ff38490SChristoph Lameter .mode = 0644, 30076d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 3008eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30090ff38490SChristoph Lameter .extra2 = &one_hundred, 30100ff38490SChristoph Lameter }, 30111743660bSChristoph Lameter #endif 301277461ab3SChristoph Lameter #ifdef CONFIG_SMP 301377461ab3SChristoph Lameter { 301477461ab3SChristoph Lameter .procname = "stat_interval", 301577461ab3SChristoph Lameter .data = &sysctl_stat_interval, 301677461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 301777461ab3SChristoph Lameter .mode = 0644, 30186d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 301977461ab3SChristoph Lameter }, 302052b6f46bSHugh Dickins { 302152b6f46bSHugh Dickins .procname = "stat_refresh", 302252b6f46bSHugh Dickins .data = NULL, 302352b6f46bSHugh Dickins .maxlen = 0, 302452b6f46bSHugh Dickins .mode = 0600, 302552b6f46bSHugh Dickins .proc_handler = vmstat_refresh, 302652b6f46bSHugh Dickins }, 302777461ab3SChristoph Lameter #endif 30286e141546SDavid Howells #ifdef CONFIG_MMU 3029ed032189SEric Paris { 3030ed032189SEric Paris .procname = "mmap_min_addr", 3031788084abSEric Paris .data = &dac_mmap_min_addr, 3032ed032189SEric Paris .maxlen = sizeof(unsigned long), 3033ed032189SEric Paris .mode = 0644, 30346d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 3035ed032189SEric Paris }, 30366e141546SDavid Howells #endif 3037f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 3038f0c0b2b8SKAMEZAWA Hiroyuki { 3039f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 3040f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 3041f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 3042f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 30436d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 3044f0c0b2b8SKAMEZAWA Hiroyuki }, 3045f0c0b2b8SKAMEZAWA Hiroyuki #endif 30462b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 30475c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 3048e6e5494cSIngo Molnar { 3049e6e5494cSIngo Molnar .procname = "vdso_enabled", 30503d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32 30513d7ee969SAndy Lutomirski .data = &vdso32_enabled, 30523d7ee969SAndy Lutomirski .maxlen = sizeof(vdso32_enabled), 30533d7ee969SAndy Lutomirski #else 3054e6e5494cSIngo Molnar .data = &vdso_enabled, 3055e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 30563d7ee969SAndy Lutomirski #endif 3057e6e5494cSIngo Molnar .mode = 0644, 30586d456111SEric W. Biederman .proc_handler = proc_dointvec, 3059eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3060e6e5494cSIngo Molnar }, 3061e6e5494cSIngo Molnar #endif 3062195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 3063195cf453SBron Gondwana { 3064195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 3065195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 3066195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 3067195cf453SBron Gondwana .mode = 0644, 30686d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3069eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3070eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3071195cf453SBron Gondwana }, 3072195cf453SBron Gondwana #endif 30736a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 30746a46079cSAndi Kleen { 30756a46079cSAndi Kleen .procname = "memory_failure_early_kill", 30766a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 30776a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 30786a46079cSAndi Kleen .mode = 0644, 30796d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3080eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3081eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 30826a46079cSAndi Kleen }, 30836a46079cSAndi Kleen { 30846a46079cSAndi Kleen .procname = "memory_failure_recovery", 30856a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 30866a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 30876a46079cSAndi Kleen .mode = 0644, 30886d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3089eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3090eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 30916a46079cSAndi Kleen }, 30926a46079cSAndi Kleen #endif 3093c9b1d098SAndrew Shewmaker { 3094c9b1d098SAndrew Shewmaker .procname = "user_reserve_kbytes", 3095c9b1d098SAndrew Shewmaker .data = &sysctl_user_reserve_kbytes, 3096c9b1d098SAndrew Shewmaker .maxlen = sizeof(sysctl_user_reserve_kbytes), 3097c9b1d098SAndrew Shewmaker .mode = 0644, 3098c9b1d098SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 3099c9b1d098SAndrew Shewmaker }, 31004eeab4f5SAndrew Shewmaker { 31014eeab4f5SAndrew Shewmaker .procname = "admin_reserve_kbytes", 31024eeab4f5SAndrew Shewmaker .data = &sysctl_admin_reserve_kbytes, 31034eeab4f5SAndrew Shewmaker .maxlen = sizeof(sysctl_admin_reserve_kbytes), 31044eeab4f5SAndrew Shewmaker .mode = 0644, 31054eeab4f5SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 31064eeab4f5SAndrew Shewmaker }, 3107d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS 3108d07e2259SDaniel Cashman { 3109d07e2259SDaniel Cashman .procname = "mmap_rnd_bits", 3110d07e2259SDaniel Cashman .data = &mmap_rnd_bits, 3111d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_bits), 3112d07e2259SDaniel Cashman .mode = 0600, 3113d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3114d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_bits_min, 3115d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_bits_max, 3116d07e2259SDaniel Cashman }, 3117d07e2259SDaniel Cashman #endif 3118d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS 3119d07e2259SDaniel Cashman { 3120d07e2259SDaniel Cashman .procname = "mmap_rnd_compat_bits", 3121d07e2259SDaniel Cashman .data = &mmap_rnd_compat_bits, 3122d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_compat_bits), 3123d07e2259SDaniel Cashman .mode = 0600, 3124d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3125d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_compat_bits_min, 3126d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_compat_bits_max, 3127d07e2259SDaniel Cashman }, 3128d07e2259SDaniel Cashman #endif 3129cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD 3130cefdca0aSPeter Xu { 3131cefdca0aSPeter Xu .procname = "unprivileged_userfaultfd", 3132cefdca0aSPeter Xu .data = &sysctl_unprivileged_userfaultfd, 3133cefdca0aSPeter Xu .maxlen = sizeof(sysctl_unprivileged_userfaultfd), 3134cefdca0aSPeter Xu .mode = 0644, 3135cefdca0aSPeter Xu .proc_handler = proc_dointvec_minmax, 3136eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3137eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3138cefdca0aSPeter Xu }, 3139cefdca0aSPeter Xu #endif 31406fce56ecSEric W. Biederman { } 31411da177e4SLinus Torvalds }; 31421da177e4SLinus Torvalds 3143d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 31441da177e4SLinus Torvalds { 31451da177e4SLinus Torvalds .procname = "inode-nr", 31461da177e4SLinus Torvalds .data = &inodes_stat, 31473942c07cSGlauber Costa .maxlen = 2*sizeof(long), 31481da177e4SLinus Torvalds .mode = 0444, 3149cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 31501da177e4SLinus Torvalds }, 31511da177e4SLinus Torvalds { 31521da177e4SLinus Torvalds .procname = "inode-state", 31531da177e4SLinus Torvalds .data = &inodes_stat, 31543942c07cSGlauber Costa .maxlen = 7*sizeof(long), 31551da177e4SLinus Torvalds .mode = 0444, 3156cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 31571da177e4SLinus Torvalds }, 31581da177e4SLinus Torvalds { 31591da177e4SLinus Torvalds .procname = "file-nr", 31601da177e4SLinus Torvalds .data = &files_stat, 3161518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 31621da177e4SLinus Torvalds .mode = 0444, 31636d456111SEric W. Biederman .proc_handler = proc_nr_files, 31641da177e4SLinus Torvalds }, 31651da177e4SLinus Torvalds { 31661da177e4SLinus Torvalds .procname = "file-max", 31671da177e4SLinus Torvalds .data = &files_stat.max_files, 3168518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 31691da177e4SLinus Torvalds .mode = 0644, 3170518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 31719002b214SWill Deacon .extra1 = &zero_ul, 317232a5ad9cSChristian Brauner .extra2 = &long_max, 31731da177e4SLinus Torvalds }, 31741da177e4SLinus Torvalds { 31759cfe015aSEric Dumazet .procname = "nr_open", 31769cfe015aSEric Dumazet .data = &sysctl_nr_open, 31779b80a184SAlexey Dobriyan .maxlen = sizeof(unsigned int), 31789cfe015aSEric Dumazet .mode = 0644, 31796d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3180eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 3181eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 31829cfe015aSEric Dumazet }, 31839cfe015aSEric Dumazet { 31841da177e4SLinus Torvalds .procname = "dentry-state", 31851da177e4SLinus Torvalds .data = &dentry_stat, 31863942c07cSGlauber Costa .maxlen = 6*sizeof(long), 31871da177e4SLinus Torvalds .mode = 0444, 3188312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 31891da177e4SLinus Torvalds }, 31901da177e4SLinus Torvalds { 31911da177e4SLinus Torvalds .procname = "overflowuid", 31921da177e4SLinus Torvalds .data = &fs_overflowuid, 31931da177e4SLinus Torvalds .maxlen = sizeof(int), 31941da177e4SLinus Torvalds .mode = 0644, 31956d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 31961da177e4SLinus Torvalds .extra1 = &minolduid, 31971da177e4SLinus Torvalds .extra2 = &maxolduid, 31981da177e4SLinus Torvalds }, 31991da177e4SLinus Torvalds { 32001da177e4SLinus Torvalds .procname = "overflowgid", 32011da177e4SLinus Torvalds .data = &fs_overflowgid, 32021da177e4SLinus Torvalds .maxlen = sizeof(int), 32031da177e4SLinus Torvalds .mode = 0644, 32046d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 32051da177e4SLinus Torvalds .extra1 = &minolduid, 32061da177e4SLinus Torvalds .extra2 = &maxolduid, 32071da177e4SLinus Torvalds }, 3208bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 32091da177e4SLinus Torvalds { 32101da177e4SLinus Torvalds .procname = "leases-enable", 32111da177e4SLinus Torvalds .data = &leases_enable, 32121da177e4SLinus Torvalds .maxlen = sizeof(int), 32131da177e4SLinus Torvalds .mode = 0644, 32146d456111SEric W. Biederman .proc_handler = proc_dointvec, 32151da177e4SLinus Torvalds }, 3216bfcd17a6SThomas Petazzoni #endif 32171da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 32181da177e4SLinus Torvalds { 32191da177e4SLinus Torvalds .procname = "dir-notify-enable", 32201da177e4SLinus Torvalds .data = &dir_notify_enable, 32211da177e4SLinus Torvalds .maxlen = sizeof(int), 32221da177e4SLinus Torvalds .mode = 0644, 32236d456111SEric W. Biederman .proc_handler = proc_dointvec, 32241da177e4SLinus Torvalds }, 32251da177e4SLinus Torvalds #endif 32261da177e4SLinus Torvalds #ifdef CONFIG_MMU 3227bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 32281da177e4SLinus Torvalds { 32291da177e4SLinus Torvalds .procname = "lease-break-time", 32301da177e4SLinus Torvalds .data = &lease_break_time, 32311da177e4SLinus Torvalds .maxlen = sizeof(int), 32321da177e4SLinus Torvalds .mode = 0644, 32336d456111SEric W. Biederman .proc_handler = proc_dointvec, 32341da177e4SLinus Torvalds }, 3235bfcd17a6SThomas Petazzoni #endif 3236ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 32371da177e4SLinus Torvalds { 32381da177e4SLinus Torvalds .procname = "aio-nr", 32391da177e4SLinus Torvalds .data = &aio_nr, 32401da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 32411da177e4SLinus Torvalds .mode = 0444, 32426d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 32431da177e4SLinus Torvalds }, 32441da177e4SLinus Torvalds { 32451da177e4SLinus Torvalds .procname = "aio-max-nr", 32461da177e4SLinus Torvalds .data = &aio_max_nr, 32471da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 32481da177e4SLinus Torvalds .mode = 0644, 32496d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 32501da177e4SLinus Torvalds }, 3251ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 32522d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 32530399cb08SRobert Love { 32540399cb08SRobert Love .procname = "inotify", 32550399cb08SRobert Love .mode = 0555, 32560399cb08SRobert Love .child = inotify_table, 32570399cb08SRobert Love }, 32580399cb08SRobert Love #endif 32595b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY 32605b8fea65SAmir Goldstein { 32615b8fea65SAmir Goldstein .procname = "fanotify", 32625b8fea65SAmir Goldstein .mode = 0555, 32635b8fea65SAmir Goldstein .child = fanotify_table, 32645b8fea65SAmir Goldstein }, 32655b8fea65SAmir Goldstein #endif 32667ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 32677ef9964eSDavide Libenzi { 32687ef9964eSDavide Libenzi .procname = "epoll", 32697ef9964eSDavide Libenzi .mode = 0555, 32707ef9964eSDavide Libenzi .child = epoll_table, 32717ef9964eSDavide Libenzi }, 32727ef9964eSDavide Libenzi #endif 32731da177e4SLinus Torvalds #endif 3274d6e71144SAlan Cox { 3275800179c9SKees Cook .procname = "protected_symlinks", 3276800179c9SKees Cook .data = &sysctl_protected_symlinks, 3277800179c9SKees Cook .maxlen = sizeof(int), 3278800179c9SKees Cook .mode = 0600, 3279800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3280eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3281eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3282800179c9SKees Cook }, 3283800179c9SKees Cook { 3284800179c9SKees Cook .procname = "protected_hardlinks", 3285800179c9SKees Cook .data = &sysctl_protected_hardlinks, 3286800179c9SKees Cook .maxlen = sizeof(int), 3287800179c9SKees Cook .mode = 0600, 3288800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3289eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3290eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3291800179c9SKees Cook }, 3292800179c9SKees Cook { 329330aba665SSalvatore Mesoraca .procname = "protected_fifos", 329430aba665SSalvatore Mesoraca .data = &sysctl_protected_fifos, 329530aba665SSalvatore Mesoraca .maxlen = sizeof(int), 329630aba665SSalvatore Mesoraca .mode = 0600, 329730aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3298eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 329930aba665SSalvatore Mesoraca .extra2 = &two, 330030aba665SSalvatore Mesoraca }, 330130aba665SSalvatore Mesoraca { 330230aba665SSalvatore Mesoraca .procname = "protected_regular", 330330aba665SSalvatore Mesoraca .data = &sysctl_protected_regular, 330430aba665SSalvatore Mesoraca .maxlen = sizeof(int), 330530aba665SSalvatore Mesoraca .mode = 0600, 330630aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3307eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 330830aba665SSalvatore Mesoraca .extra2 = &two, 330930aba665SSalvatore Mesoraca }, 331030aba665SSalvatore Mesoraca { 3311d6e71144SAlan Cox .procname = "suid_dumpable", 3312d6e71144SAlan Cox .data = &suid_dumpable, 3313d6e71144SAlan Cox .maxlen = sizeof(int), 3314d6e71144SAlan Cox .mode = 0644, 331554b50199SKees Cook .proc_handler = proc_dointvec_minmax_coredump, 3316eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 33178e654fbaSMatthew Wilcox .extra2 = &two, 3318d6e71144SAlan Cox }, 33192abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 33202abc26fcSEric W. Biederman { 33212abc26fcSEric W. Biederman .procname = "binfmt_misc", 33222abc26fcSEric W. Biederman .mode = 0555, 3323f9bd6733SEric W. Biederman .child = sysctl_mount_point, 33242abc26fcSEric W. Biederman }, 33252abc26fcSEric W. Biederman #endif 3326b492e95bSJens Axboe { 3327ff9da691SJens Axboe .procname = "pipe-max-size", 3328ff9da691SJens Axboe .data = &pipe_max_size, 332998159d97SJoe Lawrence .maxlen = sizeof(pipe_max_size), 3330b492e95bSJens Axboe .mode = 0644, 3331319e0a21SEric Biggers .proc_handler = proc_dopipe_max_size, 3332b492e95bSJens Axboe }, 3333759c0114SWilly Tarreau { 3334759c0114SWilly Tarreau .procname = "pipe-user-pages-hard", 3335759c0114SWilly Tarreau .data = &pipe_user_pages_hard, 3336759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_hard), 3337759c0114SWilly Tarreau .mode = 0644, 3338759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3339759c0114SWilly Tarreau }, 3340759c0114SWilly Tarreau { 3341759c0114SWilly Tarreau .procname = "pipe-user-pages-soft", 3342759c0114SWilly Tarreau .data = &pipe_user_pages_soft, 3343759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_soft), 3344759c0114SWilly Tarreau .mode = 0644, 3345759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3346759c0114SWilly Tarreau }, 3347d2921684SEric W. Biederman { 3348d2921684SEric W. Biederman .procname = "mount-max", 3349d2921684SEric W. Biederman .data = &sysctl_mount_max, 3350d2921684SEric W. Biederman .maxlen = sizeof(unsigned int), 3351d2921684SEric W. Biederman .mode = 0644, 3352d2921684SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3353eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 3354d2921684SEric W. Biederman }, 33556fce56ecSEric W. Biederman { } 33561da177e4SLinus Torvalds }; 33571da177e4SLinus Torvalds 3358d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 33597ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE 3360abd4f750SMasoud Asgharifard Sharbiani { 3361abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 3362abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 3363abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 3364abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 3365abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 3366abd4f750SMasoud Asgharifard Sharbiani }, 3367abd4f750SMasoud Asgharifard Sharbiani #endif 3368b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 3369b2be84dfSMasami Hiramatsu { 3370b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 3371b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 3372b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 3373b2be84dfSMasami Hiramatsu .mode = 0644, 3374b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 3375eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3376eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3377b2be84dfSMasami Hiramatsu }, 3378b2be84dfSMasami Hiramatsu #endif 33796fce56ecSEric W. Biederman { } 33801da177e4SLinus Torvalds }; 33811da177e4SLinus Torvalds 3382d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 33836fce56ecSEric W. Biederman { } 33841da177e4SLinus Torvalds }; 33851da177e4SLinus Torvalds 3386f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = { 3387f461d2dcSChristoph Hellwig { 3388f461d2dcSChristoph Hellwig .procname = "kernel", 3389f461d2dcSChristoph Hellwig .mode = 0555, 3390f461d2dcSChristoph Hellwig .child = kern_table, 3391f461d2dcSChristoph Hellwig }, 3392f461d2dcSChristoph Hellwig { 3393f461d2dcSChristoph Hellwig .procname = "vm", 3394f461d2dcSChristoph Hellwig .mode = 0555, 3395f461d2dcSChristoph Hellwig .child = vm_table, 3396f461d2dcSChristoph Hellwig }, 3397f461d2dcSChristoph Hellwig { 3398f461d2dcSChristoph Hellwig .procname = "fs", 3399f461d2dcSChristoph Hellwig .mode = 0555, 3400f461d2dcSChristoph Hellwig .child = fs_table, 3401f461d2dcSChristoph Hellwig }, 3402f461d2dcSChristoph Hellwig { 3403f461d2dcSChristoph Hellwig .procname = "debug", 3404f461d2dcSChristoph Hellwig .mode = 0555, 3405f461d2dcSChristoph Hellwig .child = debug_table, 3406f461d2dcSChristoph Hellwig }, 3407f461d2dcSChristoph Hellwig { 3408f461d2dcSChristoph Hellwig .procname = "dev", 3409f461d2dcSChristoph Hellwig .mode = 0555, 3410f461d2dcSChristoph Hellwig .child = dev_table, 3411f461d2dcSChristoph Hellwig }, 3412f461d2dcSChristoph Hellwig { } 3413f461d2dcSChristoph Hellwig }; 3414f461d2dcSChristoph Hellwig 3415de4e83bdSEric W. Biederman int __init sysctl_init(void) 3416330d57fbSAl Viro { 3417fd4b616bSSteven Rostedt struct ctl_table_header *hdr; 3418fd4b616bSSteven Rostedt 3419fd4b616bSSteven Rostedt hdr = register_sysctl_table(sysctl_base_table); 3420fd4b616bSSteven Rostedt kmemleak_not_leak(hdr); 3421330d57fbSAl Viro return 0; 3422f7e6ced4SAl Viro } 3423b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 34241da177e4SLinus Torvalds /* 34251da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 34261da177e4SLinus Torvalds * exception granted :-) 34271da177e4SLinus Torvalds */ 34281da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 3429e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec); 34301da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 34311da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 343261d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 34331da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 34341da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 34351da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 34361da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 34371da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 34380bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap); 3439