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> 36b6459415SJakub Kicinski #include <linux/filter.h> 3762239ac2SAdrian Bunk #include <linux/fs.h> 381da177e4SLinus Torvalds #include <linux/init.h> 391da177e4SLinus Torvalds #include <linux/kernel.h> 400296b228SKay Sievers #include <linux/kobject.h> 4120380731SArnaldo Carvalho de Melo #include <linux/net.h> 421da177e4SLinus Torvalds #include <linux/sysrq.h> 431da177e4SLinus Torvalds #include <linux/highuid.h> 441da177e4SLinus Torvalds #include <linux/writeback.h> 453fff4c42SIngo Molnar #include <linux/ratelimit.h> 4676ab0f53SMel Gorman #include <linux/compaction.h> 471da177e4SLinus Torvalds #include <linux/hugetlb.h> 481da177e4SLinus Torvalds #include <linux/initrd.h> 490b77f5bfSDavid Howells #include <linux/key.h> 501da177e4SLinus Torvalds #include <linux/times.h> 511da177e4SLinus Torvalds #include <linux/limits.h> 521da177e4SLinus Torvalds #include <linux/dcache.h> 536e006701SAlexey Dobriyan #include <linux/dnotify.h> 541da177e4SLinus Torvalds #include <linux/syscalls.h> 55c748e134SAdrian Bunk #include <linux/vmstat.h> 56c255d844SPavel Machek #include <linux/nfs_fs.h> 57c255d844SPavel Machek #include <linux/acpi.h> 5810a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 59b0fc494fSSteven Rostedt #include <linux/ftrace.h> 60cdd6c482SIngo Molnar #include <linux/perf_event.h> 61b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 62b492e95bSJens Axboe #include <linux/pipe_fs_i.h> 638e4228e1SDavid Rientjes #include <linux/oom.h> 6417f60a7dSEric Paris #include <linux/kmod.h> 6573efc039SDan Ballard #include <linux/capability.h> 6640401530SAl Viro #include <linux/binfmts.h> 67cf4aebc2SClark Williams #include <linux/sched/sysctl.h> 68f7ccbae4SIngo Molnar #include <linux/sched/coredump.h> 697984754bSKees Cook #include <linux/kexec.h> 701be7f75dSAlexei Starovoitov #include <linux/bpf.h> 71d2921684SEric W. Biederman #include <linux/mount.h> 72cefdca0aSPeter Xu #include <linux/userfaultfd_k.h> 732374c09bSChristoph Hellwig #include <linux/coredump.h> 742374c09bSChristoph Hellwig #include <linux/latencytop.h> 752374c09bSChristoph Hellwig #include <linux/pid.h> 760cd7c741SPeter Zijlstra #include <linux/delayacct.h> 771da177e4SLinus Torvalds 787f2923c4SChristian Brauner #include "../lib/kstrtox.h" 797f2923c4SChristian Brauner 807c0f6ba6SLinus Torvalds #include <linux/uaccess.h> 811da177e4SLinus Torvalds #include <asm/processor.h> 821da177e4SLinus Torvalds 8329cbc78bSAndi Kleen #ifdef CONFIG_X86 8429cbc78bSAndi Kleen #include <asm/nmi.h> 850741f4d2SChuck Ebbert #include <asm/stacktrace.h> 866e7c4025SIngo Molnar #include <asm/io.h> 8729cbc78bSAndi Kleen #endif 88d550bbd4SDavid Howells #ifdef CONFIG_SPARC 89d550bbd4SDavid Howells #include <asm/setup.h> 90d550bbd4SDavid Howells #endif 91c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 92c55b7c3eSDave Young #include <linux/acct.h> 93c55b7c3eSDave Young #endif 944f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 954f0e056fSDave Young #include <linux/rtmutex.h> 964f0e056fSDave Young #endif 972edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 982edf5e49SDave Young #include <linux/lockdep.h> 992edf5e49SDave Young #endif 10015485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 10115485a46SDave Young #include <scsi/sg.h> 10215485a46SDave Young #endif 103964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 104964c9dffSAlexander Popov #include <linux/stackleak.h> 105964c9dffSAlexander Popov #endif 10658687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 107504d7cf1SDon Zickus #include <linux/nmi.h> 108504d7cf1SDon Zickus #endif 109504d7cf1SDon Zickus 1101da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 1111da177e4SLinus Torvalds 112c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1132508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 114c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 115c4f3b63fSRavikiran G Thirumalai #endif 116c4f3b63fSRavikiran G Thirumalai 1179002b214SWill Deacon static unsigned long zero_ul; 118fc3501d4SSven Wegener static unsigned long one_ul = 1; 11932a5ad9cSChristian Brauner static unsigned long long_max = LONG_MAX; 120af91322eSDave Young #ifdef CONFIG_PRINTK 121af91322eSDave Young static int ten_thousand = 10000; 122af91322eSDave Young #endif 123c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS 124c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024; 125c5dfd78eSArnaldo Carvalho de Melo #endif 126c4f3b63fSRavikiran G Thirumalai 1279e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1289e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1299e4a5bdaSAndrea Righi 1301da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1311da177e4SLinus Torvalds static int maxolduid = 65535; 1321da177e4SLinus Torvalds static int minolduid; 1331da177e4SLinus Torvalds 1341da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 13573efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP; 1361da177e4SLinus Torvalds 137a2e51445SDmitry Vyukov /* 138a2e51445SDmitry Vyukov * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs 139a2e51445SDmitry Vyukov * and hung_task_check_interval_secs 140a2e51445SDmitry Vyukov */ 14180df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK 14280df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); 14380df2847SLiu Hua #endif 14480df2847SLiu Hua 145d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 146d14f1729SDave Young #include <linux/inotify.h> 147d14f1729SDave Young #endif 1485b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY 1495b8fea65SAmir Goldstein #include <linux/fanotify.h> 1505b8fea65SAmir Goldstein #endif 151b6fca725SVineet Gupta 152d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 153f4aacea2SKees Cook 154a19ac337SLuis R. Rodriguez /** 155a19ac337SLuis R. Rodriguez * enum sysctl_writes_mode - supported sysctl write modes 156a19ac337SLuis R. Rodriguez * 157a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value 158a19ac337SLuis R. Rodriguez * to be written, and multiple writes on the same sysctl file descriptor 159a19ac337SLuis R. Rodriguez * will rewrite the sysctl value, regardless of file position. No warning 160a19ac337SLuis R. Rodriguez * is issued when the initial position is not 0. 161a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is 162a19ac337SLuis R. Rodriguez * not 0. 163a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at 164a19ac337SLuis R. Rodriguez * file position 0 and the value must be fully contained in the buffer 165a19ac337SLuis R. Rodriguez * sent to the write syscall. If dealing with strings respect the file 166a19ac337SLuis R. Rodriguez * position, but restrict this to the max length of the buffer, anything 16765f50f25SWeitao Hou * passed the max length will be ignored. Multiple writes will append 168a19ac337SLuis R. Rodriguez * to the buffer. 169a19ac337SLuis R. Rodriguez * 170a19ac337SLuis R. Rodriguez * These write modes control how current file position affects the behavior of 171a19ac337SLuis R. Rodriguez * updating sysctl values through the proc interface on each write. 172a19ac337SLuis R. Rodriguez */ 173a19ac337SLuis R. Rodriguez enum sysctl_writes_mode { 174a19ac337SLuis R. Rodriguez SYSCTL_WRITES_LEGACY = -1, 175a19ac337SLuis R. Rodriguez SYSCTL_WRITES_WARN = 0, 176a19ac337SLuis R. Rodriguez SYSCTL_WRITES_STRICT = 1, 177a19ac337SLuis R. Rodriguez }; 178f4aacea2SKees Cook 179a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; 180f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 181ceb18132SLuis R. Rodriguez 18267f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 18367f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 1841da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1851da177e4SLinus Torvalds #endif 1861da177e4SLinus Torvalds 1875e771905SMel Gorman #ifdef CONFIG_COMPACTION 1885e771905SMel Gorman static int min_extfrag_threshold; 1895e771905SMel Gorman static int max_extfrag_threshold = 1000; 1905e771905SMel Gorman #endif 1915e771905SMel Gorman 192f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */ 193f461d2dcSChristoph Hellwig 1945447e8e0SArnd Bergmann #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL) 195d46edd67SSong Liu static int bpf_stats_handler(struct ctl_table *table, int write, 1967787b6fcSTobias Klauser void *buffer, size_t *lenp, loff_t *ppos) 197d46edd67SSong Liu { 198d46edd67SSong Liu struct static_key *key = (struct static_key *)table->data; 199d46edd67SSong Liu static int saved_val; 200d46edd67SSong Liu int val, ret; 201d46edd67SSong Liu struct ctl_table tmp = { 202d46edd67SSong Liu .data = &val, 203d46edd67SSong Liu .maxlen = sizeof(val), 204d46edd67SSong Liu .mode = table->mode, 205d46edd67SSong Liu .extra1 = SYSCTL_ZERO, 206d46edd67SSong Liu .extra2 = SYSCTL_ONE, 207d46edd67SSong Liu }; 208d46edd67SSong Liu 209d46edd67SSong Liu if (write && !capable(CAP_SYS_ADMIN)) 210d46edd67SSong Liu return -EPERM; 211d46edd67SSong Liu 212d46edd67SSong Liu mutex_lock(&bpf_stats_enabled_mutex); 213d46edd67SSong Liu val = saved_val; 214d46edd67SSong Liu ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 215d46edd67SSong Liu if (write && !ret && val != saved_val) { 216d46edd67SSong Liu if (val) 217d46edd67SSong Liu static_key_slow_inc(key); 218d46edd67SSong Liu else 219d46edd67SSong Liu static_key_slow_dec(key); 220d46edd67SSong Liu saved_val = val; 221d46edd67SSong Liu } 222d46edd67SSong Liu mutex_unlock(&bpf_stats_enabled_mutex); 223d46edd67SSong Liu return ret; 224d46edd67SSong Liu } 22508389d88SDaniel Borkmann 22608389d88SDaniel Borkmann static int bpf_unpriv_handler(struct ctl_table *table, int write, 22708389d88SDaniel Borkmann void *buffer, size_t *lenp, loff_t *ppos) 22808389d88SDaniel Borkmann { 22908389d88SDaniel Borkmann int ret, unpriv_enable = *(int *)table->data; 23008389d88SDaniel Borkmann bool locked_state = unpriv_enable == 1; 23108389d88SDaniel Borkmann struct ctl_table tmp = *table; 23208389d88SDaniel Borkmann 23308389d88SDaniel Borkmann if (write && !capable(CAP_SYS_ADMIN)) 23408389d88SDaniel Borkmann return -EPERM; 23508389d88SDaniel Borkmann 23608389d88SDaniel Borkmann tmp.data = &unpriv_enable; 23708389d88SDaniel Borkmann ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 23808389d88SDaniel Borkmann if (write && !ret) { 23908389d88SDaniel Borkmann if (locked_state && unpriv_enable != 1) 24008389d88SDaniel Borkmann return -EPERM; 24108389d88SDaniel Borkmann *(int *)table->data = unpriv_enable; 24208389d88SDaniel Borkmann } 24308389d88SDaniel Borkmann return ret; 24408389d88SDaniel Borkmann } 24508389d88SDaniel Borkmann #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */ 246d46edd67SSong Liu 247f461d2dcSChristoph Hellwig /* 248f461d2dcSChristoph Hellwig * /proc/sys support 249f461d2dcSChristoph Hellwig */ 250f461d2dcSChristoph Hellwig 251f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL 252f461d2dcSChristoph Hellwig 253f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write, 25432927393SChristoph Hellwig char *buffer, size_t *lenp, loff_t *ppos) 255f461d2dcSChristoph Hellwig { 256f461d2dcSChristoph Hellwig size_t len; 25732927393SChristoph Hellwig char c, *p; 258f461d2dcSChristoph Hellwig 259f461d2dcSChristoph Hellwig if (!data || !maxlen || !*lenp) { 260f461d2dcSChristoph Hellwig *lenp = 0; 261f461d2dcSChristoph Hellwig return 0; 262f461d2dcSChristoph Hellwig } 263f461d2dcSChristoph Hellwig 264f461d2dcSChristoph Hellwig if (write) { 265f461d2dcSChristoph Hellwig if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { 266f461d2dcSChristoph Hellwig /* Only continue writes not past the end of buffer. */ 267f461d2dcSChristoph Hellwig len = strlen(data); 268f461d2dcSChristoph Hellwig if (len > maxlen - 1) 269f461d2dcSChristoph Hellwig len = maxlen - 1; 270f461d2dcSChristoph Hellwig 271f461d2dcSChristoph Hellwig if (*ppos > len) 272f461d2dcSChristoph Hellwig return 0; 273f461d2dcSChristoph Hellwig len = *ppos; 274f461d2dcSChristoph Hellwig } else { 275f461d2dcSChristoph Hellwig /* Start writing from beginning of buffer. */ 276f461d2dcSChristoph Hellwig len = 0; 277f461d2dcSChristoph Hellwig } 278f461d2dcSChristoph Hellwig 279f461d2dcSChristoph Hellwig *ppos += *lenp; 280f461d2dcSChristoph Hellwig p = buffer; 281f461d2dcSChristoph Hellwig while ((p - buffer) < *lenp && len < maxlen - 1) { 28232927393SChristoph Hellwig c = *(p++); 283f461d2dcSChristoph Hellwig if (c == 0 || c == '\n') 284f461d2dcSChristoph Hellwig break; 285f461d2dcSChristoph Hellwig data[len++] = c; 286f461d2dcSChristoph Hellwig } 287f461d2dcSChristoph Hellwig data[len] = 0; 288f461d2dcSChristoph Hellwig } else { 289f461d2dcSChristoph Hellwig len = strlen(data); 290f461d2dcSChristoph Hellwig if (len > maxlen) 291f461d2dcSChristoph Hellwig len = maxlen; 292f461d2dcSChristoph Hellwig 293f461d2dcSChristoph Hellwig if (*ppos > len) { 294f461d2dcSChristoph Hellwig *lenp = 0; 295f461d2dcSChristoph Hellwig return 0; 296f461d2dcSChristoph Hellwig } 297f461d2dcSChristoph Hellwig 298f461d2dcSChristoph Hellwig data += *ppos; 299f461d2dcSChristoph Hellwig len -= *ppos; 300f461d2dcSChristoph Hellwig 301f461d2dcSChristoph Hellwig if (len > *lenp) 302f461d2dcSChristoph Hellwig len = *lenp; 303f461d2dcSChristoph Hellwig if (len) 30432927393SChristoph Hellwig memcpy(buffer, data, len); 305f461d2dcSChristoph Hellwig if (len < *lenp) { 30632927393SChristoph Hellwig buffer[len] = '\n'; 307f461d2dcSChristoph Hellwig len++; 308f461d2dcSChristoph Hellwig } 309f461d2dcSChristoph Hellwig *lenp = len; 310f461d2dcSChristoph Hellwig *ppos += len; 311f461d2dcSChristoph Hellwig } 312f461d2dcSChristoph Hellwig return 0; 313f461d2dcSChristoph Hellwig } 314f461d2dcSChristoph Hellwig 315f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table) 316f461d2dcSChristoph Hellwig { 317f461d2dcSChristoph Hellwig pr_warn_once("%s wrote to %s when file position was not 0!\n" 318f461d2dcSChristoph Hellwig "This will not be supported in the future. To silence this\n" 319f461d2dcSChristoph Hellwig "warning, set kernel.sysctl_writes_strict = -1\n", 320f461d2dcSChristoph Hellwig current->comm, table->procname); 321f461d2dcSChristoph Hellwig } 322f461d2dcSChristoph Hellwig 323f461d2dcSChristoph Hellwig /** 324f461d2dcSChristoph Hellwig * proc_first_pos_non_zero_ignore - check if first position is allowed 325f461d2dcSChristoph Hellwig * @ppos: file position 326f461d2dcSChristoph Hellwig * @table: the sysctl table 327f461d2dcSChristoph Hellwig * 328f461d2dcSChristoph Hellwig * Returns true if the first position is non-zero and the sysctl_writes_strict 329f461d2dcSChristoph Hellwig * mode indicates this is not allowed for numeric input types. String proc 330f461d2dcSChristoph Hellwig * handlers can ignore the return value. 331f461d2dcSChristoph Hellwig */ 332f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos, 333f461d2dcSChristoph Hellwig struct ctl_table *table) 334f461d2dcSChristoph Hellwig { 335f461d2dcSChristoph Hellwig if (!*ppos) 336f461d2dcSChristoph Hellwig return false; 337f461d2dcSChristoph Hellwig 338f461d2dcSChristoph Hellwig switch (sysctl_writes_strict) { 339f461d2dcSChristoph Hellwig case SYSCTL_WRITES_STRICT: 340f461d2dcSChristoph Hellwig return true; 341f461d2dcSChristoph Hellwig case SYSCTL_WRITES_WARN: 342f461d2dcSChristoph Hellwig warn_sysctl_write(table); 343f461d2dcSChristoph Hellwig return false; 344f461d2dcSChristoph Hellwig default: 345f461d2dcSChristoph Hellwig return false; 346f461d2dcSChristoph Hellwig } 347f461d2dcSChristoph Hellwig } 348f461d2dcSChristoph Hellwig 349f461d2dcSChristoph Hellwig /** 350f461d2dcSChristoph Hellwig * proc_dostring - read a string sysctl 351f461d2dcSChristoph Hellwig * @table: the sysctl table 352f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 353f461d2dcSChristoph Hellwig * @buffer: the user buffer 354f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 355f461d2dcSChristoph Hellwig * @ppos: file position 356f461d2dcSChristoph Hellwig * 357f461d2dcSChristoph Hellwig * Reads/writes a string from/to the user buffer. If the kernel 358f461d2dcSChristoph Hellwig * buffer provided is not large enough to hold the string, the 359f461d2dcSChristoph Hellwig * string is truncated. The copied string is %NULL-terminated. 360f461d2dcSChristoph Hellwig * If the string is being read by the user process, it is copied 361f461d2dcSChristoph Hellwig * and a newline '\n' is added. It is truncated if the buffer is 362f461d2dcSChristoph Hellwig * not large enough. 363f461d2dcSChristoph Hellwig * 364f461d2dcSChristoph Hellwig * Returns 0 on success. 365f461d2dcSChristoph Hellwig */ 366f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 36732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 368f461d2dcSChristoph Hellwig { 369f461d2dcSChristoph Hellwig if (write) 370f461d2dcSChristoph Hellwig proc_first_pos_non_zero_ignore(ppos, table); 371f461d2dcSChristoph Hellwig 37232927393SChristoph Hellwig return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, 37332927393SChristoph Hellwig ppos); 374f461d2dcSChristoph Hellwig } 375f461d2dcSChristoph Hellwig 376f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf) 377f461d2dcSChristoph Hellwig { 378f461d2dcSChristoph Hellwig size_t ret; 379f461d2dcSChristoph Hellwig char *tmp = skip_spaces(*buf); 380f461d2dcSChristoph Hellwig ret = tmp - *buf; 381f461d2dcSChristoph Hellwig *buf = tmp; 382f461d2dcSChristoph Hellwig return ret; 383f461d2dcSChristoph Hellwig } 384f461d2dcSChristoph Hellwig 385f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v) 386f461d2dcSChristoph Hellwig { 387f461d2dcSChristoph Hellwig while (*size) { 388f461d2dcSChristoph Hellwig if (**buf != v) 389f461d2dcSChristoph Hellwig break; 390f461d2dcSChristoph Hellwig (*size)--; 391f461d2dcSChristoph Hellwig (*buf)++; 392f461d2dcSChristoph Hellwig } 393f461d2dcSChristoph Hellwig } 394f461d2dcSChristoph Hellwig 395f461d2dcSChristoph Hellwig /** 396f461d2dcSChristoph Hellwig * strtoul_lenient - parse an ASCII formatted integer from a buffer and only 397f461d2dcSChristoph Hellwig * fail on overflow 398f461d2dcSChristoph Hellwig * 399f461d2dcSChristoph Hellwig * @cp: kernel buffer containing the string to parse 400f461d2dcSChristoph Hellwig * @endp: pointer to store the trailing characters 401f461d2dcSChristoph Hellwig * @base: the base to use 402f461d2dcSChristoph Hellwig * @res: where the parsed integer will be stored 403f461d2dcSChristoph Hellwig * 404f461d2dcSChristoph Hellwig * In case of success 0 is returned and @res will contain the parsed integer, 405f461d2dcSChristoph Hellwig * @endp will hold any trailing characters. 406f461d2dcSChristoph Hellwig * This function will fail the parse on overflow. If there wasn't an overflow 407f461d2dcSChristoph Hellwig * the function will defer the decision what characters count as invalid to the 408f461d2dcSChristoph Hellwig * caller. 409f461d2dcSChristoph Hellwig */ 410f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base, 411f461d2dcSChristoph Hellwig unsigned long *res) 412f461d2dcSChristoph Hellwig { 413f461d2dcSChristoph Hellwig unsigned long long result; 414f461d2dcSChristoph Hellwig unsigned int rv; 415f461d2dcSChristoph Hellwig 416f461d2dcSChristoph Hellwig cp = _parse_integer_fixup_radix(cp, &base); 417f461d2dcSChristoph Hellwig rv = _parse_integer(cp, base, &result); 418f461d2dcSChristoph Hellwig if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) 419f461d2dcSChristoph Hellwig return -ERANGE; 420f461d2dcSChristoph Hellwig 421f461d2dcSChristoph Hellwig cp += rv; 422f461d2dcSChristoph Hellwig 423f461d2dcSChristoph Hellwig if (endp) 424f461d2dcSChristoph Hellwig *endp = (char *)cp; 425f461d2dcSChristoph Hellwig 426f461d2dcSChristoph Hellwig *res = (unsigned long)result; 427f461d2dcSChristoph Hellwig return 0; 428f461d2dcSChristoph Hellwig } 429f461d2dcSChristoph Hellwig 430f461d2dcSChristoph Hellwig #define TMPBUFLEN 22 431f461d2dcSChristoph Hellwig /** 432f461d2dcSChristoph Hellwig * proc_get_long - reads an ASCII formatted integer from a user buffer 433f461d2dcSChristoph Hellwig * 434f461d2dcSChristoph Hellwig * @buf: a kernel buffer 435f461d2dcSChristoph Hellwig * @size: size of the kernel buffer 436f461d2dcSChristoph Hellwig * @val: this is where the number will be stored 437f461d2dcSChristoph Hellwig * @neg: set to %TRUE if number is negative 438f461d2dcSChristoph Hellwig * @perm_tr: a vector which contains the allowed trailers 439f461d2dcSChristoph Hellwig * @perm_tr_len: size of the perm_tr vector 440f461d2dcSChristoph Hellwig * @tr: pointer to store the trailer character 441f461d2dcSChristoph Hellwig * 442f461d2dcSChristoph Hellwig * In case of success %0 is returned and @buf and @size are updated with 443f461d2dcSChristoph Hellwig * the amount of bytes read. If @tr is non-NULL and a trailing 444f461d2dcSChristoph Hellwig * character exists (size is non-zero after returning from this 445f461d2dcSChristoph Hellwig * function), @tr is updated with the trailing character. 446f461d2dcSChristoph Hellwig */ 447f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size, 448f461d2dcSChristoph Hellwig unsigned long *val, bool *neg, 449f461d2dcSChristoph Hellwig const char *perm_tr, unsigned perm_tr_len, char *tr) 450f461d2dcSChristoph Hellwig { 451f461d2dcSChristoph Hellwig int len; 452f461d2dcSChristoph Hellwig char *p, tmp[TMPBUFLEN]; 453f461d2dcSChristoph Hellwig 454f461d2dcSChristoph Hellwig if (!*size) 455f461d2dcSChristoph Hellwig return -EINVAL; 456f461d2dcSChristoph Hellwig 457f461d2dcSChristoph Hellwig len = *size; 458f461d2dcSChristoph Hellwig if (len > TMPBUFLEN - 1) 459f461d2dcSChristoph Hellwig len = TMPBUFLEN - 1; 460f461d2dcSChristoph Hellwig 461f461d2dcSChristoph Hellwig memcpy(tmp, *buf, len); 462f461d2dcSChristoph Hellwig 463f461d2dcSChristoph Hellwig tmp[len] = 0; 464f461d2dcSChristoph Hellwig p = tmp; 465f461d2dcSChristoph Hellwig if (*p == '-' && *size > 1) { 466f461d2dcSChristoph Hellwig *neg = true; 467f461d2dcSChristoph Hellwig p++; 468f461d2dcSChristoph Hellwig } else 469f461d2dcSChristoph Hellwig *neg = false; 470f461d2dcSChristoph Hellwig if (!isdigit(*p)) 471f461d2dcSChristoph Hellwig return -EINVAL; 472f461d2dcSChristoph Hellwig 473f461d2dcSChristoph Hellwig if (strtoul_lenient(p, &p, 0, val)) 474f461d2dcSChristoph Hellwig return -EINVAL; 475f461d2dcSChristoph Hellwig 476f461d2dcSChristoph Hellwig len = p - tmp; 477f461d2dcSChristoph Hellwig 478f461d2dcSChristoph Hellwig /* We don't know if the next char is whitespace thus we may accept 479f461d2dcSChristoph Hellwig * invalid integers (e.g. 1234...a) or two integers instead of one 480f461d2dcSChristoph Hellwig * (e.g. 123...1). So lets not allow such large numbers. */ 481f461d2dcSChristoph Hellwig if (len == TMPBUFLEN - 1) 482f461d2dcSChristoph Hellwig return -EINVAL; 483f461d2dcSChristoph Hellwig 484f461d2dcSChristoph Hellwig if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 485f461d2dcSChristoph Hellwig return -EINVAL; 486f461d2dcSChristoph Hellwig 487f461d2dcSChristoph Hellwig if (tr && (len < *size)) 488f461d2dcSChristoph Hellwig *tr = *p; 489f461d2dcSChristoph Hellwig 490f461d2dcSChristoph Hellwig *buf += len; 491f461d2dcSChristoph Hellwig *size -= len; 492f461d2dcSChristoph Hellwig 493f461d2dcSChristoph Hellwig return 0; 494f461d2dcSChristoph Hellwig } 495f461d2dcSChristoph Hellwig 496f461d2dcSChristoph Hellwig /** 497f461d2dcSChristoph Hellwig * proc_put_long - converts an integer to a decimal ASCII formatted string 498f461d2dcSChristoph Hellwig * 499f461d2dcSChristoph Hellwig * @buf: the user buffer 500f461d2dcSChristoph Hellwig * @size: the size of the user buffer 501f461d2dcSChristoph Hellwig * @val: the integer to be converted 502f461d2dcSChristoph Hellwig * @neg: sign of the number, %TRUE for negative 503f461d2dcSChristoph Hellwig * 50432927393SChristoph Hellwig * In case of success @buf and @size are updated with the amount of bytes 50532927393SChristoph Hellwig * written. 506f461d2dcSChristoph Hellwig */ 50732927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg) 508f461d2dcSChristoph Hellwig { 509f461d2dcSChristoph Hellwig int len; 510f461d2dcSChristoph Hellwig char tmp[TMPBUFLEN], *p = tmp; 511f461d2dcSChristoph Hellwig 512f461d2dcSChristoph Hellwig sprintf(p, "%s%lu", neg ? "-" : "", val); 513f461d2dcSChristoph Hellwig len = strlen(tmp); 514f461d2dcSChristoph Hellwig if (len > *size) 515f461d2dcSChristoph Hellwig len = *size; 51632927393SChristoph Hellwig memcpy(*buf, tmp, len); 517f461d2dcSChristoph Hellwig *size -= len; 518f461d2dcSChristoph Hellwig *buf += len; 519f461d2dcSChristoph Hellwig } 520f461d2dcSChristoph Hellwig #undef TMPBUFLEN 521f461d2dcSChristoph Hellwig 52232927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c) 523f461d2dcSChristoph Hellwig { 524f461d2dcSChristoph Hellwig if (*size) { 52532927393SChristoph Hellwig char **buffer = (char **)buf; 52632927393SChristoph Hellwig **buffer = c; 52732927393SChristoph Hellwig 52832927393SChristoph Hellwig (*size)--; 52932927393SChristoph Hellwig (*buffer)++; 530f461d2dcSChristoph Hellwig *buf = *buffer; 531f461d2dcSChristoph Hellwig } 532f461d2dcSChristoph Hellwig } 533f461d2dcSChristoph Hellwig 534a2071573SJia He static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp, 535a2071573SJia He int *valp, 536a2071573SJia He int write, void *data) 537a2071573SJia He { 538a2071573SJia He if (write) { 539a2071573SJia He *(bool *)valp = *lvalp; 540a2071573SJia He } else { 541a2071573SJia He int val = *(bool *)valp; 542a2071573SJia He 543a2071573SJia He *lvalp = (unsigned long)val; 544a2071573SJia He *negp = false; 545a2071573SJia He } 546a2071573SJia He return 0; 547a2071573SJia He } 548a2071573SJia He 549f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 550f461d2dcSChristoph Hellwig int *valp, 551f461d2dcSChristoph Hellwig int write, void *data) 552f461d2dcSChristoph Hellwig { 553f461d2dcSChristoph Hellwig if (write) { 554f461d2dcSChristoph Hellwig if (*negp) { 555f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX + 1) 556f461d2dcSChristoph Hellwig return -EINVAL; 557f461d2dcSChristoph Hellwig *valp = -*lvalp; 558f461d2dcSChristoph Hellwig } else { 559f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX) 560f461d2dcSChristoph Hellwig return -EINVAL; 561f461d2dcSChristoph Hellwig *valp = *lvalp; 562f461d2dcSChristoph Hellwig } 563f461d2dcSChristoph Hellwig } else { 564f461d2dcSChristoph Hellwig int val = *valp; 565f461d2dcSChristoph Hellwig if (val < 0) { 566f461d2dcSChristoph Hellwig *negp = true; 567f461d2dcSChristoph Hellwig *lvalp = -(unsigned long)val; 568f461d2dcSChristoph Hellwig } else { 569f461d2dcSChristoph Hellwig *negp = false; 570f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 571f461d2dcSChristoph Hellwig } 572f461d2dcSChristoph Hellwig } 573f461d2dcSChristoph Hellwig return 0; 574f461d2dcSChristoph Hellwig } 575f461d2dcSChristoph Hellwig 576f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp, 577f461d2dcSChristoph Hellwig unsigned int *valp, 578f461d2dcSChristoph Hellwig int write, void *data) 579f461d2dcSChristoph Hellwig { 580f461d2dcSChristoph Hellwig if (write) { 581f461d2dcSChristoph Hellwig if (*lvalp > UINT_MAX) 582f461d2dcSChristoph Hellwig return -EINVAL; 583f461d2dcSChristoph Hellwig *valp = *lvalp; 584f461d2dcSChristoph Hellwig } else { 585f461d2dcSChristoph Hellwig unsigned int val = *valp; 586f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 587f461d2dcSChristoph Hellwig } 588f461d2dcSChristoph Hellwig return 0; 589f461d2dcSChristoph Hellwig } 590f461d2dcSChristoph Hellwig 591f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 592f461d2dcSChristoph Hellwig 593f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 59432927393SChristoph Hellwig int write, void *buffer, 595f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 596f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 597f461d2dcSChristoph Hellwig int write, void *data), 598f461d2dcSChristoph Hellwig void *data) 599f461d2dcSChristoph Hellwig { 600f461d2dcSChristoph Hellwig int *i, vleft, first = 1, err = 0; 601f461d2dcSChristoph Hellwig size_t left; 60232927393SChristoph Hellwig char *p; 603f461d2dcSChristoph Hellwig 604f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 605f461d2dcSChristoph Hellwig *lenp = 0; 606f461d2dcSChristoph Hellwig return 0; 607f461d2dcSChristoph Hellwig } 608f461d2dcSChristoph Hellwig 609f461d2dcSChristoph Hellwig i = (int *) tbl_data; 610f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 611f461d2dcSChristoph Hellwig left = *lenp; 612f461d2dcSChristoph Hellwig 613f461d2dcSChristoph Hellwig if (!conv) 614f461d2dcSChristoph Hellwig conv = do_proc_dointvec_conv; 615f461d2dcSChristoph Hellwig 616f461d2dcSChristoph Hellwig if (write) { 617f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 618f461d2dcSChristoph Hellwig goto out; 619f461d2dcSChristoph Hellwig 620f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 621f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 62232927393SChristoph Hellwig p = buffer; 623f461d2dcSChristoph Hellwig } 624f461d2dcSChristoph Hellwig 625f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first=0) { 626f461d2dcSChristoph Hellwig unsigned long lval; 627f461d2dcSChristoph Hellwig bool neg; 628f461d2dcSChristoph Hellwig 629f461d2dcSChristoph Hellwig if (write) { 630f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 631f461d2dcSChristoph Hellwig 632f461d2dcSChristoph Hellwig if (!left) 633f461d2dcSChristoph Hellwig break; 634f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 635f461d2dcSChristoph Hellwig proc_wspace_sep, 636f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 637f461d2dcSChristoph Hellwig if (err) 638f461d2dcSChristoph Hellwig break; 639f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 1, data)) { 640f461d2dcSChristoph Hellwig err = -EINVAL; 641f461d2dcSChristoph Hellwig break; 642f461d2dcSChristoph Hellwig } 643f461d2dcSChristoph Hellwig } else { 644f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 0, data)) { 645f461d2dcSChristoph Hellwig err = -EINVAL; 646f461d2dcSChristoph Hellwig break; 647f461d2dcSChristoph Hellwig } 648f461d2dcSChristoph Hellwig if (!first) 64932927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 65032927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, neg); 651f461d2dcSChristoph Hellwig } 652f461d2dcSChristoph Hellwig } 653f461d2dcSChristoph Hellwig 654f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 65532927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 656f461d2dcSChristoph Hellwig if (write && !err && left) 657f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 65832927393SChristoph Hellwig if (write && first) 659f461d2dcSChristoph Hellwig return err ? : -EINVAL; 660f461d2dcSChristoph Hellwig *lenp -= left; 661f461d2dcSChristoph Hellwig out: 662f461d2dcSChristoph Hellwig *ppos += *lenp; 663f461d2dcSChristoph Hellwig return err; 664f461d2dcSChristoph Hellwig } 665f461d2dcSChristoph Hellwig 666f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write, 66732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 668f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 669f461d2dcSChristoph Hellwig int write, void *data), 670f461d2dcSChristoph Hellwig void *data) 671f461d2dcSChristoph Hellwig { 672f461d2dcSChristoph Hellwig return __do_proc_dointvec(table->data, table, write, 673f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 674f461d2dcSChristoph Hellwig } 675f461d2dcSChristoph Hellwig 676f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data, 677f461d2dcSChristoph Hellwig struct ctl_table *table, 67832927393SChristoph Hellwig void *buffer, 679f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 680f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 681f461d2dcSChristoph Hellwig unsigned int *valp, 682f461d2dcSChristoph Hellwig int write, void *data), 683f461d2dcSChristoph Hellwig void *data) 684f461d2dcSChristoph Hellwig { 685f461d2dcSChristoph Hellwig unsigned long lval; 686f461d2dcSChristoph Hellwig int err = 0; 687f461d2dcSChristoph Hellwig size_t left; 688f461d2dcSChristoph Hellwig bool neg; 68932927393SChristoph Hellwig char *p = buffer; 690f461d2dcSChristoph Hellwig 691f461d2dcSChristoph Hellwig left = *lenp; 692f461d2dcSChristoph Hellwig 693f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 694f461d2dcSChristoph Hellwig goto bail_early; 695f461d2dcSChristoph Hellwig 696f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 697f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 698f461d2dcSChristoph Hellwig 699f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 700f461d2dcSChristoph Hellwig if (!left) { 701f461d2dcSChristoph Hellwig err = -EINVAL; 702f461d2dcSChristoph Hellwig goto out_free; 703f461d2dcSChristoph Hellwig } 704f461d2dcSChristoph Hellwig 705f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 706f461d2dcSChristoph Hellwig proc_wspace_sep, 707f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 708f461d2dcSChristoph Hellwig if (err || neg) { 709f461d2dcSChristoph Hellwig err = -EINVAL; 710f461d2dcSChristoph Hellwig goto out_free; 711f461d2dcSChristoph Hellwig } 712f461d2dcSChristoph Hellwig 713f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 1, data)) { 714f461d2dcSChristoph Hellwig err = -EINVAL; 715f461d2dcSChristoph Hellwig goto out_free; 716f461d2dcSChristoph Hellwig } 717f461d2dcSChristoph Hellwig 718f461d2dcSChristoph Hellwig if (!err && left) 719f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 720f461d2dcSChristoph Hellwig 721f461d2dcSChristoph Hellwig out_free: 722f461d2dcSChristoph Hellwig if (err) 723f461d2dcSChristoph Hellwig return -EINVAL; 724f461d2dcSChristoph Hellwig 725f461d2dcSChristoph Hellwig return 0; 726f461d2dcSChristoph Hellwig 727f461d2dcSChristoph Hellwig /* This is in keeping with old __do_proc_dointvec() */ 728f461d2dcSChristoph Hellwig bail_early: 729f461d2dcSChristoph Hellwig *ppos += *lenp; 730f461d2dcSChristoph Hellwig return err; 731f461d2dcSChristoph Hellwig } 732f461d2dcSChristoph Hellwig 73332927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer, 734f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 735f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 736f461d2dcSChristoph Hellwig unsigned int *valp, 737f461d2dcSChristoph Hellwig int write, void *data), 738f461d2dcSChristoph Hellwig void *data) 739f461d2dcSChristoph Hellwig { 740f461d2dcSChristoph Hellwig unsigned long lval; 741f461d2dcSChristoph Hellwig int err = 0; 742f461d2dcSChristoph Hellwig size_t left; 743f461d2dcSChristoph Hellwig 744f461d2dcSChristoph Hellwig left = *lenp; 745f461d2dcSChristoph Hellwig 746f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 0, data)) { 747f461d2dcSChristoph Hellwig err = -EINVAL; 748f461d2dcSChristoph Hellwig goto out; 749f461d2dcSChristoph Hellwig } 750f461d2dcSChristoph Hellwig 75132927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, false); 75232927393SChristoph Hellwig if (!left) 753f461d2dcSChristoph Hellwig goto out; 754f461d2dcSChristoph Hellwig 75532927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 756f461d2dcSChristoph Hellwig 757f461d2dcSChristoph Hellwig out: 758f461d2dcSChristoph Hellwig *lenp -= left; 759f461d2dcSChristoph Hellwig *ppos += *lenp; 760f461d2dcSChristoph Hellwig 761f461d2dcSChristoph Hellwig return err; 762f461d2dcSChristoph Hellwig } 763f461d2dcSChristoph Hellwig 764f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, 76532927393SChristoph Hellwig int write, void *buffer, 766f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 767f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 768f461d2dcSChristoph Hellwig unsigned int *valp, 769f461d2dcSChristoph Hellwig int write, void *data), 770f461d2dcSChristoph Hellwig void *data) 771f461d2dcSChristoph Hellwig { 772f461d2dcSChristoph Hellwig unsigned int *i, vleft; 773f461d2dcSChristoph Hellwig 774f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 775f461d2dcSChristoph Hellwig *lenp = 0; 776f461d2dcSChristoph Hellwig return 0; 777f461d2dcSChristoph Hellwig } 778f461d2dcSChristoph Hellwig 779f461d2dcSChristoph Hellwig i = (unsigned int *) tbl_data; 780f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 781f461d2dcSChristoph Hellwig 782f461d2dcSChristoph Hellwig /* 783f461d2dcSChristoph Hellwig * Arrays are not supported, keep this simple. *Do not* add 784f461d2dcSChristoph Hellwig * support for them. 785f461d2dcSChristoph Hellwig */ 786f461d2dcSChristoph Hellwig if (vleft != 1) { 787f461d2dcSChristoph Hellwig *lenp = 0; 788f461d2dcSChristoph Hellwig return -EINVAL; 789f461d2dcSChristoph Hellwig } 790f461d2dcSChristoph Hellwig 791f461d2dcSChristoph Hellwig if (!conv) 792f461d2dcSChristoph Hellwig conv = do_proc_douintvec_conv; 793f461d2dcSChristoph Hellwig 794f461d2dcSChristoph Hellwig if (write) 795f461d2dcSChristoph Hellwig return do_proc_douintvec_w(i, table, buffer, lenp, ppos, 796f461d2dcSChristoph Hellwig conv, data); 797f461d2dcSChristoph Hellwig return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); 798f461d2dcSChristoph Hellwig } 799f461d2dcSChristoph Hellwig 800f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write, 80132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 802f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 803f461d2dcSChristoph Hellwig unsigned int *valp, 804f461d2dcSChristoph Hellwig int write, void *data), 805f461d2dcSChristoph Hellwig void *data) 806f461d2dcSChristoph Hellwig { 807f461d2dcSChristoph Hellwig return __do_proc_douintvec(table->data, table, write, 808f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 809f461d2dcSChristoph Hellwig } 810f461d2dcSChristoph Hellwig 811f461d2dcSChristoph Hellwig /** 812a2071573SJia He * proc_dobool - read/write a bool 813a2071573SJia He * @table: the sysctl table 814a2071573SJia He * @write: %TRUE if this is a write to the sysctl file 815a2071573SJia He * @buffer: the user buffer 816a2071573SJia He * @lenp: the size of the user buffer 817a2071573SJia He * @ppos: file position 818a2071573SJia He * 819a2071573SJia He * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 820a2071573SJia He * values from/to the user buffer, treated as an ASCII string. 821a2071573SJia He * 822a2071573SJia He * Returns 0 on success. 823a2071573SJia He */ 824a2071573SJia He int proc_dobool(struct ctl_table *table, int write, void *buffer, 825a2071573SJia He size_t *lenp, loff_t *ppos) 826a2071573SJia He { 827a2071573SJia He return do_proc_dointvec(table, write, buffer, lenp, ppos, 828a2071573SJia He do_proc_dobool_conv, NULL); 829a2071573SJia He } 830a2071573SJia He 831a2071573SJia He /** 832f461d2dcSChristoph Hellwig * proc_dointvec - read a vector of integers 833f461d2dcSChristoph Hellwig * @table: the sysctl table 834f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 835f461d2dcSChristoph Hellwig * @buffer: the user buffer 836f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 837f461d2dcSChristoph Hellwig * @ppos: file position 838f461d2dcSChristoph Hellwig * 839f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 840f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 841f461d2dcSChristoph Hellwig * 842f461d2dcSChristoph Hellwig * Returns 0 on success. 843f461d2dcSChristoph Hellwig */ 84432927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer, 84532927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 846f461d2dcSChristoph Hellwig { 847f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 848f461d2dcSChristoph Hellwig } 849f461d2dcSChristoph Hellwig 850f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION 851f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, 85232927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos) 853f461d2dcSChristoph Hellwig { 854f461d2dcSChristoph Hellwig int ret, old; 855f461d2dcSChristoph Hellwig 856f461d2dcSChristoph Hellwig if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) 857f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 858f461d2dcSChristoph Hellwig 859f461d2dcSChristoph Hellwig old = *(int *)table->data; 860f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 861f461d2dcSChristoph Hellwig if (ret) 862f461d2dcSChristoph Hellwig return ret; 863f461d2dcSChristoph Hellwig if (old != *(int *)table->data) 864f461d2dcSChristoph Hellwig pr_warn_once("sysctl attribute %s changed by %s[%d]\n", 865f461d2dcSChristoph Hellwig table->procname, current->comm, 866f461d2dcSChristoph Hellwig task_pid_nr(current)); 867f461d2dcSChristoph Hellwig return ret; 868f461d2dcSChristoph Hellwig } 869f461d2dcSChristoph Hellwig #endif 870f461d2dcSChristoph Hellwig 871f461d2dcSChristoph Hellwig /** 872f461d2dcSChristoph Hellwig * proc_douintvec - read a vector of unsigned integers 873f461d2dcSChristoph Hellwig * @table: the sysctl table 874f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 875f461d2dcSChristoph Hellwig * @buffer: the user buffer 876f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 877f461d2dcSChristoph Hellwig * @ppos: file position 878f461d2dcSChristoph Hellwig * 879f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 880f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 881f461d2dcSChristoph Hellwig * 882f461d2dcSChristoph Hellwig * Returns 0 on success. 883f461d2dcSChristoph Hellwig */ 88432927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer, 88532927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 886f461d2dcSChristoph Hellwig { 887f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 888f461d2dcSChristoph Hellwig do_proc_douintvec_conv, NULL); 889f461d2dcSChristoph Hellwig } 890f461d2dcSChristoph Hellwig 891f461d2dcSChristoph Hellwig /* 892f461d2dcSChristoph Hellwig * Taint values can only be increased 893f461d2dcSChristoph Hellwig * This means we can safely use a temporary. 894f461d2dcSChristoph Hellwig */ 895f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write, 89632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 897f461d2dcSChristoph Hellwig { 898f461d2dcSChristoph Hellwig struct ctl_table t; 899f461d2dcSChristoph Hellwig unsigned long tmptaint = get_taint(); 900f461d2dcSChristoph Hellwig int err; 901f461d2dcSChristoph Hellwig 902f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 903f461d2dcSChristoph Hellwig return -EPERM; 904f461d2dcSChristoph Hellwig 905f461d2dcSChristoph Hellwig t = *table; 906f461d2dcSChristoph Hellwig t.data = &tmptaint; 907f461d2dcSChristoph Hellwig err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 908f461d2dcSChristoph Hellwig if (err < 0) 909f461d2dcSChristoph Hellwig return err; 910f461d2dcSChristoph Hellwig 911f461d2dcSChristoph Hellwig if (write) { 912db38d5c1SRafael Aquini int i; 913db38d5c1SRafael Aquini 914db38d5c1SRafael Aquini /* 915db38d5c1SRafael Aquini * If we are relying on panic_on_taint not producing 916db38d5c1SRafael Aquini * false positives due to userspace input, bail out 917db38d5c1SRafael Aquini * before setting the requested taint flags. 918db38d5c1SRafael Aquini */ 919db38d5c1SRafael Aquini if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint)) 920db38d5c1SRafael Aquini return -EINVAL; 921db38d5c1SRafael Aquini 922f461d2dcSChristoph Hellwig /* 923f461d2dcSChristoph Hellwig * Poor man's atomic or. Not worth adding a primitive 924f461d2dcSChristoph Hellwig * to everyone's atomic.h for this 925f461d2dcSChristoph Hellwig */ 926e77132e7SRafael Aquini for (i = 0; i < TAINT_FLAGS_COUNT; i++) 927e77132e7SRafael Aquini if ((1UL << i) & tmptaint) 928f461d2dcSChristoph Hellwig add_taint(i, LOCKDEP_STILL_OK); 929f461d2dcSChristoph Hellwig } 930f461d2dcSChristoph Hellwig 931f461d2dcSChristoph Hellwig return err; 932f461d2dcSChristoph Hellwig } 933f461d2dcSChristoph Hellwig 934f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK 935f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 93632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 937f461d2dcSChristoph Hellwig { 938f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 939f461d2dcSChristoph Hellwig return -EPERM; 940f461d2dcSChristoph Hellwig 941f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 942f461d2dcSChristoph Hellwig } 943f461d2dcSChristoph Hellwig #endif 944f461d2dcSChristoph Hellwig 945f461d2dcSChristoph Hellwig /** 946f461d2dcSChristoph Hellwig * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure 947f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 948f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 949f461d2dcSChristoph Hellwig * 950f461d2dcSChristoph Hellwig * The do_proc_dointvec_minmax_conv_param structure provides the 951f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 952f461d2dcSChristoph Hellwig * parameters that use the proc_dointvec_minmax() handler. 953f461d2dcSChristoph Hellwig */ 954f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param { 955f461d2dcSChristoph Hellwig int *min; 956f461d2dcSChristoph Hellwig int *max; 957f461d2dcSChristoph Hellwig }; 958f461d2dcSChristoph Hellwig 959f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 960f461d2dcSChristoph Hellwig int *valp, 961f461d2dcSChristoph Hellwig int write, void *data) 962f461d2dcSChristoph Hellwig { 963f461d2dcSChristoph Hellwig int tmp, ret; 964f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param *param = data; 965f461d2dcSChristoph Hellwig /* 966f461d2dcSChristoph Hellwig * If writing, first do so via a temporary local int so we can 967f461d2dcSChristoph Hellwig * bounds-check it before touching *valp. 968f461d2dcSChristoph Hellwig */ 969f461d2dcSChristoph Hellwig int *ip = write ? &tmp : valp; 970f461d2dcSChristoph Hellwig 971f461d2dcSChristoph Hellwig ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); 972f461d2dcSChristoph Hellwig if (ret) 973f461d2dcSChristoph Hellwig return ret; 974f461d2dcSChristoph Hellwig 975f461d2dcSChristoph Hellwig if (write) { 976f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 977f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 978f461d2dcSChristoph Hellwig return -EINVAL; 979f461d2dcSChristoph Hellwig *valp = tmp; 980f461d2dcSChristoph Hellwig } 981f461d2dcSChristoph Hellwig 982f461d2dcSChristoph Hellwig return 0; 983f461d2dcSChristoph Hellwig } 984f461d2dcSChristoph Hellwig 985f461d2dcSChristoph Hellwig /** 986f461d2dcSChristoph Hellwig * proc_dointvec_minmax - read a vector of integers with min/max values 987f461d2dcSChristoph Hellwig * @table: the sysctl table 988f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 989f461d2dcSChristoph Hellwig * @buffer: the user buffer 990f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 991f461d2dcSChristoph Hellwig * @ppos: file position 992f461d2dcSChristoph Hellwig * 993f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 994f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 995f461d2dcSChristoph Hellwig * 996f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 997f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 998f461d2dcSChristoph Hellwig * 999f461d2dcSChristoph Hellwig * Returns 0 on success or -EINVAL on write when the range check fails. 1000f461d2dcSChristoph Hellwig */ 1001f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 100232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1003f461d2dcSChristoph Hellwig { 1004f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param param = { 1005f461d2dcSChristoph Hellwig .min = (int *) table->extra1, 1006f461d2dcSChristoph Hellwig .max = (int *) table->extra2, 1007f461d2dcSChristoph Hellwig }; 1008f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 1009f461d2dcSChristoph Hellwig do_proc_dointvec_minmax_conv, ¶m); 1010f461d2dcSChristoph Hellwig } 1011f461d2dcSChristoph Hellwig 1012f461d2dcSChristoph Hellwig /** 1013f461d2dcSChristoph Hellwig * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure 1014f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 1015f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 1016f461d2dcSChristoph Hellwig * 1017f461d2dcSChristoph Hellwig * The do_proc_douintvec_minmax_conv_param structure provides the 1018f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 1019f461d2dcSChristoph Hellwig * parameters that use the proc_douintvec_minmax() handler. 1020f461d2dcSChristoph Hellwig */ 1021f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param { 1022f461d2dcSChristoph Hellwig unsigned int *min; 1023f461d2dcSChristoph Hellwig unsigned int *max; 1024f461d2dcSChristoph Hellwig }; 1025f461d2dcSChristoph Hellwig 1026f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, 1027f461d2dcSChristoph Hellwig unsigned int *valp, 1028f461d2dcSChristoph Hellwig int write, void *data) 1029f461d2dcSChristoph Hellwig { 1030f461d2dcSChristoph Hellwig int ret; 1031f461d2dcSChristoph Hellwig unsigned int tmp; 1032f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param *param = data; 1033f461d2dcSChristoph Hellwig /* write via temporary local uint for bounds-checking */ 1034f461d2dcSChristoph Hellwig unsigned int *up = write ? &tmp : valp; 1035f461d2dcSChristoph Hellwig 1036f461d2dcSChristoph Hellwig ret = do_proc_douintvec_conv(lvalp, up, write, data); 1037f461d2dcSChristoph Hellwig if (ret) 1038f461d2dcSChristoph Hellwig return ret; 1039f461d2dcSChristoph Hellwig 1040f461d2dcSChristoph Hellwig if (write) { 1041f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 1042f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 1043f461d2dcSChristoph Hellwig return -ERANGE; 1044f461d2dcSChristoph Hellwig 1045f461d2dcSChristoph Hellwig *valp = tmp; 1046f461d2dcSChristoph Hellwig } 1047f461d2dcSChristoph Hellwig 1048f461d2dcSChristoph Hellwig return 0; 1049f461d2dcSChristoph Hellwig } 1050f461d2dcSChristoph Hellwig 1051f461d2dcSChristoph Hellwig /** 1052f461d2dcSChristoph Hellwig * proc_douintvec_minmax - read a vector of unsigned ints with min/max values 1053f461d2dcSChristoph Hellwig * @table: the sysctl table 1054f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1055f461d2dcSChristoph Hellwig * @buffer: the user buffer 1056f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1057f461d2dcSChristoph Hellwig * @ppos: file position 1058f461d2dcSChristoph Hellwig * 1059f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 1060f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. Negative 1061f461d2dcSChristoph Hellwig * strings are not allowed. 1062f461d2dcSChristoph Hellwig * 1063f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1064f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). There is a final sanity 1065f461d2dcSChristoph Hellwig * check for UINT_MAX to avoid having to support wrap around uses from 1066f461d2dcSChristoph Hellwig * userspace. 1067f461d2dcSChristoph Hellwig * 1068f461d2dcSChristoph Hellwig * Returns 0 on success or -ERANGE on write when the range check fails. 1069f461d2dcSChristoph Hellwig */ 1070f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 107132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1072f461d2dcSChristoph Hellwig { 1073f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param param = { 1074f461d2dcSChristoph Hellwig .min = (unsigned int *) table->extra1, 1075f461d2dcSChristoph Hellwig .max = (unsigned int *) table->extra2, 1076f461d2dcSChristoph Hellwig }; 1077f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1078f461d2dcSChristoph Hellwig do_proc_douintvec_minmax_conv, ¶m); 1079f461d2dcSChristoph Hellwig } 1080f461d2dcSChristoph Hellwig 1081cb944413SEric Dumazet /** 1082cb944413SEric Dumazet * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values 1083cb944413SEric Dumazet * @table: the sysctl table 1084cb944413SEric Dumazet * @write: %TRUE if this is a write to the sysctl file 1085cb944413SEric Dumazet * @buffer: the user buffer 1086cb944413SEric Dumazet * @lenp: the size of the user buffer 1087cb944413SEric Dumazet * @ppos: file position 1088cb944413SEric Dumazet * 1089cb944413SEric Dumazet * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars 1090cb944413SEric Dumazet * values from/to the user buffer, treated as an ASCII string. Negative 1091cb944413SEric Dumazet * strings are not allowed. 1092cb944413SEric Dumazet * 1093cb944413SEric Dumazet * This routine will ensure the values are within the range specified by 1094cb944413SEric Dumazet * table->extra1 (min) and table->extra2 (max). 1095cb944413SEric Dumazet * 1096cb944413SEric Dumazet * Returns 0 on success or an error on write when the range check fails. 1097cb944413SEric Dumazet */ 1098cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write, 1099cb944413SEric Dumazet void *buffer, size_t *lenp, loff_t *ppos) 1100cb944413SEric Dumazet { 1101cb944413SEric Dumazet struct ctl_table tmp; 1102cb944413SEric Dumazet unsigned int min = 0, max = 255U, val; 1103cb944413SEric Dumazet u8 *data = table->data; 1104cb944413SEric Dumazet struct do_proc_douintvec_minmax_conv_param param = { 1105cb944413SEric Dumazet .min = &min, 1106cb944413SEric Dumazet .max = &max, 1107cb944413SEric Dumazet }; 1108cb944413SEric Dumazet int res; 1109cb944413SEric Dumazet 1110cb944413SEric Dumazet /* Do not support arrays yet. */ 1111cb944413SEric Dumazet if (table->maxlen != sizeof(u8)) 1112cb944413SEric Dumazet return -EINVAL; 1113cb944413SEric Dumazet 1114cb944413SEric Dumazet if (table->extra1) { 1115cb944413SEric Dumazet min = *(unsigned int *) table->extra1; 1116cb944413SEric Dumazet if (min > 255U) 1117cb944413SEric Dumazet return -EINVAL; 1118cb944413SEric Dumazet } 1119cb944413SEric Dumazet if (table->extra2) { 1120cb944413SEric Dumazet max = *(unsigned int *) table->extra2; 1121cb944413SEric Dumazet if (max > 255U) 1122cb944413SEric Dumazet return -EINVAL; 1123cb944413SEric Dumazet } 1124cb944413SEric Dumazet 1125cb944413SEric Dumazet tmp = *table; 1126cb944413SEric Dumazet 1127cb944413SEric Dumazet tmp.maxlen = sizeof(val); 1128cb944413SEric Dumazet tmp.data = &val; 1129cb944413SEric Dumazet val = *data; 1130cb944413SEric Dumazet res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos, 1131cb944413SEric Dumazet do_proc_douintvec_minmax_conv, ¶m); 1132cb944413SEric Dumazet if (res) 1133cb944413SEric Dumazet return res; 1134cb944413SEric Dumazet if (write) 1135cb944413SEric Dumazet *data = val; 1136cb944413SEric Dumazet return 0; 1137cb944413SEric Dumazet } 1138cb944413SEric Dumazet EXPORT_SYMBOL_GPL(proc_dou8vec_minmax); 1139cb944413SEric Dumazet 1140f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp, 1141f461d2dcSChristoph Hellwig unsigned int *valp, 1142f461d2dcSChristoph Hellwig int write, void *data) 1143f461d2dcSChristoph Hellwig { 1144f461d2dcSChristoph Hellwig if (write) { 1145f461d2dcSChristoph Hellwig unsigned int val; 1146f461d2dcSChristoph Hellwig 1147f461d2dcSChristoph Hellwig val = round_pipe_size(*lvalp); 1148f461d2dcSChristoph Hellwig if (val == 0) 1149f461d2dcSChristoph Hellwig return -EINVAL; 1150f461d2dcSChristoph Hellwig 1151f461d2dcSChristoph Hellwig *valp = val; 1152f461d2dcSChristoph Hellwig } else { 1153f461d2dcSChristoph Hellwig unsigned int val = *valp; 1154f461d2dcSChristoph Hellwig *lvalp = (unsigned long) val; 1155f461d2dcSChristoph Hellwig } 1156f461d2dcSChristoph Hellwig 1157f461d2dcSChristoph Hellwig return 0; 1158f461d2dcSChristoph Hellwig } 1159f461d2dcSChristoph Hellwig 1160f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write, 116132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1162f461d2dcSChristoph Hellwig { 1163f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1164f461d2dcSChristoph Hellwig do_proc_dopipe_max_size_conv, NULL); 1165f461d2dcSChristoph Hellwig } 1166f461d2dcSChristoph Hellwig 1167f461d2dcSChristoph Hellwig static void validate_coredump_safety(void) 1168f461d2dcSChristoph Hellwig { 1169f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1170f461d2dcSChristoph Hellwig if (suid_dumpable == SUID_DUMP_ROOT && 1171f461d2dcSChristoph Hellwig core_pattern[0] != '/' && core_pattern[0] != '|') { 1172f461d2dcSChristoph Hellwig printk(KERN_WARNING 1173f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n" 1174f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n" 1175f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n" 1176f461d2dcSChristoph Hellwig ); 1177f461d2dcSChristoph Hellwig } 1178f461d2dcSChristoph Hellwig #endif 1179f461d2dcSChristoph Hellwig } 1180f461d2dcSChristoph Hellwig 1181f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 118232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1183f461d2dcSChristoph Hellwig { 1184f461d2dcSChristoph Hellwig int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 1185f461d2dcSChristoph Hellwig if (!error) 1186f461d2dcSChristoph Hellwig validate_coredump_safety(); 1187f461d2dcSChristoph Hellwig return error; 1188f461d2dcSChristoph Hellwig } 1189f461d2dcSChristoph Hellwig 1190f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1191f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write, 119232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1193f461d2dcSChristoph Hellwig { 1194f461d2dcSChristoph Hellwig int error = proc_dostring(table, write, buffer, lenp, ppos); 1195f461d2dcSChristoph Hellwig if (!error) 1196f461d2dcSChristoph Hellwig validate_coredump_safety(); 1197f461d2dcSChristoph Hellwig return error; 1198f461d2dcSChristoph Hellwig } 1199f461d2dcSChristoph Hellwig #endif 1200f461d2dcSChristoph Hellwig 1201f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ 1202f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write, 120332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1204f461d2dcSChristoph Hellwig { 1205f461d2dcSChristoph Hellwig int tmp, ret; 1206f461d2dcSChristoph Hellwig 1207f461d2dcSChristoph Hellwig tmp = sysrq_mask(); 1208f461d2dcSChristoph Hellwig 1209f461d2dcSChristoph Hellwig ret = __do_proc_dointvec(&tmp, table, write, buffer, 1210f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1211f461d2dcSChristoph Hellwig if (ret || !write) 1212f461d2dcSChristoph Hellwig return ret; 1213f461d2dcSChristoph Hellwig 1214f461d2dcSChristoph Hellwig if (write) 1215f461d2dcSChristoph Hellwig sysrq_toggle_support(tmp); 1216f461d2dcSChristoph Hellwig 1217f461d2dcSChristoph Hellwig return 0; 1218f461d2dcSChristoph Hellwig } 1219f461d2dcSChristoph Hellwig #endif 1220f461d2dcSChristoph Hellwig 122132927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, 122232927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos, 122332927393SChristoph Hellwig unsigned long convmul, unsigned long convdiv) 1224f461d2dcSChristoph Hellwig { 1225f461d2dcSChristoph Hellwig unsigned long *i, *min, *max; 1226f461d2dcSChristoph Hellwig int vleft, first = 1, err = 0; 1227f461d2dcSChristoph Hellwig size_t left; 122832927393SChristoph Hellwig char *p; 1229f461d2dcSChristoph Hellwig 1230f461d2dcSChristoph Hellwig if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 1231f461d2dcSChristoph Hellwig *lenp = 0; 1232f461d2dcSChristoph Hellwig return 0; 1233f461d2dcSChristoph Hellwig } 1234f461d2dcSChristoph Hellwig 1235f461d2dcSChristoph Hellwig i = (unsigned long *) data; 1236f461d2dcSChristoph Hellwig min = (unsigned long *) table->extra1; 1237f461d2dcSChristoph Hellwig max = (unsigned long *) table->extra2; 1238f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(unsigned long); 1239f461d2dcSChristoph Hellwig left = *lenp; 1240f461d2dcSChristoph Hellwig 1241f461d2dcSChristoph Hellwig if (write) { 1242f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 1243f461d2dcSChristoph Hellwig goto out; 1244f461d2dcSChristoph Hellwig 1245f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 1246f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 124732927393SChristoph Hellwig p = buffer; 1248f461d2dcSChristoph Hellwig } 1249f461d2dcSChristoph Hellwig 1250f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first = 0) { 1251f461d2dcSChristoph Hellwig unsigned long val; 1252f461d2dcSChristoph Hellwig 1253f461d2dcSChristoph Hellwig if (write) { 1254f461d2dcSChristoph Hellwig bool neg; 1255f461d2dcSChristoph Hellwig 1256f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 1257f461d2dcSChristoph Hellwig if (!left) 1258f461d2dcSChristoph Hellwig break; 1259f461d2dcSChristoph Hellwig 1260f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val, &neg, 1261f461d2dcSChristoph Hellwig proc_wspace_sep, 1262f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 1263f461d2dcSChristoph Hellwig if (err) 1264f461d2dcSChristoph Hellwig break; 1265f461d2dcSChristoph Hellwig if (neg) 1266f461d2dcSChristoph Hellwig continue; 1267f461d2dcSChristoph Hellwig val = convmul * val / convdiv; 1268f461d2dcSChristoph Hellwig if ((min && val < *min) || (max && val > *max)) { 1269f461d2dcSChristoph Hellwig err = -EINVAL; 1270f461d2dcSChristoph Hellwig break; 1271f461d2dcSChristoph Hellwig } 1272f461d2dcSChristoph Hellwig *i = val; 1273f461d2dcSChristoph Hellwig } else { 1274f461d2dcSChristoph Hellwig val = convdiv * (*i) / convmul; 127532927393SChristoph Hellwig if (!first) 127632927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 127732927393SChristoph Hellwig proc_put_long(&buffer, &left, val, false); 1278f461d2dcSChristoph Hellwig } 1279f461d2dcSChristoph Hellwig } 1280f461d2dcSChristoph Hellwig 1281f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 128232927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1283f461d2dcSChristoph Hellwig if (write && !err) 1284f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 128532927393SChristoph Hellwig if (write && first) 1286f461d2dcSChristoph Hellwig return err ? : -EINVAL; 1287f461d2dcSChristoph Hellwig *lenp -= left; 1288f461d2dcSChristoph Hellwig out: 1289f461d2dcSChristoph Hellwig *ppos += *lenp; 1290f461d2dcSChristoph Hellwig return err; 1291f461d2dcSChristoph Hellwig } 1292f461d2dcSChristoph Hellwig 1293f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 129432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, 1295f461d2dcSChristoph Hellwig unsigned long convdiv) 1296f461d2dcSChristoph Hellwig { 1297f461d2dcSChristoph Hellwig return __do_proc_doulongvec_minmax(table->data, table, write, 1298f461d2dcSChristoph Hellwig buffer, lenp, ppos, convmul, convdiv); 1299f461d2dcSChristoph Hellwig } 1300f461d2dcSChristoph Hellwig 1301f461d2dcSChristoph Hellwig /** 1302f461d2dcSChristoph Hellwig * proc_doulongvec_minmax - read a vector of long integers with min/max values 1303f461d2dcSChristoph Hellwig * @table: the sysctl table 1304f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1305f461d2dcSChristoph Hellwig * @buffer: the user buffer 1306f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1307f461d2dcSChristoph Hellwig * @ppos: file position 1308f461d2dcSChristoph Hellwig * 1309f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1310f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1311f461d2dcSChristoph Hellwig * 1312f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1313f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1314f461d2dcSChristoph Hellwig * 1315f461d2dcSChristoph Hellwig * Returns 0 on success. 1316f461d2dcSChristoph Hellwig */ 1317f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 131832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1319f461d2dcSChristoph Hellwig { 1320f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 1321f461d2dcSChristoph Hellwig } 1322f461d2dcSChristoph Hellwig 1323f461d2dcSChristoph Hellwig /** 1324f461d2dcSChristoph Hellwig * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 1325f461d2dcSChristoph Hellwig * @table: the sysctl table 1326f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1327f461d2dcSChristoph Hellwig * @buffer: the user buffer 1328f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1329f461d2dcSChristoph Hellwig * @ppos: file position 1330f461d2dcSChristoph Hellwig * 1331f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1332f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. The values 1333f461d2dcSChristoph Hellwig * are treated as milliseconds, and converted to jiffies when they are stored. 1334f461d2dcSChristoph Hellwig * 1335f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1336f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1337f461d2dcSChristoph Hellwig * 1338f461d2dcSChristoph Hellwig * Returns 0 on success. 1339f461d2dcSChristoph Hellwig */ 1340f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 134132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1342f461d2dcSChristoph Hellwig { 1343f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, 1344f461d2dcSChristoph Hellwig lenp, ppos, HZ, 1000l); 1345f461d2dcSChristoph Hellwig } 1346f461d2dcSChristoph Hellwig 1347f461d2dcSChristoph Hellwig 1348f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 1349f461d2dcSChristoph Hellwig int *valp, 1350f461d2dcSChristoph Hellwig int write, void *data) 1351f461d2dcSChristoph Hellwig { 1352f461d2dcSChristoph Hellwig if (write) { 1353f461d2dcSChristoph Hellwig if (*lvalp > INT_MAX / HZ) 1354f461d2dcSChristoph Hellwig return 1; 1355f461d2dcSChristoph Hellwig *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 1356f461d2dcSChristoph Hellwig } else { 1357f461d2dcSChristoph Hellwig int val = *valp; 1358f461d2dcSChristoph Hellwig unsigned long lval; 1359f461d2dcSChristoph Hellwig if (val < 0) { 1360f461d2dcSChristoph Hellwig *negp = true; 1361f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1362f461d2dcSChristoph Hellwig } else { 1363f461d2dcSChristoph Hellwig *negp = false; 1364f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1365f461d2dcSChristoph Hellwig } 1366f461d2dcSChristoph Hellwig *lvalp = lval / HZ; 1367f461d2dcSChristoph Hellwig } 1368f461d2dcSChristoph Hellwig return 0; 1369f461d2dcSChristoph Hellwig } 1370f461d2dcSChristoph Hellwig 1371f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 1372f461d2dcSChristoph Hellwig int *valp, 1373f461d2dcSChristoph Hellwig int write, void *data) 1374f461d2dcSChristoph Hellwig { 1375f461d2dcSChristoph Hellwig if (write) { 1376f461d2dcSChristoph Hellwig if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 1377f461d2dcSChristoph Hellwig return 1; 1378f461d2dcSChristoph Hellwig *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 1379f461d2dcSChristoph Hellwig } else { 1380f461d2dcSChristoph Hellwig int val = *valp; 1381f461d2dcSChristoph Hellwig unsigned long lval; 1382f461d2dcSChristoph Hellwig if (val < 0) { 1383f461d2dcSChristoph Hellwig *negp = true; 1384f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1385f461d2dcSChristoph Hellwig } else { 1386f461d2dcSChristoph Hellwig *negp = false; 1387f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1388f461d2dcSChristoph Hellwig } 1389f461d2dcSChristoph Hellwig *lvalp = jiffies_to_clock_t(lval); 1390f461d2dcSChristoph Hellwig } 1391f461d2dcSChristoph Hellwig return 0; 1392f461d2dcSChristoph Hellwig } 1393f461d2dcSChristoph Hellwig 1394f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 1395f461d2dcSChristoph Hellwig int *valp, 1396f461d2dcSChristoph Hellwig int write, void *data) 1397f461d2dcSChristoph Hellwig { 1398f461d2dcSChristoph Hellwig if (write) { 1399f461d2dcSChristoph Hellwig unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 1400f461d2dcSChristoph Hellwig 1401f461d2dcSChristoph Hellwig if (jif > INT_MAX) 1402f461d2dcSChristoph Hellwig return 1; 1403f461d2dcSChristoph Hellwig *valp = (int)jif; 1404f461d2dcSChristoph Hellwig } else { 1405f461d2dcSChristoph Hellwig int val = *valp; 1406f461d2dcSChristoph Hellwig unsigned long lval; 1407f461d2dcSChristoph Hellwig if (val < 0) { 1408f461d2dcSChristoph Hellwig *negp = true; 1409f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1410f461d2dcSChristoph Hellwig } else { 1411f461d2dcSChristoph Hellwig *negp = false; 1412f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1413f461d2dcSChristoph Hellwig } 1414f461d2dcSChristoph Hellwig *lvalp = jiffies_to_msecs(lval); 1415f461d2dcSChristoph Hellwig } 1416f461d2dcSChristoph Hellwig return 0; 1417f461d2dcSChristoph Hellwig } 1418f461d2dcSChristoph Hellwig 1419f461d2dcSChristoph Hellwig /** 1420f461d2dcSChristoph Hellwig * proc_dointvec_jiffies - read a vector of integers as seconds 1421f461d2dcSChristoph Hellwig * @table: the sysctl table 1422f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1423f461d2dcSChristoph Hellwig * @buffer: the user buffer 1424f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1425f461d2dcSChristoph Hellwig * @ppos: file position 1426f461d2dcSChristoph Hellwig * 1427f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1428f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1429f461d2dcSChristoph Hellwig * The values read are assumed to be in seconds, and are converted into 1430f461d2dcSChristoph Hellwig * jiffies. 1431f461d2dcSChristoph Hellwig * 1432f461d2dcSChristoph Hellwig * Returns 0 on success. 1433f461d2dcSChristoph Hellwig */ 1434f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 143532927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1436f461d2dcSChristoph Hellwig { 1437f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1438f461d2dcSChristoph Hellwig do_proc_dointvec_jiffies_conv,NULL); 1439f461d2dcSChristoph Hellwig } 1440f461d2dcSChristoph Hellwig 1441f461d2dcSChristoph Hellwig /** 1442f461d2dcSChristoph Hellwig * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 1443f461d2dcSChristoph Hellwig * @table: the sysctl table 1444f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1445f461d2dcSChristoph Hellwig * @buffer: the user buffer 1446f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1447f461d2dcSChristoph Hellwig * @ppos: pointer to the file position 1448f461d2dcSChristoph Hellwig * 1449f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1450f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1451f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/USER_HZ seconds, and 1452f461d2dcSChristoph Hellwig * are converted into jiffies. 1453f461d2dcSChristoph Hellwig * 1454f461d2dcSChristoph Hellwig * Returns 0 on success. 1455f461d2dcSChristoph Hellwig */ 1456f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 145732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1458f461d2dcSChristoph Hellwig { 1459f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1460f461d2dcSChristoph Hellwig do_proc_dointvec_userhz_jiffies_conv,NULL); 1461f461d2dcSChristoph Hellwig } 1462f461d2dcSChristoph Hellwig 1463f461d2dcSChristoph Hellwig /** 1464f461d2dcSChristoph Hellwig * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 1465f461d2dcSChristoph Hellwig * @table: the sysctl table 1466f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1467f461d2dcSChristoph Hellwig * @buffer: the user buffer 1468f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1469f461d2dcSChristoph Hellwig * @ppos: file position 1470f461d2dcSChristoph Hellwig * @ppos: the current position in the file 1471f461d2dcSChristoph Hellwig * 1472f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1473f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1474f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/1000 seconds, and 1475f461d2dcSChristoph Hellwig * are converted into jiffies. 1476f461d2dcSChristoph Hellwig * 1477f461d2dcSChristoph Hellwig * Returns 0 on success. 1478f461d2dcSChristoph Hellwig */ 147932927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer, 148032927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1481f461d2dcSChristoph Hellwig { 1482f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 1483f461d2dcSChristoph Hellwig do_proc_dointvec_ms_jiffies_conv, NULL); 1484f461d2dcSChristoph Hellwig } 1485f461d2dcSChristoph Hellwig 148632927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer, 148732927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1488f461d2dcSChristoph Hellwig { 1489f461d2dcSChristoph Hellwig struct pid *new_pid; 1490f461d2dcSChristoph Hellwig pid_t tmp; 1491f461d2dcSChristoph Hellwig int r; 1492f461d2dcSChristoph Hellwig 1493f461d2dcSChristoph Hellwig tmp = pid_vnr(cad_pid); 1494f461d2dcSChristoph Hellwig 1495f461d2dcSChristoph Hellwig r = __do_proc_dointvec(&tmp, table, write, buffer, 1496f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1497f461d2dcSChristoph Hellwig if (r || !write) 1498f461d2dcSChristoph Hellwig return r; 1499f461d2dcSChristoph Hellwig 1500f461d2dcSChristoph Hellwig new_pid = find_get_pid(tmp); 1501f461d2dcSChristoph Hellwig if (!new_pid) 1502f461d2dcSChristoph Hellwig return -ESRCH; 1503f461d2dcSChristoph Hellwig 1504f461d2dcSChristoph Hellwig put_pid(xchg(&cad_pid, new_pid)); 1505f461d2dcSChristoph Hellwig return 0; 1506f461d2dcSChristoph Hellwig } 1507f461d2dcSChristoph Hellwig 1508f461d2dcSChristoph Hellwig /** 1509f461d2dcSChristoph Hellwig * proc_do_large_bitmap - read/write from/to a large bitmap 1510f461d2dcSChristoph Hellwig * @table: the sysctl table 1511f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1512f461d2dcSChristoph Hellwig * @buffer: the user buffer 1513f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1514f461d2dcSChristoph Hellwig * @ppos: file position 1515f461d2dcSChristoph Hellwig * 1516f461d2dcSChristoph Hellwig * The bitmap is stored at table->data and the bitmap length (in bits) 1517f461d2dcSChristoph Hellwig * in table->maxlen. 1518f461d2dcSChristoph Hellwig * 1519f461d2dcSChristoph Hellwig * We use a range comma separated format (e.g. 1,3-4,10-10) so that 1520f461d2dcSChristoph Hellwig * large bitmaps may be represented in a compact manner. Writing into 1521f461d2dcSChristoph Hellwig * the file will clear the bitmap then update it with the given input. 1522f461d2dcSChristoph Hellwig * 1523f461d2dcSChristoph Hellwig * Returns 0 on success. 1524f461d2dcSChristoph Hellwig */ 1525f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 152632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1527f461d2dcSChristoph Hellwig { 1528f461d2dcSChristoph Hellwig int err = 0; 1529f461d2dcSChristoph Hellwig size_t left = *lenp; 1530f461d2dcSChristoph Hellwig unsigned long bitmap_len = table->maxlen; 1531f461d2dcSChristoph Hellwig unsigned long *bitmap = *(unsigned long **) table->data; 1532f461d2dcSChristoph Hellwig unsigned long *tmp_bitmap = NULL; 1533f461d2dcSChristoph Hellwig char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1534f461d2dcSChristoph Hellwig 1535f461d2dcSChristoph Hellwig if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { 1536f461d2dcSChristoph Hellwig *lenp = 0; 1537f461d2dcSChristoph Hellwig return 0; 1538f461d2dcSChristoph Hellwig } 1539f461d2dcSChristoph Hellwig 1540f461d2dcSChristoph Hellwig if (write) { 154132927393SChristoph Hellwig char *p = buffer; 1542f461d2dcSChristoph Hellwig size_t skipped = 0; 1543f461d2dcSChristoph Hellwig 1544f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) { 1545f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 1546f461d2dcSChristoph Hellwig /* How much of the buffer we'll skip this pass */ 1547f461d2dcSChristoph Hellwig skipped = *lenp - left; 1548f461d2dcSChristoph Hellwig } 1549f461d2dcSChristoph Hellwig 1550f461d2dcSChristoph Hellwig tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); 155132927393SChristoph Hellwig if (!tmp_bitmap) 1552f461d2dcSChristoph Hellwig return -ENOMEM; 1553f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1554f461d2dcSChristoph Hellwig while (!err && left) { 1555f461d2dcSChristoph Hellwig unsigned long val_a, val_b; 1556f461d2dcSChristoph Hellwig bool neg; 1557f461d2dcSChristoph Hellwig size_t saved_left; 1558f461d2dcSChristoph Hellwig 1559f461d2dcSChristoph Hellwig /* In case we stop parsing mid-number, we can reset */ 1560f461d2dcSChristoph Hellwig saved_left = left; 1561f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_a, &neg, tr_a, 1562f461d2dcSChristoph Hellwig sizeof(tr_a), &c); 1563f461d2dcSChristoph Hellwig /* 1564f461d2dcSChristoph Hellwig * If we consumed the entirety of a truncated buffer or 1565f461d2dcSChristoph Hellwig * only one char is left (may be a "-"), then stop here, 1566f461d2dcSChristoph Hellwig * reset, & come back for more. 1567f461d2dcSChristoph Hellwig */ 1568f461d2dcSChristoph Hellwig if ((left <= 1) && skipped) { 1569f461d2dcSChristoph Hellwig left = saved_left; 1570f461d2dcSChristoph Hellwig break; 1571f461d2dcSChristoph Hellwig } 1572f461d2dcSChristoph Hellwig 1573f461d2dcSChristoph Hellwig if (err) 1574f461d2dcSChristoph Hellwig break; 1575f461d2dcSChristoph Hellwig if (val_a >= bitmap_len || neg) { 1576f461d2dcSChristoph Hellwig err = -EINVAL; 1577f461d2dcSChristoph Hellwig break; 1578f461d2dcSChristoph Hellwig } 1579f461d2dcSChristoph Hellwig 1580f461d2dcSChristoph Hellwig val_b = val_a; 1581f461d2dcSChristoph Hellwig if (left) { 1582f461d2dcSChristoph Hellwig p++; 1583f461d2dcSChristoph Hellwig left--; 1584f461d2dcSChristoph Hellwig } 1585f461d2dcSChristoph Hellwig 1586f461d2dcSChristoph Hellwig if (c == '-') { 1587f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_b, 1588f461d2dcSChristoph Hellwig &neg, tr_b, sizeof(tr_b), 1589f461d2dcSChristoph Hellwig &c); 1590f461d2dcSChristoph Hellwig /* 1591f461d2dcSChristoph Hellwig * If we consumed all of a truncated buffer or 1592f461d2dcSChristoph Hellwig * then stop here, reset, & come back for more. 1593f461d2dcSChristoph Hellwig */ 1594f461d2dcSChristoph Hellwig if (!left && skipped) { 1595f461d2dcSChristoph Hellwig left = saved_left; 1596f461d2dcSChristoph Hellwig break; 1597f461d2dcSChristoph Hellwig } 1598f461d2dcSChristoph Hellwig 1599f461d2dcSChristoph Hellwig if (err) 1600f461d2dcSChristoph Hellwig break; 1601f461d2dcSChristoph Hellwig if (val_b >= bitmap_len || neg || 1602f461d2dcSChristoph Hellwig val_a > val_b) { 1603f461d2dcSChristoph Hellwig err = -EINVAL; 1604f461d2dcSChristoph Hellwig break; 1605f461d2dcSChristoph Hellwig } 1606f461d2dcSChristoph Hellwig if (left) { 1607f461d2dcSChristoph Hellwig p++; 1608f461d2dcSChristoph Hellwig left--; 1609f461d2dcSChristoph Hellwig } 1610f461d2dcSChristoph Hellwig } 1611f461d2dcSChristoph Hellwig 1612f461d2dcSChristoph Hellwig bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 1613f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1614f461d2dcSChristoph Hellwig } 1615f461d2dcSChristoph Hellwig left += skipped; 1616f461d2dcSChristoph Hellwig } else { 1617f461d2dcSChristoph Hellwig unsigned long bit_a, bit_b = 0; 16189a52c5f3SJiapeng Chong bool first = 1; 1619f461d2dcSChristoph Hellwig 1620f461d2dcSChristoph Hellwig while (left) { 1621f461d2dcSChristoph Hellwig bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 1622f461d2dcSChristoph Hellwig if (bit_a >= bitmap_len) 1623f461d2dcSChristoph Hellwig break; 1624f461d2dcSChristoph Hellwig bit_b = find_next_zero_bit(bitmap, bitmap_len, 1625f461d2dcSChristoph Hellwig bit_a + 1) - 1; 1626f461d2dcSChristoph Hellwig 162732927393SChristoph Hellwig if (!first) 162832927393SChristoph Hellwig proc_put_char(&buffer, &left, ','); 162932927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_a, false); 1630f461d2dcSChristoph Hellwig if (bit_a != bit_b) { 163132927393SChristoph Hellwig proc_put_char(&buffer, &left, '-'); 163232927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_b, false); 1633f461d2dcSChristoph Hellwig } 1634f461d2dcSChristoph Hellwig 1635f461d2dcSChristoph Hellwig first = 0; bit_b++; 1636f461d2dcSChristoph Hellwig } 163732927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1638f461d2dcSChristoph Hellwig } 1639f461d2dcSChristoph Hellwig 1640f461d2dcSChristoph Hellwig if (!err) { 1641f461d2dcSChristoph Hellwig if (write) { 1642f461d2dcSChristoph Hellwig if (*ppos) 1643f461d2dcSChristoph Hellwig bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 1644f461d2dcSChristoph Hellwig else 1645f461d2dcSChristoph Hellwig bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 1646f461d2dcSChristoph Hellwig } 1647f461d2dcSChristoph Hellwig *lenp -= left; 1648f461d2dcSChristoph Hellwig *ppos += *lenp; 1649f461d2dcSChristoph Hellwig } 1650f461d2dcSChristoph Hellwig 1651f461d2dcSChristoph Hellwig bitmap_free(tmp_bitmap); 1652f461d2dcSChristoph Hellwig return err; 1653f461d2dcSChristoph Hellwig } 1654f461d2dcSChristoph Hellwig 1655f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */ 1656f461d2dcSChristoph Hellwig 1657f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 165832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1659f461d2dcSChristoph Hellwig { 1660f461d2dcSChristoph Hellwig return -ENOSYS; 1661f461d2dcSChristoph Hellwig } 1662f461d2dcSChristoph Hellwig 1663a2071573SJia He int proc_dobool(struct ctl_table *table, int write, 1664a2071573SJia He void *buffer, size_t *lenp, loff_t *ppos) 1665a2071573SJia He { 1666a2071573SJia He return -ENOSYS; 1667a2071573SJia He } 1668a2071573SJia He 1669f461d2dcSChristoph Hellwig int proc_dointvec(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_douintvec(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_dointvec_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_douintvec_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 1693cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write, 1694cb944413SEric Dumazet void *buffer, size_t *lenp, loff_t *ppos) 1695cb944413SEric Dumazet { 1696cb944413SEric Dumazet return -ENOSYS; 1697cb944413SEric Dumazet } 1698cb944413SEric Dumazet 1699f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 170032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1701f461d2dcSChristoph Hellwig { 1702f461d2dcSChristoph Hellwig return -ENOSYS; 1703f461d2dcSChristoph Hellwig } 1704f461d2dcSChristoph Hellwig 1705f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 170632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1707f461d2dcSChristoph Hellwig { 1708f461d2dcSChristoph Hellwig return -ENOSYS; 1709f461d2dcSChristoph Hellwig } 1710f461d2dcSChristoph Hellwig 1711f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 171232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1713f461d2dcSChristoph Hellwig { 1714f461d2dcSChristoph Hellwig return -ENOSYS; 1715f461d2dcSChristoph Hellwig } 1716f461d2dcSChristoph Hellwig 1717f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 171832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1719f461d2dcSChristoph Hellwig { 1720f461d2dcSChristoph Hellwig return -ENOSYS; 1721f461d2dcSChristoph Hellwig } 1722f461d2dcSChristoph Hellwig 1723f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 172432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1725f461d2dcSChristoph Hellwig { 1726f461d2dcSChristoph Hellwig return -ENOSYS; 1727f461d2dcSChristoph Hellwig } 1728f461d2dcSChristoph Hellwig 1729f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 173032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1731f461d2dcSChristoph Hellwig { 1732f461d2dcSChristoph Hellwig return -ENOSYS; 1733f461d2dcSChristoph Hellwig } 1734f461d2dcSChristoph Hellwig 1735f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 1736f461d2dcSChristoph Hellwig 1737f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL) 1738f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write, 173932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1740f461d2dcSChristoph Hellwig { 1741f461d2dcSChristoph Hellwig struct static_key *key = (struct static_key *)table->data; 1742f461d2dcSChristoph Hellwig static DEFINE_MUTEX(static_key_mutex); 1743f461d2dcSChristoph Hellwig int val, ret; 1744f461d2dcSChristoph Hellwig struct ctl_table tmp = { 1745f461d2dcSChristoph Hellwig .data = &val, 1746f461d2dcSChristoph Hellwig .maxlen = sizeof(val), 1747f461d2dcSChristoph Hellwig .mode = table->mode, 1748f461d2dcSChristoph Hellwig .extra1 = SYSCTL_ZERO, 1749f461d2dcSChristoph Hellwig .extra2 = SYSCTL_ONE, 1750f461d2dcSChristoph Hellwig }; 1751f461d2dcSChristoph Hellwig 1752f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 1753f461d2dcSChristoph Hellwig return -EPERM; 1754f461d2dcSChristoph Hellwig 1755f461d2dcSChristoph Hellwig mutex_lock(&static_key_mutex); 1756f461d2dcSChristoph Hellwig val = static_key_enabled(key); 1757f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 1758f461d2dcSChristoph Hellwig if (write && !ret) { 1759f461d2dcSChristoph Hellwig if (val) 1760f461d2dcSChristoph Hellwig static_key_enable(key); 1761f461d2dcSChristoph Hellwig else 1762f461d2dcSChristoph Hellwig static_key_disable(key); 1763f461d2dcSChristoph Hellwig } 1764f461d2dcSChristoph Hellwig mutex_unlock(&static_key_mutex); 1765f461d2dcSChristoph Hellwig return ret; 1766f461d2dcSChristoph Hellwig } 1767f461d2dcSChristoph Hellwig 1768d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 17692bba22c5SMike Galbraith { 17702bba22c5SMike Galbraith .procname = "sched_child_runs_first", 17712bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 17722bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 17732bba22c5SMike Galbraith .mode = 0644, 17746d456111SEric W. Biederman .proc_handler = proc_dointvec, 17752bba22c5SMike Galbraith }, 17761d1c2509SPeter Zijlstra #ifdef CONFIG_SCHEDSTATS 17771d1c2509SPeter Zijlstra { 17781d1c2509SPeter Zijlstra .procname = "sched_schedstats", 17791d1c2509SPeter Zijlstra .data = NULL, 17801d1c2509SPeter Zijlstra .maxlen = sizeof(unsigned int), 17811d1c2509SPeter Zijlstra .mode = 0644, 17821d1c2509SPeter Zijlstra .proc_handler = sysctl_schedstats, 17831d1c2509SPeter Zijlstra .extra1 = SYSCTL_ZERO, 17841d1c2509SPeter Zijlstra .extra2 = SYSCTL_ONE, 17851d1c2509SPeter Zijlstra }, 17861d1c2509SPeter Zijlstra #endif /* CONFIG_SCHEDSTATS */ 17870cd7c741SPeter Zijlstra #ifdef CONFIG_TASK_DELAY_ACCT 17880cd7c741SPeter Zijlstra { 17890cd7c741SPeter Zijlstra .procname = "task_delayacct", 17900cd7c741SPeter Zijlstra .data = NULL, 17910cd7c741SPeter Zijlstra .maxlen = sizeof(unsigned int), 17920cd7c741SPeter Zijlstra .mode = 0644, 17930cd7c741SPeter Zijlstra .proc_handler = sysctl_delayacct, 17940cd7c741SPeter Zijlstra .extra1 = SYSCTL_ZERO, 17950cd7c741SPeter Zijlstra .extra2 = SYSCTL_ONE, 17960cd7c741SPeter Zijlstra }, 17970cd7c741SPeter Zijlstra #endif /* CONFIG_TASK_DELAY_ACCT */ 1798b7cc6ec7SMel Gorman #ifdef CONFIG_NUMA_BALANCING 17993a7053b3SMel Gorman { 180054a43d54SAndi Kleen .procname = "numa_balancing", 180154a43d54SAndi Kleen .data = NULL, /* filled in by handler */ 180254a43d54SAndi Kleen .maxlen = sizeof(unsigned int), 180354a43d54SAndi Kleen .mode = 0644, 180454a43d54SAndi Kleen .proc_handler = sysctl_numa_balancing, 1805eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1806eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 180754a43d54SAndi Kleen }, 1808cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */ 18091799e35dSIngo Molnar { 18109f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 18119f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 18129f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 18139f0c1e56SPeter Zijlstra .mode = 0644, 18146d456111SEric W. Biederman .proc_handler = sched_rt_handler, 18159f0c1e56SPeter Zijlstra }, 18169f0c1e56SPeter Zijlstra { 18179f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 18189f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 18199f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 18209f0c1e56SPeter Zijlstra .mode = 0644, 18216d456111SEric W. Biederman .proc_handler = sched_rt_handler, 18229f0c1e56SPeter Zijlstra }, 1823ce0dbbbbSClark Williams { 1824b4098bfcSPeter Zijlstra .procname = "sched_deadline_period_max_us", 1825b4098bfcSPeter Zijlstra .data = &sysctl_sched_dl_period_max, 1826b4098bfcSPeter Zijlstra .maxlen = sizeof(unsigned int), 1827b4098bfcSPeter Zijlstra .mode = 0644, 1828b4098bfcSPeter Zijlstra .proc_handler = proc_dointvec, 1829b4098bfcSPeter Zijlstra }, 1830b4098bfcSPeter Zijlstra { 1831b4098bfcSPeter Zijlstra .procname = "sched_deadline_period_min_us", 1832b4098bfcSPeter Zijlstra .data = &sysctl_sched_dl_period_min, 1833b4098bfcSPeter Zijlstra .maxlen = sizeof(unsigned int), 1834b4098bfcSPeter Zijlstra .mode = 0644, 1835b4098bfcSPeter Zijlstra .proc_handler = proc_dointvec, 1836b4098bfcSPeter Zijlstra }, 1837b4098bfcSPeter Zijlstra { 1838ce0dbbbbSClark Williams .procname = "sched_rr_timeslice_ms", 1839975e155eSShile Zhang .data = &sysctl_sched_rr_timeslice, 1840ce0dbbbbSClark Williams .maxlen = sizeof(int), 1841ce0dbbbbSClark Williams .mode = 0644, 1842ce0dbbbbSClark Williams .proc_handler = sched_rr_handler, 1843ce0dbbbbSClark Williams }, 1844e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK 1845e8f14172SPatrick Bellasi { 1846e8f14172SPatrick Bellasi .procname = "sched_util_clamp_min", 1847e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_min, 1848e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1849e8f14172SPatrick Bellasi .mode = 0644, 1850e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1851e8f14172SPatrick Bellasi }, 1852e8f14172SPatrick Bellasi { 1853e8f14172SPatrick Bellasi .procname = "sched_util_clamp_max", 1854e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_max, 1855e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1856e8f14172SPatrick Bellasi .mode = 0644, 1857e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1858e8f14172SPatrick Bellasi }, 185913685c4aSQais Yousef { 186013685c4aSQais Yousef .procname = "sched_util_clamp_min_rt_default", 186113685c4aSQais Yousef .data = &sysctl_sched_uclamp_util_min_rt_default, 186213685c4aSQais Yousef .maxlen = sizeof(unsigned int), 186313685c4aSQais Yousef .mode = 0644, 186413685c4aSQais Yousef .proc_handler = sysctl_sched_uclamp_handler, 186513685c4aSQais Yousef }, 1866e8f14172SPatrick Bellasi #endif 18675091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 18685091faa4SMike Galbraith { 18695091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 18705091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 18715091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 18725091faa4SMike Galbraith .mode = 0644, 18731747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 1874eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1875eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18765091faa4SMike Galbraith }, 18775091faa4SMike Galbraith #endif 1878ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 1879ec12cb7fSPaul Turner { 1880ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 1881ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 1882ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 1883ec12cb7fSPaul Turner .mode = 0644, 1884ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 1885eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 1886ec12cb7fSPaul Turner }, 1887ec12cb7fSPaul Turner #endif 18888d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) 18898d5d0cfbSQuentin Perret { 18908d5d0cfbSQuentin Perret .procname = "sched_energy_aware", 18918d5d0cfbSQuentin Perret .data = &sysctl_sched_energy_aware, 18928d5d0cfbSQuentin Perret .maxlen = sizeof(unsigned int), 18938d5d0cfbSQuentin Perret .mode = 0644, 18948d5d0cfbSQuentin Perret .proc_handler = sched_energy_aware_handler, 1895eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1896eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18978d5d0cfbSQuentin Perret }, 18988d5d0cfbSQuentin Perret #endif 1899f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 1900f20786ffSPeter Zijlstra { 1901f20786ffSPeter Zijlstra .procname = "prove_locking", 1902f20786ffSPeter Zijlstra .data = &prove_locking, 1903f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1904f20786ffSPeter Zijlstra .mode = 0644, 19056d456111SEric W. Biederman .proc_handler = proc_dointvec, 1906f20786ffSPeter Zijlstra }, 1907f20786ffSPeter Zijlstra #endif 1908f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 1909f20786ffSPeter Zijlstra { 1910f20786ffSPeter Zijlstra .procname = "lock_stat", 1911f20786ffSPeter Zijlstra .data = &lock_stat, 1912f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1913f20786ffSPeter Zijlstra .mode = 0644, 19146d456111SEric W. Biederman .proc_handler = proc_dointvec, 1915f20786ffSPeter Zijlstra }, 1916f20786ffSPeter Zijlstra #endif 191777e54a1fSIngo Molnar { 19181da177e4SLinus Torvalds .procname = "panic", 19191da177e4SLinus Torvalds .data = &panic_timeout, 19201da177e4SLinus Torvalds .maxlen = sizeof(int), 19211da177e4SLinus Torvalds .mode = 0644, 19226d456111SEric W. Biederman .proc_handler = proc_dointvec, 19231da177e4SLinus Torvalds }, 1924046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 19251da177e4SLinus Torvalds { 19261da177e4SLinus Torvalds .procname = "core_uses_pid", 19271da177e4SLinus Torvalds .data = &core_uses_pid, 19281da177e4SLinus Torvalds .maxlen = sizeof(int), 19291da177e4SLinus Torvalds .mode = 0644, 19306d456111SEric W. Biederman .proc_handler = proc_dointvec, 19311da177e4SLinus Torvalds }, 19321da177e4SLinus Torvalds { 19331da177e4SLinus Torvalds .procname = "core_pattern", 19341da177e4SLinus Torvalds .data = core_pattern, 193571ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 19361da177e4SLinus Torvalds .mode = 0644, 193754b50199SKees Cook .proc_handler = proc_dostring_coredump, 19381da177e4SLinus Torvalds }, 1939a293980cSNeil Horman { 1940a293980cSNeil Horman .procname = "core_pipe_limit", 1941a293980cSNeil Horman .data = &core_pipe_limit, 1942a293980cSNeil Horman .maxlen = sizeof(unsigned int), 1943a293980cSNeil Horman .mode = 0644, 19446d456111SEric W. Biederman .proc_handler = proc_dointvec, 1945a293980cSNeil Horman }, 1946046d662fSAlex Kelly #endif 194734f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 19481da177e4SLinus Torvalds { 19491da177e4SLinus Torvalds .procname = "tainted", 195025ddbb18SAndi Kleen .maxlen = sizeof(long), 195134f5a398STheodore Ts'o .mode = 0644, 19526d456111SEric W. Biederman .proc_handler = proc_taint, 19531da177e4SLinus Torvalds }, 1954f4aacea2SKees Cook { 1955f4aacea2SKees Cook .procname = "sysctl_writes_strict", 1956f4aacea2SKees Cook .data = &sysctl_writes_strict, 1957f4aacea2SKees Cook .maxlen = sizeof(int), 1958f4aacea2SKees Cook .mode = 0644, 1959f4aacea2SKees Cook .proc_handler = proc_dointvec_minmax, 1960*78e36f3bSXiaoming Ni .extra1 = SYSCTL_NEG_ONE, 1961eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1962f4aacea2SKees Cook }, 196334f5a398STheodore Ts'o #endif 19649745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 19659745512cSArjan van de Ven { 19669745512cSArjan van de Ven .procname = "latencytop", 19679745512cSArjan van de Ven .data = &latencytop_enabled, 19689745512cSArjan van de Ven .maxlen = sizeof(int), 19699745512cSArjan van de Ven .mode = 0644, 1970cb251765SMel Gorman .proc_handler = sysctl_latencytop, 19719745512cSArjan van de Ven }, 19729745512cSArjan van de Ven #endif 19731da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 19741da177e4SLinus Torvalds { 19751da177e4SLinus Torvalds .procname = "real-root-dev", 19761da177e4SLinus Torvalds .data = &real_root_dev, 19771da177e4SLinus Torvalds .maxlen = sizeof(int), 19781da177e4SLinus Torvalds .mode = 0644, 19796d456111SEric W. Biederman .proc_handler = proc_dointvec, 19801da177e4SLinus Torvalds }, 19811da177e4SLinus Torvalds #endif 198245807a1dSIngo Molnar { 198345807a1dSIngo Molnar .procname = "print-fatal-signals", 198445807a1dSIngo Molnar .data = &print_fatal_signals, 198545807a1dSIngo Molnar .maxlen = sizeof(int), 198645807a1dSIngo Molnar .mode = 0644, 19876d456111SEric W. Biederman .proc_handler = proc_dointvec, 198845807a1dSIngo Molnar }, 198972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 19901da177e4SLinus Torvalds { 19911da177e4SLinus Torvalds .procname = "reboot-cmd", 19921da177e4SLinus Torvalds .data = reboot_command, 19931da177e4SLinus Torvalds .maxlen = 256, 19941da177e4SLinus Torvalds .mode = 0644, 19956d456111SEric W. Biederman .proc_handler = proc_dostring, 19961da177e4SLinus Torvalds }, 19971da177e4SLinus Torvalds { 19981da177e4SLinus Torvalds .procname = "stop-a", 19991da177e4SLinus Torvalds .data = &stop_a_enabled, 20001da177e4SLinus Torvalds .maxlen = sizeof (int), 20011da177e4SLinus Torvalds .mode = 0644, 20026d456111SEric W. Biederman .proc_handler = proc_dointvec, 20031da177e4SLinus Torvalds }, 20041da177e4SLinus Torvalds { 20051da177e4SLinus Torvalds .procname = "scons-poweroff", 20061da177e4SLinus Torvalds .data = &scons_pwroff, 20071da177e4SLinus Torvalds .maxlen = sizeof (int), 20081da177e4SLinus Torvalds .mode = 0644, 20096d456111SEric W. Biederman .proc_handler = proc_dointvec, 20101da177e4SLinus Torvalds }, 20111da177e4SLinus Torvalds #endif 20120871420fSDavid S. Miller #ifdef CONFIG_SPARC64 20130871420fSDavid S. Miller { 20140871420fSDavid S. Miller .procname = "tsb-ratio", 20150871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 20160871420fSDavid S. Miller .maxlen = sizeof (int), 20170871420fSDavid S. Miller .mode = 0644, 20186d456111SEric W. Biederman .proc_handler = proc_dointvec, 20190871420fSDavid S. Miller }, 20200871420fSDavid S. Miller #endif 2021b67114dbSHelge Deller #ifdef CONFIG_PARISC 20221da177e4SLinus Torvalds { 20231da177e4SLinus Torvalds .procname = "soft-power", 20241da177e4SLinus Torvalds .data = &pwrsw_enabled, 20251da177e4SLinus Torvalds .maxlen = sizeof (int), 20261da177e4SLinus Torvalds .mode = 0644, 20276d456111SEric W. Biederman .proc_handler = proc_dointvec, 20281da177e4SLinus Torvalds }, 2029bf14e3b9SVineet Gupta #endif 2030bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW 20311da177e4SLinus Torvalds { 20321da177e4SLinus Torvalds .procname = "unaligned-trap", 20331da177e4SLinus Torvalds .data = &unaligned_enabled, 20341da177e4SLinus Torvalds .maxlen = sizeof (int), 20351da177e4SLinus Torvalds .mode = 0644, 20366d456111SEric W. Biederman .proc_handler = proc_dointvec, 20371da177e4SLinus Torvalds }, 20381da177e4SLinus Torvalds #endif 20391da177e4SLinus Torvalds { 20401da177e4SLinus Torvalds .procname = "ctrl-alt-del", 20411da177e4SLinus Torvalds .data = &C_A_D, 20421da177e4SLinus Torvalds .maxlen = sizeof(int), 20431da177e4SLinus Torvalds .mode = 0644, 20446d456111SEric W. Biederman .proc_handler = proc_dointvec, 20451da177e4SLinus Torvalds }, 2046606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 2047b0fc494fSSteven Rostedt { 2048b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 2049b0fc494fSSteven Rostedt .data = &ftrace_enabled, 2050b0fc494fSSteven Rostedt .maxlen = sizeof(int), 2051b0fc494fSSteven Rostedt .mode = 0644, 20526d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 2053b0fc494fSSteven Rostedt }, 2054b0fc494fSSteven Rostedt #endif 2055f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 2056f38f1d2aSSteven Rostedt { 2057f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 2058f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 2059f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 2060f38f1d2aSSteven Rostedt .mode = 0644, 20616d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 2062f38f1d2aSSteven Rostedt }, 2063f38f1d2aSSteven Rostedt #endif 2064944ac425SSteven Rostedt #ifdef CONFIG_TRACING 2065944ac425SSteven Rostedt { 20663299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 2067944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 2068944ac425SSteven Rostedt .maxlen = sizeof(int), 2069944ac425SSteven Rostedt .mode = 0644, 20706d456111SEric W. Biederman .proc_handler = proc_dointvec, 2071944ac425SSteven Rostedt }, 2072de7edd31SSteven Rostedt (Red Hat) { 2073de7edd31SSteven Rostedt (Red Hat) .procname = "traceoff_on_warning", 2074de7edd31SSteven Rostedt (Red Hat) .data = &__disable_trace_on_warning, 2075de7edd31SSteven Rostedt (Red Hat) .maxlen = sizeof(__disable_trace_on_warning), 2076de7edd31SSteven Rostedt (Red Hat) .mode = 0644, 2077de7edd31SSteven Rostedt (Red Hat) .proc_handler = proc_dointvec, 2078de7edd31SSteven Rostedt (Red Hat) }, 20790daa2302SSteven Rostedt (Red Hat) { 20800daa2302SSteven Rostedt (Red Hat) .procname = "tracepoint_printk", 20810daa2302SSteven Rostedt (Red Hat) .data = &tracepoint_printk, 20820daa2302SSteven Rostedt (Red Hat) .maxlen = sizeof(tracepoint_printk), 20830daa2302SSteven Rostedt (Red Hat) .mode = 0644, 208442391745SSteven Rostedt (Red Hat) .proc_handler = tracepoint_printk_sysctl, 20850daa2302SSteven Rostedt (Red Hat) }, 2086944ac425SSteven Rostedt #endif 20872965faa5SDave Young #ifdef CONFIG_KEXEC_CORE 20887984754bSKees Cook { 20897984754bSKees Cook .procname = "kexec_load_disabled", 20907984754bSKees Cook .data = &kexec_load_disabled, 20917984754bSKees Cook .maxlen = sizeof(int), 20927984754bSKees Cook .mode = 0644, 20937984754bSKees Cook /* only handle a transition from default "0" to "1" */ 20947984754bSKees Cook .proc_handler = proc_dointvec_minmax, 2095eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2096eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20977984754bSKees Cook }, 20987984754bSKees Cook #endif 2099a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 21001da177e4SLinus Torvalds { 21011da177e4SLinus Torvalds .procname = "modprobe", 21021da177e4SLinus Torvalds .data = &modprobe_path, 21031da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 21041da177e4SLinus Torvalds .mode = 0644, 21056d456111SEric W. Biederman .proc_handler = proc_dostring, 21061da177e4SLinus Torvalds }, 21073d43321bSKees Cook { 21083d43321bSKees Cook .procname = "modules_disabled", 21093d43321bSKees Cook .data = &modules_disabled, 21103d43321bSKees Cook .maxlen = sizeof(int), 21113d43321bSKees Cook .mode = 0644, 21123d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 21136d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2114eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2115eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 21163d43321bSKees Cook }, 21171da177e4SLinus Torvalds #endif 211886d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER 21191da177e4SLinus Torvalds { 21201da177e4SLinus Torvalds .procname = "hotplug", 2121312c004dSKay Sievers .data = &uevent_helper, 2122312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 21231da177e4SLinus Torvalds .mode = 0644, 21246d456111SEric W. Biederman .proc_handler = proc_dostring, 21251da177e4SLinus Torvalds }, 212686d56134SMichael Marineau #endif 21271da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 21281da177e4SLinus Torvalds { 21291da177e4SLinus Torvalds .procname = "sg-big-buff", 21301da177e4SLinus Torvalds .data = &sg_big_buff, 21311da177e4SLinus Torvalds .maxlen = sizeof (int), 21321da177e4SLinus Torvalds .mode = 0444, 21336d456111SEric W. Biederman .proc_handler = proc_dointvec, 21341da177e4SLinus Torvalds }, 21351da177e4SLinus Torvalds #endif 21361da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 21371da177e4SLinus Torvalds { 21381da177e4SLinus Torvalds .procname = "acct", 21391da177e4SLinus Torvalds .data = &acct_parm, 21401da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 21411da177e4SLinus Torvalds .mode = 0644, 21426d456111SEric W. Biederman .proc_handler = proc_dointvec, 21431da177e4SLinus Torvalds }, 21441da177e4SLinus Torvalds #endif 21451da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 21461da177e4SLinus Torvalds { 21471da177e4SLinus Torvalds .procname = "sysrq", 2148eaee4172SDmitry Safonov .data = NULL, 21491da177e4SLinus Torvalds .maxlen = sizeof (int), 21501da177e4SLinus Torvalds .mode = 0644, 215197f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 21521da177e4SLinus Torvalds }, 21531da177e4SLinus Torvalds #endif 2154d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 21551da177e4SLinus Torvalds { 21561da177e4SLinus Torvalds .procname = "cad_pid", 21579ec52099SCedric Le Goater .data = NULL, 21581da177e4SLinus Torvalds .maxlen = sizeof (int), 21591da177e4SLinus Torvalds .mode = 0600, 21606d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 21611da177e4SLinus Torvalds }, 2162d6f8ff73SRandy Dunlap #endif 21631da177e4SLinus Torvalds { 21641da177e4SLinus Torvalds .procname = "threads-max", 216516db3d3fSHeinrich Schuchardt .data = NULL, 21661da177e4SLinus Torvalds .maxlen = sizeof(int), 21671da177e4SLinus Torvalds .mode = 0644, 216816db3d3fSHeinrich Schuchardt .proc_handler = sysctl_max_threads, 21691da177e4SLinus Torvalds }, 21701da177e4SLinus Torvalds { 21711da177e4SLinus Torvalds .procname = "random", 21721da177e4SLinus Torvalds .mode = 0555, 21731da177e4SLinus Torvalds .child = random_table, 21741da177e4SLinus Torvalds }, 21751da177e4SLinus Torvalds { 217617f60a7dSEric Paris .procname = "usermodehelper", 217717f60a7dSEric Paris .mode = 0555, 217817f60a7dSEric Paris .child = usermodehelper_table, 217917f60a7dSEric Paris }, 2180ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER 2181ceb18132SLuis R. Rodriguez { 2182ceb18132SLuis R. Rodriguez .procname = "firmware_config", 2183ceb18132SLuis R. Rodriguez .mode = 0555, 2184ceb18132SLuis R. Rodriguez .child = firmware_config_table, 2185ceb18132SLuis R. Rodriguez }, 2186ceb18132SLuis R. Rodriguez #endif 218717f60a7dSEric Paris { 21881da177e4SLinus Torvalds .procname = "overflowuid", 21891da177e4SLinus Torvalds .data = &overflowuid, 21901da177e4SLinus Torvalds .maxlen = sizeof(int), 21911da177e4SLinus Torvalds .mode = 0644, 21926d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21931da177e4SLinus Torvalds .extra1 = &minolduid, 21941da177e4SLinus Torvalds .extra2 = &maxolduid, 21951da177e4SLinus Torvalds }, 21961da177e4SLinus Torvalds { 21971da177e4SLinus Torvalds .procname = "overflowgid", 21981da177e4SLinus Torvalds .data = &overflowgid, 21991da177e4SLinus Torvalds .maxlen = sizeof(int), 22001da177e4SLinus Torvalds .mode = 0644, 22016d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 22021da177e4SLinus Torvalds .extra1 = &minolduid, 22031da177e4SLinus Torvalds .extra2 = &maxolduid, 22041da177e4SLinus Torvalds }, 2205347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 22061da177e4SLinus Torvalds { 22071da177e4SLinus Torvalds .procname = "userprocess_debug", 2208ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 22091da177e4SLinus Torvalds .maxlen = sizeof(int), 22101da177e4SLinus Torvalds .mode = 0644, 22116d456111SEric W. Biederman .proc_handler = proc_dointvec, 22121da177e4SLinus Torvalds }, 22131da177e4SLinus Torvalds #endif 221460c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP 221560c958d8SGuilherme G. Piccoli { 221660c958d8SGuilherme G. Piccoli .procname = "oops_all_cpu_backtrace", 221760c958d8SGuilherme G. Piccoli .data = &sysctl_oops_all_cpu_backtrace, 221860c958d8SGuilherme G. Piccoli .maxlen = sizeof(int), 221960c958d8SGuilherme G. Piccoli .mode = 0644, 222060c958d8SGuilherme G. Piccoli .proc_handler = proc_dointvec_minmax, 222160c958d8SGuilherme G. Piccoli .extra1 = SYSCTL_ZERO, 222260c958d8SGuilherme G. Piccoli .extra2 = SYSCTL_ONE, 222360c958d8SGuilherme G. Piccoli }, 222460c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */ 22251da177e4SLinus Torvalds { 22261da177e4SLinus Torvalds .procname = "pid_max", 22271da177e4SLinus Torvalds .data = &pid_max, 22281da177e4SLinus Torvalds .maxlen = sizeof (int), 22291da177e4SLinus Torvalds .mode = 0644, 22306d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 22311da177e4SLinus Torvalds .extra1 = &pid_max_min, 22321da177e4SLinus Torvalds .extra2 = &pid_max_max, 22331da177e4SLinus Torvalds }, 22341da177e4SLinus Torvalds { 22351da177e4SLinus Torvalds .procname = "panic_on_oops", 22361da177e4SLinus Torvalds .data = &panic_on_oops, 22371da177e4SLinus Torvalds .maxlen = sizeof(int), 22381da177e4SLinus Torvalds .mode = 0644, 22396d456111SEric W. Biederman .proc_handler = proc_dointvec, 22401da177e4SLinus Torvalds }, 224181c9d43fSFeng Tang { 224281c9d43fSFeng Tang .procname = "panic_print", 224381c9d43fSFeng Tang .data = &panic_print, 224481c9d43fSFeng Tang .maxlen = sizeof(unsigned long), 224581c9d43fSFeng Tang .mode = 0644, 224681c9d43fSFeng Tang .proc_handler = proc_doulongvec_minmax, 224781c9d43fSFeng Tang }, 22487ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 22497ef3d2fdSJoe Perches { 22507ef3d2fdSJoe Perches .procname = "printk", 22517ef3d2fdSJoe Perches .data = &console_loglevel, 22527ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 22537ef3d2fdSJoe Perches .mode = 0644, 22546d456111SEric W. Biederman .proc_handler = proc_dointvec, 22557ef3d2fdSJoe Perches }, 22561da177e4SLinus Torvalds { 22571da177e4SLinus Torvalds .procname = "printk_ratelimit", 2258717115e1SDave Young .data = &printk_ratelimit_state.interval, 22591da177e4SLinus Torvalds .maxlen = sizeof(int), 22601da177e4SLinus Torvalds .mode = 0644, 22616d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 22621da177e4SLinus Torvalds }, 22631da177e4SLinus Torvalds { 22641da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 2265717115e1SDave Young .data = &printk_ratelimit_state.burst, 22661da177e4SLinus Torvalds .maxlen = sizeof(int), 22671da177e4SLinus Torvalds .mode = 0644, 22686d456111SEric W. Biederman .proc_handler = proc_dointvec, 22691da177e4SLinus Torvalds }, 2270af91322eSDave Young { 2271af91322eSDave Young .procname = "printk_delay", 2272af91322eSDave Young .data = &printk_delay_msec, 2273af91322eSDave Young .maxlen = sizeof(int), 2274af91322eSDave Young .mode = 0644, 22756d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2276eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2277af91322eSDave Young .extra2 = &ten_thousand, 2278af91322eSDave Young }, 22791da177e4SLinus Torvalds { 2280750afe7bSBorislav Petkov .procname = "printk_devkmsg", 2281750afe7bSBorislav Petkov .data = devkmsg_log_str, 2282750afe7bSBorislav Petkov .maxlen = DEVKMSG_STR_MAX_SIZE, 2283750afe7bSBorislav Petkov .mode = 0644, 2284750afe7bSBorislav Petkov .proc_handler = devkmsg_sysctl_set_loglvl, 2285750afe7bSBorislav Petkov }, 2286750afe7bSBorislav Petkov { 2287eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 2288eaf06b24SDan Rosenberg .data = &dmesg_restrict, 2289eaf06b24SDan Rosenberg .maxlen = sizeof(int), 2290eaf06b24SDan Rosenberg .mode = 0644, 2291620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2292eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2293eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2294eaf06b24SDan Rosenberg }, 2295455cd5abSDan Rosenberg { 2296455cd5abSDan Rosenberg .procname = "kptr_restrict", 2297455cd5abSDan Rosenberg .data = &kptr_restrict, 2298455cd5abSDan Rosenberg .maxlen = sizeof(int), 2299455cd5abSDan Rosenberg .mode = 0644, 2300620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2301eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2302*78e36f3bSXiaoming Ni .extra2 = SYSCTL_TWO, 2303455cd5abSDan Rosenberg }, 2304df6e61d4SJoe Perches #endif 2305eaf06b24SDan Rosenberg { 23061da177e4SLinus Torvalds .procname = "ngroups_max", 23071da177e4SLinus Torvalds .data = &ngroups_max, 23081da177e4SLinus Torvalds .maxlen = sizeof (int), 23091da177e4SLinus Torvalds .mode = 0444, 23106d456111SEric W. Biederman .proc_handler = proc_dointvec, 23111da177e4SLinus Torvalds }, 231273efc039SDan Ballard { 231373efc039SDan Ballard .procname = "cap_last_cap", 231473efc039SDan Ballard .data = (void *)&cap_last_cap, 231573efc039SDan Ballard .maxlen = sizeof(int), 231673efc039SDan Ballard .mode = 0444, 231773efc039SDan Ballard .proc_handler = proc_dointvec, 231873efc039SDan Ballard }, 231958687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 2320504d7cf1SDon Zickus { 232158687acbSDon Zickus .procname = "watchdog", 23223c00ea82SFrederic Weisbecker .data = &watchdog_user_enabled, 2323504d7cf1SDon Zickus .maxlen = sizeof(int), 2324504d7cf1SDon Zickus .mode = 0644, 2325195daf66SUlrich Obergfell .proc_handler = proc_watchdog, 2326eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2327eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 232858687acbSDon Zickus }, 232958687acbSDon Zickus { 233058687acbSDon Zickus .procname = "watchdog_thresh", 2331586692a5SMandeep Singh Baines .data = &watchdog_thresh, 233258687acbSDon Zickus .maxlen = sizeof(int), 233358687acbSDon Zickus .mode = 0644, 2334195daf66SUlrich Obergfell .proc_handler = proc_watchdog_thresh, 2335eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 233658687acbSDon Zickus .extra2 = &sixty, 2337504d7cf1SDon Zickus }, 23382508ce18SDon Zickus { 2339195daf66SUlrich Obergfell .procname = "nmi_watchdog", 23407feeb9cdSThomas Gleixner .data = &nmi_watchdog_user_enabled, 2341195daf66SUlrich Obergfell .maxlen = sizeof(int), 234251d4052bSThomas Gleixner .mode = NMI_WATCHDOG_SYSCTL_PERM, 2343195daf66SUlrich Obergfell .proc_handler = proc_nmi_watchdog, 2344eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2345eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2346195daf66SUlrich Obergfell }, 2347195daf66SUlrich Obergfell { 234805a4a952SNicholas Piggin .procname = "watchdog_cpumask", 234905a4a952SNicholas Piggin .data = &watchdog_cpumask_bits, 235005a4a952SNicholas Piggin .maxlen = NR_CPUS, 235105a4a952SNicholas Piggin .mode = 0644, 235205a4a952SNicholas Piggin .proc_handler = proc_watchdog_cpumask, 235305a4a952SNicholas Piggin }, 235405a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR 235505a4a952SNicholas Piggin { 2356195daf66SUlrich Obergfell .procname = "soft_watchdog", 23577feeb9cdSThomas Gleixner .data = &soft_watchdog_user_enabled, 2358195daf66SUlrich Obergfell .maxlen = sizeof(int), 2359195daf66SUlrich Obergfell .mode = 0644, 2360195daf66SUlrich Obergfell .proc_handler = proc_soft_watchdog, 2361eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2362eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2363195daf66SUlrich Obergfell }, 2364195daf66SUlrich Obergfell { 23652508ce18SDon Zickus .procname = "softlockup_panic", 23662508ce18SDon Zickus .data = &softlockup_panic, 23672508ce18SDon Zickus .maxlen = sizeof(int), 23682508ce18SDon Zickus .mode = 0644, 23692508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 2370eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2371eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 23722508ce18SDon Zickus }, 2373ed235875SAaron Tomlin #ifdef CONFIG_SMP 2374ed235875SAaron Tomlin { 2375ed235875SAaron Tomlin .procname = "softlockup_all_cpu_backtrace", 2376ed235875SAaron Tomlin .data = &sysctl_softlockup_all_cpu_backtrace, 2377ed235875SAaron Tomlin .maxlen = sizeof(int), 2378ed235875SAaron Tomlin .mode = 0644, 2379ed235875SAaron Tomlin .proc_handler = proc_dointvec_minmax, 2380eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2381eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2382ed235875SAaron Tomlin }, 238305a4a952SNicholas Piggin #endif /* CONFIG_SMP */ 238405a4a952SNicholas Piggin #endif 238505a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR 238605a4a952SNicholas Piggin { 238705a4a952SNicholas Piggin .procname = "hardlockup_panic", 238805a4a952SNicholas Piggin .data = &hardlockup_panic, 238905a4a952SNicholas Piggin .maxlen = sizeof(int), 239005a4a952SNicholas Piggin .mode = 0644, 239105a4a952SNicholas Piggin .proc_handler = proc_dointvec_minmax, 2392eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2393eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 239405a4a952SNicholas Piggin }, 239505a4a952SNicholas Piggin #ifdef CONFIG_SMP 239655537871SJiri Kosina { 239755537871SJiri Kosina .procname = "hardlockup_all_cpu_backtrace", 239855537871SJiri Kosina .data = &sysctl_hardlockup_all_cpu_backtrace, 239955537871SJiri Kosina .maxlen = sizeof(int), 240055537871SJiri Kosina .mode = 0644, 240155537871SJiri Kosina .proc_handler = proc_dointvec_minmax, 2402eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2403eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 240455537871SJiri Kosina }, 2405ed235875SAaron Tomlin #endif /* CONFIG_SMP */ 24065dc30558SDon Zickus #endif 240705a4a952SNicholas Piggin #endif 240805a4a952SNicholas Piggin 24095dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 24105dc30558SDon Zickus { 24115dc30558SDon Zickus .procname = "unknown_nmi_panic", 24125dc30558SDon Zickus .data = &unknown_nmi_panic, 24135dc30558SDon Zickus .maxlen = sizeof (int), 24145dc30558SDon Zickus .mode = 0644, 24155dc30558SDon Zickus .proc_handler = proc_dointvec, 24165dc30558SDon Zickus }, 2417504d7cf1SDon Zickus #endif 2418b6522fa4SXiaoming Ni 2419b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \ 2420b6522fa4SXiaoming Ni defined(CONFIG_DEBUG_STACKOVERFLOW) 2421b6522fa4SXiaoming Ni { 2422b6522fa4SXiaoming Ni .procname = "panic_on_stackoverflow", 2423b6522fa4SXiaoming Ni .data = &sysctl_panic_on_stackoverflow, 2424b6522fa4SXiaoming Ni .maxlen = sizeof(int), 2425b6522fa4SXiaoming Ni .mode = 0644, 2426b6522fa4SXiaoming Ni .proc_handler = proc_dointvec, 2427b6522fa4SXiaoming Ni }, 2428b6522fa4SXiaoming Ni #endif 24291da177e4SLinus Torvalds #if defined(CONFIG_X86) 24301da177e4SLinus Torvalds { 24318da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 24328da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 24338da5addaSDon Zickus .maxlen = sizeof(int), 24348da5addaSDon Zickus .mode = 0644, 24356d456111SEric W. Biederman .proc_handler = proc_dointvec, 24368da5addaSDon Zickus }, 24378da5addaSDon Zickus { 24385211a242SKurt Garloff .procname = "panic_on_io_nmi", 24395211a242SKurt Garloff .data = &panic_on_io_nmi, 24405211a242SKurt Garloff .maxlen = sizeof(int), 24415211a242SKurt Garloff .mode = 0644, 24426d456111SEric W. Biederman .proc_handler = proc_dointvec, 24435211a242SKurt Garloff }, 24445211a242SKurt Garloff { 24451da177e4SLinus Torvalds .procname = "bootloader_type", 24461da177e4SLinus Torvalds .data = &bootloader_type, 24471da177e4SLinus Torvalds .maxlen = sizeof (int), 24481da177e4SLinus Torvalds .mode = 0444, 24496d456111SEric W. Biederman .proc_handler = proc_dointvec, 24501da177e4SLinus Torvalds }, 24510741f4d2SChuck Ebbert { 24525031296cSH. Peter Anvin .procname = "bootloader_version", 24535031296cSH. Peter Anvin .data = &bootloader_version, 24545031296cSH. Peter Anvin .maxlen = sizeof (int), 24555031296cSH. Peter Anvin .mode = 0444, 24566d456111SEric W. Biederman .proc_handler = proc_dointvec, 24575031296cSH. Peter Anvin }, 24585031296cSH. Peter Anvin { 24596e7c4025SIngo Molnar .procname = "io_delay_type", 24606e7c4025SIngo Molnar .data = &io_delay_type, 24616e7c4025SIngo Molnar .maxlen = sizeof(int), 24626e7c4025SIngo Molnar .mode = 0644, 24636d456111SEric W. Biederman .proc_handler = proc_dointvec, 24646e7c4025SIngo Molnar }, 24651da177e4SLinus Torvalds #endif 24667a9166e3SLuke Yang #if defined(CONFIG_MMU) 24671da177e4SLinus Torvalds { 24681da177e4SLinus Torvalds .procname = "randomize_va_space", 24691da177e4SLinus Torvalds .data = &randomize_va_space, 24701da177e4SLinus Torvalds .maxlen = sizeof(int), 24711da177e4SLinus Torvalds .mode = 0644, 24726d456111SEric W. Biederman .proc_handler = proc_dointvec, 24731da177e4SLinus Torvalds }, 24747a9166e3SLuke Yang #endif 24750152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 2476951f22d5SMartin Schwidefsky { 2477951f22d5SMartin Schwidefsky .procname = "spin_retry", 2478951f22d5SMartin Schwidefsky .data = &spin_retry, 2479951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 2480951f22d5SMartin Schwidefsky .mode = 0644, 24816d456111SEric W. Biederman .proc_handler = proc_dointvec, 2482951f22d5SMartin Schwidefsky }, 2483951f22d5SMartin Schwidefsky #endif 2484673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 2485c255d844SPavel Machek { 2486c255d844SPavel Machek .procname = "acpi_video_flags", 248777afcf78SPavel Machek .data = &acpi_realmode_flags, 2488c255d844SPavel Machek .maxlen = sizeof (unsigned long), 2489c255d844SPavel Machek .mode = 0644, 24906d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 2491c255d844SPavel Machek }, 2492c255d844SPavel Machek #endif 2493b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN 2494d2b176edSJes Sorensen { 2495d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 2496d2b176edSJes Sorensen .data = &no_unaligned_warning, 2497d2b176edSJes Sorensen .maxlen = sizeof (int), 2498d2b176edSJes Sorensen .mode = 0644, 24996d456111SEric W. Biederman .proc_handler = proc_dointvec, 2500d2b176edSJes Sorensen }, 2501b6fca725SVineet Gupta #endif 2502b6fca725SVineet Gupta #ifdef CONFIG_IA64 250388fc241fSDoug Chapman { 250488fc241fSDoug Chapman .procname = "unaligned-dump-stack", 250588fc241fSDoug Chapman .data = &unaligned_dump_stack, 250688fc241fSDoug Chapman .maxlen = sizeof (int), 250788fc241fSDoug Chapman .mode = 0644, 25086d456111SEric W. Biederman .proc_handler = proc_dointvec, 250988fc241fSDoug Chapman }, 2510d2b176edSJes Sorensen #endif 2511e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 25120ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP 25130ec9dc9bSGuilherme G. Piccoli { 25140ec9dc9bSGuilherme G. Piccoli .procname = "hung_task_all_cpu_backtrace", 25150ec9dc9bSGuilherme G. Piccoli .data = &sysctl_hung_task_all_cpu_backtrace, 25160ec9dc9bSGuilherme G. Piccoli .maxlen = sizeof(int), 25170ec9dc9bSGuilherme G. Piccoli .mode = 0644, 25180ec9dc9bSGuilherme G. Piccoli .proc_handler = proc_dointvec_minmax, 25190ec9dc9bSGuilherme G. Piccoli .extra1 = SYSCTL_ZERO, 25200ec9dc9bSGuilherme G. Piccoli .extra2 = SYSCTL_ONE, 25210ec9dc9bSGuilherme G. Piccoli }, 25220ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */ 2523e162b39aSMandeep Singh Baines { 2524e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 2525e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 2526e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 2527e162b39aSMandeep Singh Baines .mode = 0644, 25286d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2529eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2530eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2531e162b39aSMandeep Singh Baines }, 253282a1fcb9SIngo Molnar { 253382a1fcb9SIngo Molnar .procname = "hung_task_check_count", 253482a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 2535cd64647fSLi Zefan .maxlen = sizeof(int), 253682a1fcb9SIngo Molnar .mode = 0644, 2537cd64647fSLi Zefan .proc_handler = proc_dointvec_minmax, 2538eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 253982a1fcb9SIngo Molnar }, 254082a1fcb9SIngo Molnar { 254182a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 254282a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 254390739081SIngo Molnar .maxlen = sizeof(unsigned long), 254482a1fcb9SIngo Molnar .mode = 0644, 25456d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 254680df2847SLiu Hua .extra2 = &hung_task_timeout_max, 254782a1fcb9SIngo Molnar }, 254882a1fcb9SIngo Molnar { 2549a2e51445SDmitry Vyukov .procname = "hung_task_check_interval_secs", 2550a2e51445SDmitry Vyukov .data = &sysctl_hung_task_check_interval_secs, 2551a2e51445SDmitry Vyukov .maxlen = sizeof(unsigned long), 2552a2e51445SDmitry Vyukov .mode = 0644, 2553a2e51445SDmitry Vyukov .proc_handler = proc_dohung_task_timeout_secs, 2554a2e51445SDmitry Vyukov .extra2 = &hung_task_timeout_max, 2555a2e51445SDmitry Vyukov }, 2556a2e51445SDmitry Vyukov { 255782a1fcb9SIngo Molnar .procname = "hung_task_warnings", 255882a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 2559270750dbSAaron Tomlin .maxlen = sizeof(int), 256082a1fcb9SIngo Molnar .mode = 0644, 2561270750dbSAaron Tomlin .proc_handler = proc_dointvec_minmax, 2562*78e36f3bSXiaoming Ni .extra1 = SYSCTL_NEG_ONE, 256382a1fcb9SIngo Molnar }, 2564c4f3b63fSRavikiran G Thirumalai #endif 256523f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 256623f78d4aSIngo Molnar { 256723f78d4aSIngo Molnar .procname = "max_lock_depth", 256823f78d4aSIngo Molnar .data = &max_lock_depth, 256923f78d4aSIngo Molnar .maxlen = sizeof(int), 257023f78d4aSIngo Molnar .mode = 0644, 25716d456111SEric W. Biederman .proc_handler = proc_dointvec, 257223f78d4aSIngo Molnar }, 257323f78d4aSIngo Molnar #endif 257410a0a8d4SJeremy Fitzhardinge { 257510a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 257610a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 257710a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 257810a0a8d4SJeremy Fitzhardinge .mode = 0644, 25796d456111SEric W. Biederman .proc_handler = proc_dostring, 258010a0a8d4SJeremy Fitzhardinge }, 25810b77f5bfSDavid Howells #ifdef CONFIG_KEYS 25820b77f5bfSDavid Howells { 25830b77f5bfSDavid Howells .procname = "keys", 25840b77f5bfSDavid Howells .mode = 0555, 25850b77f5bfSDavid Howells .child = key_sysctls, 25860b77f5bfSDavid Howells }, 25870b77f5bfSDavid Howells #endif 2588cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 2589aa4a2218SVince Weaver /* 2590aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 2591aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 2592aa4a2218SVince Weaver * 2593aa4a2218SVince Weaver * So it's an ABI, do not remove! 2594aa4a2218SVince Weaver */ 25951ccd1549SPeter Zijlstra { 2596cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 2597cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 2598cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 25991ccd1549SPeter Zijlstra .mode = 0644, 26006d456111SEric W. Biederman .proc_handler = proc_dointvec, 26011ccd1549SPeter Zijlstra }, 2602c5078f78SPeter Zijlstra { 2603cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 2604cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 2605cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 2606c5078f78SPeter Zijlstra .mode = 0644, 26076d456111SEric W. Biederman .proc_handler = proc_dointvec, 2608c5078f78SPeter Zijlstra }, 2609a78ac325SPeter Zijlstra { 2610cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 2611cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 2612cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 2613a78ac325SPeter Zijlstra .mode = 0644, 2614163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 2615eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2616a78ac325SPeter Zijlstra }, 261714c63f17SDave Hansen { 261814c63f17SDave Hansen .procname = "perf_cpu_time_max_percent", 261914c63f17SDave Hansen .data = &sysctl_perf_cpu_time_max_percent, 262014c63f17SDave Hansen .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), 262114c63f17SDave Hansen .mode = 0644, 262214c63f17SDave Hansen .proc_handler = perf_cpu_time_max_percent_handler, 2623eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2624*78e36f3bSXiaoming Ni .extra2 = SYSCTL_ONE_HUNDRED, 262514c63f17SDave Hansen }, 2626c5dfd78eSArnaldo Carvalho de Melo { 2627c5dfd78eSArnaldo Carvalho de Melo .procname = "perf_event_max_stack", 2628a831100aSArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_stack, 2629c5dfd78eSArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_stack), 2630c5dfd78eSArnaldo Carvalho de Melo .mode = 0644, 2631c5dfd78eSArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2632eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2633c5dfd78eSArnaldo Carvalho de Melo .extra2 = &six_hundred_forty_kb, 2634c5dfd78eSArnaldo Carvalho de Melo }, 2635c85b0334SArnaldo Carvalho de Melo { 2636c85b0334SArnaldo Carvalho de Melo .procname = "perf_event_max_contexts_per_stack", 2637c85b0334SArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_contexts_per_stack, 2638c85b0334SArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), 2639c85b0334SArnaldo Carvalho de Melo .mode = 0644, 2640c85b0334SArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2641eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2642*78e36f3bSXiaoming Ni .extra2 = SYSCTL_ONE_THOUSAND, 2643c85b0334SArnaldo Carvalho de Melo }, 26441ccd1549SPeter Zijlstra #endif 26459e3961a0SPrarit Bhargava { 26469e3961a0SPrarit Bhargava .procname = "panic_on_warn", 26479e3961a0SPrarit Bhargava .data = &panic_on_warn, 26489e3961a0SPrarit Bhargava .maxlen = sizeof(int), 26499e3961a0SPrarit Bhargava .mode = 0644, 26509e3961a0SPrarit Bhargava .proc_handler = proc_dointvec_minmax, 2651eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2652eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 26539e3961a0SPrarit Bhargava }, 2654bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 2655bc7a34b8SThomas Gleixner { 2656bc7a34b8SThomas Gleixner .procname = "timer_migration", 2657bc7a34b8SThomas Gleixner .data = &sysctl_timer_migration, 2658bc7a34b8SThomas Gleixner .maxlen = sizeof(unsigned int), 2659bc7a34b8SThomas Gleixner .mode = 0644, 2660bc7a34b8SThomas Gleixner .proc_handler = timer_migration_handler, 2661eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2662eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2663bc7a34b8SThomas Gleixner }, 2664bc7a34b8SThomas Gleixner #endif 26651be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL 26661be7f75dSAlexei Starovoitov { 26671be7f75dSAlexei Starovoitov .procname = "unprivileged_bpf_disabled", 26681be7f75dSAlexei Starovoitov .data = &sysctl_unprivileged_bpf_disabled, 26691be7f75dSAlexei Starovoitov .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), 26701be7f75dSAlexei Starovoitov .mode = 0644, 267108389d88SDaniel Borkmann .proc_handler = bpf_unpriv_handler, 267208389d88SDaniel Borkmann .extra1 = SYSCTL_ZERO, 2673*78e36f3bSXiaoming Ni .extra2 = SYSCTL_TWO, 26741be7f75dSAlexei Starovoitov }, 2675492ecee8SAlexei Starovoitov { 2676492ecee8SAlexei Starovoitov .procname = "bpf_stats_enabled", 2677a8e11e5cSEric Dumazet .data = &bpf_stats_enabled_key.key, 2678a8e11e5cSEric Dumazet .maxlen = sizeof(bpf_stats_enabled_key), 2679492ecee8SAlexei Starovoitov .mode = 0644, 2680d46edd67SSong Liu .proc_handler = bpf_stats_handler, 2681492ecee8SAlexei Starovoitov }, 26823fcc5530SAlexei Starovoitov #endif 2683b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU) 2684088e9d25SDaniel Bristot de Oliveira { 2685088e9d25SDaniel Bristot de Oliveira .procname = "panic_on_rcu_stall", 2686088e9d25SDaniel Bristot de Oliveira .data = &sysctl_panic_on_rcu_stall, 2687088e9d25SDaniel Bristot de Oliveira .maxlen = sizeof(sysctl_panic_on_rcu_stall), 2688088e9d25SDaniel Bristot de Oliveira .mode = 0644, 2689088e9d25SDaniel Bristot de Oliveira .proc_handler = proc_dointvec_minmax, 2690eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2691eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2692088e9d25SDaniel Bristot de Oliveira }, 2693088e9d25SDaniel Bristot de Oliveira #endif 2694dfe56404Schao #if defined(CONFIG_TREE_RCU) 2695dfe56404Schao { 2696dfe56404Schao .procname = "max_rcu_stall_to_panic", 2697dfe56404Schao .data = &sysctl_max_rcu_stall_to_panic, 2698dfe56404Schao .maxlen = sizeof(sysctl_max_rcu_stall_to_panic), 2699dfe56404Schao .mode = 0644, 2700dfe56404Schao .proc_handler = proc_dointvec_minmax, 2701dfe56404Schao .extra1 = SYSCTL_ONE, 2702dfe56404Schao .extra2 = SYSCTL_INT_MAX, 2703dfe56404Schao }, 2704dfe56404Schao #endif 2705964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 2706964c9dffSAlexander Popov { 2707964c9dffSAlexander Popov .procname = "stack_erasing", 2708964c9dffSAlexander Popov .data = NULL, 2709964c9dffSAlexander Popov .maxlen = sizeof(int), 2710964c9dffSAlexander Popov .mode = 0600, 2711964c9dffSAlexander Popov .proc_handler = stack_erasing_sysctl, 2712eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2713eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2714964c9dffSAlexander Popov }, 2715964c9dffSAlexander Popov #endif 27166fce56ecSEric W. Biederman { } 27171da177e4SLinus Torvalds }; 27181da177e4SLinus Torvalds 2719d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 27201da177e4SLinus Torvalds { 27211da177e4SLinus Torvalds .procname = "overcommit_memory", 27221da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 27231da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 27241da177e4SLinus Torvalds .mode = 0644, 272556f3547bSFeng Tang .proc_handler = overcommit_policy_handler, 2726eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2727*78e36f3bSXiaoming Ni .extra2 = SYSCTL_TWO, 27281da177e4SLinus Torvalds }, 27291da177e4SLinus Torvalds { 2730fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 2731fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 2732fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 2733fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 2734cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2735eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2736*78e36f3bSXiaoming Ni .extra2 = SYSCTL_TWO, 2737fadd8fbdSKAMEZAWA Hiroyuki }, 2738fadd8fbdSKAMEZAWA Hiroyuki { 2739fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 2740fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 2741fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 2742fe071d7eSDavid Rientjes .mode = 0644, 27436d456111SEric W. Biederman .proc_handler = proc_dointvec, 2744fe071d7eSDavid Rientjes }, 2745fe071d7eSDavid Rientjes { 2746fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 2747fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 2748fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 2749fef1bdd6SDavid Rientjes .mode = 0644, 27506d456111SEric W. Biederman .proc_handler = proc_dointvec, 2751fef1bdd6SDavid Rientjes }, 2752fef1bdd6SDavid Rientjes { 27531da177e4SLinus Torvalds .procname = "overcommit_ratio", 27541da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 27551da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 27561da177e4SLinus Torvalds .mode = 0644, 275749f0ce5fSJerome Marchand .proc_handler = overcommit_ratio_handler, 275849f0ce5fSJerome Marchand }, 275949f0ce5fSJerome Marchand { 276049f0ce5fSJerome Marchand .procname = "overcommit_kbytes", 276149f0ce5fSJerome Marchand .data = &sysctl_overcommit_kbytes, 276249f0ce5fSJerome Marchand .maxlen = sizeof(sysctl_overcommit_kbytes), 276349f0ce5fSJerome Marchand .mode = 0644, 276449f0ce5fSJerome Marchand .proc_handler = overcommit_kbytes_handler, 27651da177e4SLinus Torvalds }, 27661da177e4SLinus Torvalds { 27671da177e4SLinus Torvalds .procname = "page-cluster", 27681da177e4SLinus Torvalds .data = &page_cluster, 27691da177e4SLinus Torvalds .maxlen = sizeof(int), 27701da177e4SLinus Torvalds .mode = 0644, 2771cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2772eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27731da177e4SLinus Torvalds }, 27741da177e4SLinus Torvalds { 27751da177e4SLinus Torvalds .procname = "dirty_background_ratio", 27761da177e4SLinus Torvalds .data = &dirty_background_ratio, 27771da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 27781da177e4SLinus Torvalds .mode = 0644, 27796d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 2780eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2781*78e36f3bSXiaoming Ni .extra2 = SYSCTL_ONE_HUNDRED, 27821da177e4SLinus Torvalds }, 27831da177e4SLinus Torvalds { 27842da02997SDavid Rientjes .procname = "dirty_background_bytes", 27852da02997SDavid Rientjes .data = &dirty_background_bytes, 27862da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 27872da02997SDavid Rientjes .mode = 0644, 27886d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 2789fc3501d4SSven Wegener .extra1 = &one_ul, 27902da02997SDavid Rientjes }, 27912da02997SDavid Rientjes { 27921da177e4SLinus Torvalds .procname = "dirty_ratio", 27931da177e4SLinus Torvalds .data = &vm_dirty_ratio, 27941da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 27951da177e4SLinus Torvalds .mode = 0644, 27966d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 2797eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2798*78e36f3bSXiaoming Ni .extra2 = SYSCTL_ONE_HUNDRED, 27991da177e4SLinus Torvalds }, 28001da177e4SLinus Torvalds { 28012da02997SDavid Rientjes .procname = "dirty_bytes", 28022da02997SDavid Rientjes .data = &vm_dirty_bytes, 28032da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 28042da02997SDavid Rientjes .mode = 0644, 28056d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 28069e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 28072da02997SDavid Rientjes }, 28082da02997SDavid Rientjes { 28091da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 2810f6ef9438SBart Samwel .data = &dirty_writeback_interval, 2811f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 28121da177e4SLinus Torvalds .mode = 0644, 28136d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 28141da177e4SLinus Torvalds }, 28151da177e4SLinus Torvalds { 28161da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 2817f6ef9438SBart Samwel .data = &dirty_expire_interval, 2818f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 28191da177e4SLinus Torvalds .mode = 0644, 2820cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2821eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28221da177e4SLinus Torvalds }, 28231da177e4SLinus Torvalds { 28241efff914STheodore Ts'o .procname = "dirtytime_expire_seconds", 28251efff914STheodore Ts'o .data = &dirtytime_expire_interval, 28262d87b309SRandy Dunlap .maxlen = sizeof(dirtytime_expire_interval), 28271efff914STheodore Ts'o .mode = 0644, 28281efff914STheodore Ts'o .proc_handler = dirtytime_interval_handler, 2829eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28301efff914STheodore Ts'o }, 28311efff914STheodore Ts'o { 28321da177e4SLinus Torvalds .procname = "swappiness", 28331da177e4SLinus Torvalds .data = &vm_swappiness, 28341da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 28351da177e4SLinus Torvalds .mode = 0644, 28366d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2837eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2838*78e36f3bSXiaoming Ni .extra2 = SYSCTL_TWO_HUNDRED, 28391da177e4SLinus Torvalds }, 28401da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 28411da177e4SLinus Torvalds { 28421da177e4SLinus Torvalds .procname = "nr_hugepages", 2843e5ff2159SAndi Kleen .data = NULL, 28441da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 28451da177e4SLinus Torvalds .mode = 0644, 28466d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 28471da177e4SLinus Torvalds }, 284806808b08SLee Schermerhorn #ifdef CONFIG_NUMA 284906808b08SLee Schermerhorn { 285006808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 285106808b08SLee Schermerhorn .data = NULL, 285206808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 285306808b08SLee Schermerhorn .mode = 0644, 285406808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 285506808b08SLee Schermerhorn }, 28564518085eSKemi Wang { 28574518085eSKemi Wang .procname = "numa_stat", 28584518085eSKemi Wang .data = &sysctl_vm_numa_stat, 28594518085eSKemi Wang .maxlen = sizeof(int), 28604518085eSKemi Wang .mode = 0644, 28614518085eSKemi Wang .proc_handler = sysctl_vm_numa_stat_handler, 2862eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2863eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 28644518085eSKemi Wang }, 286506808b08SLee Schermerhorn #endif 28661da177e4SLinus Torvalds { 28671da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 28681da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 28691da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 28701da177e4SLinus Torvalds .mode = 0644, 28716d456111SEric W. Biederman .proc_handler = proc_dointvec, 28721da177e4SLinus Torvalds }, 2873396faf03SMel Gorman { 2874d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 2875e5ff2159SAndi Kleen .data = NULL, 2876e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 2877d1c3fb1fSNishanth Aravamudan .mode = 0644, 28786d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 2879d1c3fb1fSNishanth Aravamudan }, 28801da177e4SLinus Torvalds #endif 28811da177e4SLinus Torvalds { 28821da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 28831da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 28841da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 28851da177e4SLinus Torvalds .mode = 0644, 28866d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 28871da177e4SLinus Torvalds }, 28881da177e4SLinus Torvalds { 28899d0243bcSAndrew Morton .procname = "drop_caches", 28909d0243bcSAndrew Morton .data = &sysctl_drop_caches, 28919d0243bcSAndrew Morton .maxlen = sizeof(int), 2892204cb79aSJohannes Weiner .mode = 0200, 28939d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 2894eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2895*78e36f3bSXiaoming Ni .extra2 = SYSCTL_FOUR, 28969d0243bcSAndrew Morton }, 289776ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 289876ab0f53SMel Gorman { 289976ab0f53SMel Gorman .procname = "compact_memory", 2900ef498438SPintu Kumar .data = NULL, 290176ab0f53SMel Gorman .maxlen = sizeof(int), 290276ab0f53SMel Gorman .mode = 0200, 290376ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 290476ab0f53SMel Gorman }, 29055e771905SMel Gorman { 2906facdaa91SNitin Gupta .procname = "compaction_proactiveness", 2907facdaa91SNitin Gupta .data = &sysctl_compaction_proactiveness, 2908d34c0a75SNitin Gupta .maxlen = sizeof(sysctl_compaction_proactiveness), 2909facdaa91SNitin Gupta .mode = 0644, 291065d759c8SCharan Teja Reddy .proc_handler = compaction_proactiveness_sysctl_handler, 2911facdaa91SNitin Gupta .extra1 = SYSCTL_ZERO, 2912*78e36f3bSXiaoming Ni .extra2 = SYSCTL_ONE_HUNDRED, 2913facdaa91SNitin Gupta }, 2914facdaa91SNitin Gupta { 29155e771905SMel Gorman .procname = "extfrag_threshold", 29165e771905SMel Gorman .data = &sysctl_extfrag_threshold, 29175e771905SMel Gorman .maxlen = sizeof(int), 29185e771905SMel Gorman .mode = 0644, 29196b7e5cadSMatthew Wilcox .proc_handler = proc_dointvec_minmax, 29205e771905SMel Gorman .extra1 = &min_extfrag_threshold, 29215e771905SMel Gorman .extra2 = &max_extfrag_threshold, 29225e771905SMel Gorman }, 29235bbe3547SEric B Munson { 29245bbe3547SEric B Munson .procname = "compact_unevictable_allowed", 29255bbe3547SEric B Munson .data = &sysctl_compact_unevictable_allowed, 29265bbe3547SEric B Munson .maxlen = sizeof(int), 29275bbe3547SEric B Munson .mode = 0644, 29286923aa0dSSebastian Andrzej Siewior .proc_handler = proc_dointvec_minmax_warn_RT_change, 2929eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2930eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 29315bbe3547SEric B Munson }, 29325e771905SMel Gorman 293376ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 29349d0243bcSAndrew Morton { 29351da177e4SLinus Torvalds .procname = "min_free_kbytes", 29361da177e4SLinus Torvalds .data = &min_free_kbytes, 29371da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 29381da177e4SLinus Torvalds .mode = 0644, 29396d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 2940eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29411da177e4SLinus Torvalds }, 29428ad4b1fbSRohit Seth { 29431c30844dSMel Gorman .procname = "watermark_boost_factor", 29441c30844dSMel Gorman .data = &watermark_boost_factor, 29451c30844dSMel Gorman .maxlen = sizeof(watermark_boost_factor), 29461c30844dSMel Gorman .mode = 0644, 294726363af5SChristoph Hellwig .proc_handler = proc_dointvec_minmax, 2948eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29491c30844dSMel Gorman }, 29501c30844dSMel Gorman { 2951795ae7a0SJohannes Weiner .procname = "watermark_scale_factor", 2952795ae7a0SJohannes Weiner .data = &watermark_scale_factor, 2953795ae7a0SJohannes Weiner .maxlen = sizeof(watermark_scale_factor), 2954795ae7a0SJohannes Weiner .mode = 0644, 2955795ae7a0SJohannes Weiner .proc_handler = watermark_scale_factor_sysctl_handler, 2956eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2957*78e36f3bSXiaoming Ni .extra2 = SYSCTL_THREE_THOUSAND, 2958795ae7a0SJohannes Weiner }, 2959795ae7a0SJohannes Weiner { 296074f44822SMel Gorman .procname = "percpu_pagelist_high_fraction", 296174f44822SMel Gorman .data = &percpu_pagelist_high_fraction, 296274f44822SMel Gorman .maxlen = sizeof(percpu_pagelist_high_fraction), 29638ad4b1fbSRohit Seth .mode = 0644, 296474f44822SMel Gorman .proc_handler = percpu_pagelist_high_fraction_sysctl_handler, 2965eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29668ad4b1fbSRohit Seth }, 29675ef64cc8SLinus Torvalds { 29685ef64cc8SLinus Torvalds .procname = "page_lock_unfairness", 29695ef64cc8SLinus Torvalds .data = &sysctl_page_lock_unfairness, 29705ef64cc8SLinus Torvalds .maxlen = sizeof(sysctl_page_lock_unfairness), 29715ef64cc8SLinus Torvalds .mode = 0644, 29725ef64cc8SLinus Torvalds .proc_handler = proc_dointvec_minmax, 29735ef64cc8SLinus Torvalds .extra1 = SYSCTL_ZERO, 29745ef64cc8SLinus Torvalds }, 29751da177e4SLinus Torvalds #ifdef CONFIG_MMU 29761da177e4SLinus Torvalds { 29771da177e4SLinus Torvalds .procname = "max_map_count", 29781da177e4SLinus Torvalds .data = &sysctl_max_map_count, 29791da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 29801da177e4SLinus Torvalds .mode = 0644, 29813e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 2982eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29831da177e4SLinus Torvalds }, 2984dd8632a1SPaul Mundt #else 2985dd8632a1SPaul Mundt { 2986dd8632a1SPaul Mundt .procname = "nr_trim_pages", 2987dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 2988dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 2989dd8632a1SPaul Mundt .mode = 0644, 29906d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2991eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2992dd8632a1SPaul Mundt }, 29931da177e4SLinus Torvalds #endif 29941da177e4SLinus Torvalds { 29951da177e4SLinus Torvalds .procname = "laptop_mode", 29961da177e4SLinus Torvalds .data = &laptop_mode, 29971da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 29981da177e4SLinus Torvalds .mode = 0644, 29996d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 30001da177e4SLinus Torvalds }, 30011da177e4SLinus Torvalds { 30021da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 30031da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 30041da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 30051da177e4SLinus Torvalds .mode = 0644, 30063b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 3007eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30081da177e4SLinus Torvalds }, 300967f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 301067f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 30111da177e4SLinus Torvalds { 30121da177e4SLinus Torvalds .procname = "legacy_va_layout", 30131da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 30141da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 30151da177e4SLinus Torvalds .mode = 0644, 30163b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 3017eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30181da177e4SLinus Torvalds }, 30191da177e4SLinus Torvalds #endif 30201743660bSChristoph Lameter #ifdef CONFIG_NUMA 30211743660bSChristoph Lameter { 30221743660bSChristoph Lameter .procname = "zone_reclaim_mode", 3023a5f5f91dSMel Gorman .data = &node_reclaim_mode, 3024a5f5f91dSMel Gorman .maxlen = sizeof(node_reclaim_mode), 30251743660bSChristoph Lameter .mode = 0644, 30263b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 3027eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30281743660bSChristoph Lameter }, 30299614634fSChristoph Lameter { 30309614634fSChristoph Lameter .procname = "min_unmapped_ratio", 30319614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 30329614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 30339614634fSChristoph Lameter .mode = 0644, 30346d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 3035eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3036*78e36f3bSXiaoming Ni .extra2 = SYSCTL_ONE_HUNDRED, 30379614634fSChristoph Lameter }, 30380ff38490SChristoph Lameter { 30390ff38490SChristoph Lameter .procname = "min_slab_ratio", 30400ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 30410ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 30420ff38490SChristoph Lameter .mode = 0644, 30436d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 3044eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3045*78e36f3bSXiaoming Ni .extra2 = SYSCTL_ONE_HUNDRED, 30460ff38490SChristoph Lameter }, 30471743660bSChristoph Lameter #endif 304877461ab3SChristoph Lameter #ifdef CONFIG_SMP 304977461ab3SChristoph Lameter { 305077461ab3SChristoph Lameter .procname = "stat_interval", 305177461ab3SChristoph Lameter .data = &sysctl_stat_interval, 305277461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 305377461ab3SChristoph Lameter .mode = 0644, 30546d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 305577461ab3SChristoph Lameter }, 305652b6f46bSHugh Dickins { 305752b6f46bSHugh Dickins .procname = "stat_refresh", 305852b6f46bSHugh Dickins .data = NULL, 305952b6f46bSHugh Dickins .maxlen = 0, 306052b6f46bSHugh Dickins .mode = 0600, 306152b6f46bSHugh Dickins .proc_handler = vmstat_refresh, 306252b6f46bSHugh Dickins }, 306377461ab3SChristoph Lameter #endif 30646e141546SDavid Howells #ifdef CONFIG_MMU 3065ed032189SEric Paris { 3066ed032189SEric Paris .procname = "mmap_min_addr", 3067788084abSEric Paris .data = &dac_mmap_min_addr, 3068ed032189SEric Paris .maxlen = sizeof(unsigned long), 3069ed032189SEric Paris .mode = 0644, 30706d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 3071ed032189SEric Paris }, 30726e141546SDavid Howells #endif 3073f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 3074f0c0b2b8SKAMEZAWA Hiroyuki { 3075f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 3076f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 3077f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 3078f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 30796d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 3080f0c0b2b8SKAMEZAWA Hiroyuki }, 3081f0c0b2b8SKAMEZAWA Hiroyuki #endif 30822b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 30835c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 3084e6e5494cSIngo Molnar { 3085e6e5494cSIngo Molnar .procname = "vdso_enabled", 30863d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32 30873d7ee969SAndy Lutomirski .data = &vdso32_enabled, 30883d7ee969SAndy Lutomirski .maxlen = sizeof(vdso32_enabled), 30893d7ee969SAndy Lutomirski #else 3090e6e5494cSIngo Molnar .data = &vdso_enabled, 3091e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 30923d7ee969SAndy Lutomirski #endif 3093e6e5494cSIngo Molnar .mode = 0644, 30946d456111SEric W. Biederman .proc_handler = proc_dointvec, 3095eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3096e6e5494cSIngo Molnar }, 3097e6e5494cSIngo Molnar #endif 3098195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 3099195cf453SBron Gondwana { 3100195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 3101195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 3102195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 3103195cf453SBron Gondwana .mode = 0644, 31046d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3105eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3106eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3107195cf453SBron Gondwana }, 3108195cf453SBron Gondwana #endif 31096a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 31106a46079cSAndi Kleen { 31116a46079cSAndi Kleen .procname = "memory_failure_early_kill", 31126a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 31136a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 31146a46079cSAndi Kleen .mode = 0644, 31156d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3116eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3117eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 31186a46079cSAndi Kleen }, 31196a46079cSAndi Kleen { 31206a46079cSAndi Kleen .procname = "memory_failure_recovery", 31216a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 31226a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 31236a46079cSAndi Kleen .mode = 0644, 31246d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3125eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3126eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 31276a46079cSAndi Kleen }, 31286a46079cSAndi Kleen #endif 3129c9b1d098SAndrew Shewmaker { 3130c9b1d098SAndrew Shewmaker .procname = "user_reserve_kbytes", 3131c9b1d098SAndrew Shewmaker .data = &sysctl_user_reserve_kbytes, 3132c9b1d098SAndrew Shewmaker .maxlen = sizeof(sysctl_user_reserve_kbytes), 3133c9b1d098SAndrew Shewmaker .mode = 0644, 3134c9b1d098SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 3135c9b1d098SAndrew Shewmaker }, 31364eeab4f5SAndrew Shewmaker { 31374eeab4f5SAndrew Shewmaker .procname = "admin_reserve_kbytes", 31384eeab4f5SAndrew Shewmaker .data = &sysctl_admin_reserve_kbytes, 31394eeab4f5SAndrew Shewmaker .maxlen = sizeof(sysctl_admin_reserve_kbytes), 31404eeab4f5SAndrew Shewmaker .mode = 0644, 31414eeab4f5SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 31424eeab4f5SAndrew Shewmaker }, 3143d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS 3144d07e2259SDaniel Cashman { 3145d07e2259SDaniel Cashman .procname = "mmap_rnd_bits", 3146d07e2259SDaniel Cashman .data = &mmap_rnd_bits, 3147d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_bits), 3148d07e2259SDaniel Cashman .mode = 0600, 3149d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3150d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_bits_min, 3151d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_bits_max, 3152d07e2259SDaniel Cashman }, 3153d07e2259SDaniel Cashman #endif 3154d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS 3155d07e2259SDaniel Cashman { 3156d07e2259SDaniel Cashman .procname = "mmap_rnd_compat_bits", 3157d07e2259SDaniel Cashman .data = &mmap_rnd_compat_bits, 3158d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_compat_bits), 3159d07e2259SDaniel Cashman .mode = 0600, 3160d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3161d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_compat_bits_min, 3162d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_compat_bits_max, 3163d07e2259SDaniel Cashman }, 3164d07e2259SDaniel Cashman #endif 3165cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD 3166cefdca0aSPeter Xu { 3167cefdca0aSPeter Xu .procname = "unprivileged_userfaultfd", 3168cefdca0aSPeter Xu .data = &sysctl_unprivileged_userfaultfd, 3169cefdca0aSPeter Xu .maxlen = sizeof(sysctl_unprivileged_userfaultfd), 3170cefdca0aSPeter Xu .mode = 0644, 3171cefdca0aSPeter Xu .proc_handler = proc_dointvec_minmax, 3172eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3173eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3174cefdca0aSPeter Xu }, 3175cefdca0aSPeter Xu #endif 31766fce56ecSEric W. Biederman { } 31771da177e4SLinus Torvalds }; 31781da177e4SLinus Torvalds 3179d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 31801da177e4SLinus Torvalds { 31811da177e4SLinus Torvalds .procname = "inode-nr", 31821da177e4SLinus Torvalds .data = &inodes_stat, 31833942c07cSGlauber Costa .maxlen = 2*sizeof(long), 31841da177e4SLinus Torvalds .mode = 0444, 3185cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 31861da177e4SLinus Torvalds }, 31871da177e4SLinus Torvalds { 31881da177e4SLinus Torvalds .procname = "inode-state", 31891da177e4SLinus Torvalds .data = &inodes_stat, 31903942c07cSGlauber Costa .maxlen = 7*sizeof(long), 31911da177e4SLinus Torvalds .mode = 0444, 3192cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 31931da177e4SLinus Torvalds }, 31941da177e4SLinus Torvalds { 31951da177e4SLinus Torvalds .procname = "file-nr", 31961da177e4SLinus Torvalds .data = &files_stat, 3197518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 31981da177e4SLinus Torvalds .mode = 0444, 31996d456111SEric W. Biederman .proc_handler = proc_nr_files, 32001da177e4SLinus Torvalds }, 32011da177e4SLinus Torvalds { 32021da177e4SLinus Torvalds .procname = "file-max", 32031da177e4SLinus Torvalds .data = &files_stat.max_files, 3204518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 32051da177e4SLinus Torvalds .mode = 0644, 3206518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 32079002b214SWill Deacon .extra1 = &zero_ul, 320832a5ad9cSChristian Brauner .extra2 = &long_max, 32091da177e4SLinus Torvalds }, 32101da177e4SLinus Torvalds { 32119cfe015aSEric Dumazet .procname = "nr_open", 32129cfe015aSEric Dumazet .data = &sysctl_nr_open, 32139b80a184SAlexey Dobriyan .maxlen = sizeof(unsigned int), 32149cfe015aSEric Dumazet .mode = 0644, 32156d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3216eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 3217eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 32189cfe015aSEric Dumazet }, 32199cfe015aSEric Dumazet { 32201da177e4SLinus Torvalds .procname = "dentry-state", 32211da177e4SLinus Torvalds .data = &dentry_stat, 32223942c07cSGlauber Costa .maxlen = 6*sizeof(long), 32231da177e4SLinus Torvalds .mode = 0444, 3224312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 32251da177e4SLinus Torvalds }, 32261da177e4SLinus Torvalds { 32271da177e4SLinus Torvalds .procname = "overflowuid", 32281da177e4SLinus Torvalds .data = &fs_overflowuid, 32291da177e4SLinus Torvalds .maxlen = sizeof(int), 32301da177e4SLinus Torvalds .mode = 0644, 32316d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 32321da177e4SLinus Torvalds .extra1 = &minolduid, 32331da177e4SLinus Torvalds .extra2 = &maxolduid, 32341da177e4SLinus Torvalds }, 32351da177e4SLinus Torvalds { 32361da177e4SLinus Torvalds .procname = "overflowgid", 32371da177e4SLinus Torvalds .data = &fs_overflowgid, 32381da177e4SLinus Torvalds .maxlen = sizeof(int), 32391da177e4SLinus Torvalds .mode = 0644, 32406d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 32411da177e4SLinus Torvalds .extra1 = &minolduid, 32421da177e4SLinus Torvalds .extra2 = &maxolduid, 32431da177e4SLinus Torvalds }, 3244bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 32451da177e4SLinus Torvalds { 32461da177e4SLinus Torvalds .procname = "leases-enable", 32471da177e4SLinus Torvalds .data = &leases_enable, 32481da177e4SLinus Torvalds .maxlen = sizeof(int), 32491da177e4SLinus Torvalds .mode = 0644, 32506d456111SEric W. Biederman .proc_handler = proc_dointvec, 32511da177e4SLinus Torvalds }, 3252bfcd17a6SThomas Petazzoni #endif 32531da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 32541da177e4SLinus Torvalds { 32551da177e4SLinus Torvalds .procname = "dir-notify-enable", 32561da177e4SLinus Torvalds .data = &dir_notify_enable, 32571da177e4SLinus Torvalds .maxlen = sizeof(int), 32581da177e4SLinus Torvalds .mode = 0644, 32596d456111SEric W. Biederman .proc_handler = proc_dointvec, 32601da177e4SLinus Torvalds }, 32611da177e4SLinus Torvalds #endif 32621da177e4SLinus Torvalds #ifdef CONFIG_MMU 3263bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 32641da177e4SLinus Torvalds { 32651da177e4SLinus Torvalds .procname = "lease-break-time", 32661da177e4SLinus Torvalds .data = &lease_break_time, 32671da177e4SLinus Torvalds .maxlen = sizeof(int), 32681da177e4SLinus Torvalds .mode = 0644, 32696d456111SEric W. Biederman .proc_handler = proc_dointvec, 32701da177e4SLinus Torvalds }, 3271bfcd17a6SThomas Petazzoni #endif 3272ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 32731da177e4SLinus Torvalds { 32741da177e4SLinus Torvalds .procname = "aio-nr", 32751da177e4SLinus Torvalds .data = &aio_nr, 32761da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 32771da177e4SLinus Torvalds .mode = 0444, 32786d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 32791da177e4SLinus Torvalds }, 32801da177e4SLinus Torvalds { 32811da177e4SLinus Torvalds .procname = "aio-max-nr", 32821da177e4SLinus Torvalds .data = &aio_max_nr, 32831da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 32841da177e4SLinus Torvalds .mode = 0644, 32856d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 32861da177e4SLinus Torvalds }, 3287ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 32882d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 32890399cb08SRobert Love { 32900399cb08SRobert Love .procname = "inotify", 32910399cb08SRobert Love .mode = 0555, 32920399cb08SRobert Love .child = inotify_table, 32930399cb08SRobert Love }, 32940399cb08SRobert Love #endif 32955b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY 32965b8fea65SAmir Goldstein { 32975b8fea65SAmir Goldstein .procname = "fanotify", 32985b8fea65SAmir Goldstein .mode = 0555, 32995b8fea65SAmir Goldstein .child = fanotify_table, 33005b8fea65SAmir Goldstein }, 33015b8fea65SAmir Goldstein #endif 33027ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 33037ef9964eSDavide Libenzi { 33047ef9964eSDavide Libenzi .procname = "epoll", 33057ef9964eSDavide Libenzi .mode = 0555, 33067ef9964eSDavide Libenzi .child = epoll_table, 33077ef9964eSDavide Libenzi }, 33087ef9964eSDavide Libenzi #endif 33091da177e4SLinus Torvalds #endif 3310d6e71144SAlan Cox { 3311800179c9SKees Cook .procname = "protected_symlinks", 3312800179c9SKees Cook .data = &sysctl_protected_symlinks, 3313800179c9SKees Cook .maxlen = sizeof(int), 3314800179c9SKees Cook .mode = 0600, 3315800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3316eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3317eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3318800179c9SKees Cook }, 3319800179c9SKees Cook { 3320800179c9SKees Cook .procname = "protected_hardlinks", 3321800179c9SKees Cook .data = &sysctl_protected_hardlinks, 3322800179c9SKees Cook .maxlen = sizeof(int), 3323800179c9SKees Cook .mode = 0600, 3324800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3325eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3326eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3327800179c9SKees Cook }, 3328800179c9SKees Cook { 332930aba665SSalvatore Mesoraca .procname = "protected_fifos", 333030aba665SSalvatore Mesoraca .data = &sysctl_protected_fifos, 333130aba665SSalvatore Mesoraca .maxlen = sizeof(int), 333230aba665SSalvatore Mesoraca .mode = 0600, 333330aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3334eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3335*78e36f3bSXiaoming Ni .extra2 = SYSCTL_TWO, 333630aba665SSalvatore Mesoraca }, 333730aba665SSalvatore Mesoraca { 333830aba665SSalvatore Mesoraca .procname = "protected_regular", 333930aba665SSalvatore Mesoraca .data = &sysctl_protected_regular, 334030aba665SSalvatore Mesoraca .maxlen = sizeof(int), 334130aba665SSalvatore Mesoraca .mode = 0600, 334230aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3343eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3344*78e36f3bSXiaoming Ni .extra2 = SYSCTL_TWO, 334530aba665SSalvatore Mesoraca }, 334630aba665SSalvatore Mesoraca { 3347d6e71144SAlan Cox .procname = "suid_dumpable", 3348d6e71144SAlan Cox .data = &suid_dumpable, 3349d6e71144SAlan Cox .maxlen = sizeof(int), 3350d6e71144SAlan Cox .mode = 0644, 335154b50199SKees Cook .proc_handler = proc_dointvec_minmax_coredump, 3352eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3353*78e36f3bSXiaoming Ni .extra2 = SYSCTL_TWO, 3354d6e71144SAlan Cox }, 33552abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 33562abc26fcSEric W. Biederman { 33572abc26fcSEric W. Biederman .procname = "binfmt_misc", 33582abc26fcSEric W. Biederman .mode = 0555, 3359f9bd6733SEric W. Biederman .child = sysctl_mount_point, 33602abc26fcSEric W. Biederman }, 33612abc26fcSEric W. Biederman #endif 3362b492e95bSJens Axboe { 3363ff9da691SJens Axboe .procname = "pipe-max-size", 3364ff9da691SJens Axboe .data = &pipe_max_size, 336598159d97SJoe Lawrence .maxlen = sizeof(pipe_max_size), 3366b492e95bSJens Axboe .mode = 0644, 3367319e0a21SEric Biggers .proc_handler = proc_dopipe_max_size, 3368b492e95bSJens Axboe }, 3369759c0114SWilly Tarreau { 3370759c0114SWilly Tarreau .procname = "pipe-user-pages-hard", 3371759c0114SWilly Tarreau .data = &pipe_user_pages_hard, 3372759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_hard), 3373759c0114SWilly Tarreau .mode = 0644, 3374759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3375759c0114SWilly Tarreau }, 3376759c0114SWilly Tarreau { 3377759c0114SWilly Tarreau .procname = "pipe-user-pages-soft", 3378759c0114SWilly Tarreau .data = &pipe_user_pages_soft, 3379759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_soft), 3380759c0114SWilly Tarreau .mode = 0644, 3381759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3382759c0114SWilly Tarreau }, 3383d2921684SEric W. Biederman { 3384d2921684SEric W. Biederman .procname = "mount-max", 3385d2921684SEric W. Biederman .data = &sysctl_mount_max, 3386d2921684SEric W. Biederman .maxlen = sizeof(unsigned int), 3387d2921684SEric W. Biederman .mode = 0644, 3388d2921684SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3389eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 3390d2921684SEric W. Biederman }, 33916fce56ecSEric W. Biederman { } 33921da177e4SLinus Torvalds }; 33931da177e4SLinus Torvalds 3394d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 33957ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE 3396abd4f750SMasoud Asgharifard Sharbiani { 3397abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 3398abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 3399abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 3400abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 3401abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 3402abd4f750SMasoud Asgharifard Sharbiani }, 3403abd4f750SMasoud Asgharifard Sharbiani #endif 3404b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 3405b2be84dfSMasami Hiramatsu { 3406b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 3407b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 3408b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 3409b2be84dfSMasami Hiramatsu .mode = 0644, 3410b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 3411eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3412eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3413b2be84dfSMasami Hiramatsu }, 3414b2be84dfSMasami Hiramatsu #endif 34156fce56ecSEric W. Biederman { } 34161da177e4SLinus Torvalds }; 34171da177e4SLinus Torvalds 3418d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 34196fce56ecSEric W. Biederman { } 34201da177e4SLinus Torvalds }; 34211da177e4SLinus Torvalds 3422f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = { 3423f461d2dcSChristoph Hellwig { 3424f461d2dcSChristoph Hellwig .procname = "kernel", 3425f461d2dcSChristoph Hellwig .mode = 0555, 3426f461d2dcSChristoph Hellwig .child = kern_table, 3427f461d2dcSChristoph Hellwig }, 3428f461d2dcSChristoph Hellwig { 3429f461d2dcSChristoph Hellwig .procname = "vm", 3430f461d2dcSChristoph Hellwig .mode = 0555, 3431f461d2dcSChristoph Hellwig .child = vm_table, 3432f461d2dcSChristoph Hellwig }, 3433f461d2dcSChristoph Hellwig { 3434f461d2dcSChristoph Hellwig .procname = "fs", 3435f461d2dcSChristoph Hellwig .mode = 0555, 3436f461d2dcSChristoph Hellwig .child = fs_table, 3437f461d2dcSChristoph Hellwig }, 3438f461d2dcSChristoph Hellwig { 3439f461d2dcSChristoph Hellwig .procname = "debug", 3440f461d2dcSChristoph Hellwig .mode = 0555, 3441f461d2dcSChristoph Hellwig .child = debug_table, 3442f461d2dcSChristoph Hellwig }, 3443f461d2dcSChristoph Hellwig { 3444f461d2dcSChristoph Hellwig .procname = "dev", 3445f461d2dcSChristoph Hellwig .mode = 0555, 3446f461d2dcSChristoph Hellwig .child = dev_table, 3447f461d2dcSChristoph Hellwig }, 3448f461d2dcSChristoph Hellwig { } 3449f461d2dcSChristoph Hellwig }; 3450f461d2dcSChristoph Hellwig 3451de4e83bdSEric W. Biederman int __init sysctl_init(void) 3452330d57fbSAl Viro { 3453fd4b616bSSteven Rostedt struct ctl_table_header *hdr; 3454fd4b616bSSteven Rostedt 3455fd4b616bSSteven Rostedt hdr = register_sysctl_table(sysctl_base_table); 3456fd4b616bSSteven Rostedt kmemleak_not_leak(hdr); 3457330d57fbSAl Viro return 0; 3458f7e6ced4SAl Viro } 3459b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 34601da177e4SLinus Torvalds /* 34611da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 34621da177e4SLinus Torvalds * exception granted :-) 34631da177e4SLinus Torvalds */ 3464a2071573SJia He EXPORT_SYMBOL(proc_dobool); 34651da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 3466e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec); 34671da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 34681da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 346961d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 34701da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 34711da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 34721da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 34731da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 34741da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 34750bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap); 3476