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> 30455cd5abSDan Rosenberg #include <linux/printk.h> 311da177e4SLinus Torvalds #include <linux/proc_fs.h> 3272c2d582SAndrew Morgan #include <linux/security.h> 331da177e4SLinus Torvalds #include <linux/ctype.h> 34fd4b616bSSteven Rostedt #include <linux/kmemleak.h> 3562239ac2SAdrian Bunk #include <linux/fs.h> 361da177e4SLinus Torvalds #include <linux/init.h> 371da177e4SLinus Torvalds #include <linux/kernel.h> 380296b228SKay Sievers #include <linux/kobject.h> 3920380731SArnaldo Carvalho de Melo #include <linux/net.h> 401da177e4SLinus Torvalds #include <linux/sysrq.h> 411da177e4SLinus Torvalds #include <linux/highuid.h> 421da177e4SLinus Torvalds #include <linux/writeback.h> 433fff4c42SIngo Molnar #include <linux/ratelimit.h> 4476ab0f53SMel Gorman #include <linux/compaction.h> 451da177e4SLinus Torvalds #include <linux/hugetlb.h> 461da177e4SLinus Torvalds #include <linux/initrd.h> 470b77f5bfSDavid Howells #include <linux/key.h> 481da177e4SLinus Torvalds #include <linux/times.h> 491da177e4SLinus Torvalds #include <linux/limits.h> 501da177e4SLinus Torvalds #include <linux/dcache.h> 516e006701SAlexey Dobriyan #include <linux/dnotify.h> 521da177e4SLinus Torvalds #include <linux/syscalls.h> 53c748e134SAdrian Bunk #include <linux/vmstat.h> 54c255d844SPavel Machek #include <linux/nfs_fs.h> 55c255d844SPavel Machek #include <linux/acpi.h> 5610a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 57b0fc494fSSteven Rostedt #include <linux/ftrace.h> 58cdd6c482SIngo Molnar #include <linux/perf_event.h> 59b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 60b492e95bSJens Axboe #include <linux/pipe_fs_i.h> 618e4228e1SDavid Rientjes #include <linux/oom.h> 6217f60a7dSEric Paris #include <linux/kmod.h> 6373efc039SDan Ballard #include <linux/capability.h> 6440401530SAl Viro #include <linux/binfmts.h> 65cf4aebc2SClark Williams #include <linux/sched/sysctl.h> 66f7ccbae4SIngo Molnar #include <linux/sched/coredump.h> 677984754bSKees Cook #include <linux/kexec.h> 681be7f75dSAlexei Starovoitov #include <linux/bpf.h> 69d2921684SEric W. Biederman #include <linux/mount.h> 70cefdca0aSPeter Xu #include <linux/userfaultfd_k.h> 712374c09bSChristoph Hellwig #include <linux/coredump.h> 722374c09bSChristoph Hellwig #include <linux/latencytop.h> 732374c09bSChristoph Hellwig #include <linux/pid.h> 741da177e4SLinus Torvalds 757f2923c4SChristian Brauner #include "../lib/kstrtox.h" 767f2923c4SChristian Brauner 777c0f6ba6SLinus Torvalds #include <linux/uaccess.h> 781da177e4SLinus Torvalds #include <asm/processor.h> 791da177e4SLinus Torvalds 8029cbc78bSAndi Kleen #ifdef CONFIG_X86 8129cbc78bSAndi Kleen #include <asm/nmi.h> 820741f4d2SChuck Ebbert #include <asm/stacktrace.h> 836e7c4025SIngo Molnar #include <asm/io.h> 8429cbc78bSAndi Kleen #endif 85d550bbd4SDavid Howells #ifdef CONFIG_SPARC 86d550bbd4SDavid Howells #include <asm/setup.h> 87d550bbd4SDavid Howells #endif 88c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 89c55b7c3eSDave Young #include <linux/acct.h> 90c55b7c3eSDave Young #endif 914f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 924f0e056fSDave Young #include <linux/rtmutex.h> 934f0e056fSDave Young #endif 942edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 952edf5e49SDave Young #include <linux/lockdep.h> 962edf5e49SDave Young #endif 9715485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 9815485a46SDave Young #include <scsi/sg.h> 9915485a46SDave Young #endif 100964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 101964c9dffSAlexander Popov #include <linux/stackleak.h> 102964c9dffSAlexander Popov #endif 10358687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 104504d7cf1SDon Zickus #include <linux/nmi.h> 105504d7cf1SDon Zickus #endif 106504d7cf1SDon Zickus 1071da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 1081da177e4SLinus Torvalds 109c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1102508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 111c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 112c4f3b63fSRavikiran G Thirumalai #endif 113c4f3b63fSRavikiran G Thirumalai 114270750dbSAaron Tomlin static int __maybe_unused neg_one = -1; 115cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 1165509a5d2SDave Hansen static int __maybe_unused four = 4; 1179002b214SWill Deacon static unsigned long zero_ul; 118fc3501d4SSven Wegener static unsigned long one_ul = 1; 11932a5ad9cSChristian Brauner static unsigned long long_max = LONG_MAX; 120c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 121795ae7a0SJohannes Weiner static int one_thousand = 1000; 122af91322eSDave Young #ifdef CONFIG_PRINTK 123af91322eSDave Young static int ten_thousand = 10000; 124af91322eSDave Young #endif 125c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS 126c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024; 127c5dfd78eSArnaldo Carvalho de Melo #endif 128c4f3b63fSRavikiran G Thirumalai 1299e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1309e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1319e4a5bdaSAndrea Righi 1321da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1331da177e4SLinus Torvalds static int maxolduid = 65535; 1341da177e4SLinus Torvalds static int minolduid; 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 13773efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP; 1381da177e4SLinus Torvalds 139a2e51445SDmitry Vyukov /* 140a2e51445SDmitry Vyukov * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs 141a2e51445SDmitry Vyukov * and hung_task_check_interval_secs 142a2e51445SDmitry Vyukov */ 14380df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK 14480df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); 14580df2847SLiu Hua #endif 14680df2847SLiu Hua 147d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 148d14f1729SDave Young #include <linux/inotify.h> 149d14f1729SDave Young #endif 150b6fca725SVineet Gupta 151d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 152f4aacea2SKees Cook 153a19ac337SLuis R. Rodriguez /** 154a19ac337SLuis R. Rodriguez * enum sysctl_writes_mode - supported sysctl write modes 155a19ac337SLuis R. Rodriguez * 156a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value 157a19ac337SLuis R. Rodriguez * to be written, and multiple writes on the same sysctl file descriptor 158a19ac337SLuis R. Rodriguez * will rewrite the sysctl value, regardless of file position. No warning 159a19ac337SLuis R. Rodriguez * is issued when the initial position is not 0. 160a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is 161a19ac337SLuis R. Rodriguez * not 0. 162a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at 163a19ac337SLuis R. Rodriguez * file position 0 and the value must be fully contained in the buffer 164a19ac337SLuis R. Rodriguez * sent to the write syscall. If dealing with strings respect the file 165a19ac337SLuis R. Rodriguez * position, but restrict this to the max length of the buffer, anything 16665f50f25SWeitao Hou * passed the max length will be ignored. Multiple writes will append 167a19ac337SLuis R. Rodriguez * to the buffer. 168a19ac337SLuis R. Rodriguez * 169a19ac337SLuis R. Rodriguez * These write modes control how current file position affects the behavior of 170a19ac337SLuis R. Rodriguez * updating sysctl values through the proc interface on each write. 171a19ac337SLuis R. Rodriguez */ 172a19ac337SLuis R. Rodriguez enum sysctl_writes_mode { 173a19ac337SLuis R. Rodriguez SYSCTL_WRITES_LEGACY = -1, 174a19ac337SLuis R. Rodriguez SYSCTL_WRITES_WARN = 0, 175a19ac337SLuis R. Rodriguez SYSCTL_WRITES_STRICT = 1, 176a19ac337SLuis R. Rodriguez }; 177f4aacea2SKees Cook 178a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; 179f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 180ceb18132SLuis R. Rodriguez 18167f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 18267f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 1831da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1841da177e4SLinus Torvalds #endif 1851da177e4SLinus Torvalds 18677e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 18773c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 18873c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 18973c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 19073c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 191cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP 1921983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 1931983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 194cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */ 195cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */ 19677e54a1fSIngo Molnar 1975e771905SMel Gorman #ifdef CONFIG_COMPACTION 1985e771905SMel Gorman static int min_extfrag_threshold; 1995e771905SMel Gorman static int max_extfrag_threshold = 1000; 2005e771905SMel Gorman #endif 2015e771905SMel Gorman 202f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */ 203f461d2dcSChristoph Hellwig 204*d46edd67SSong Liu #ifdef CONFIG_BPF_SYSCALL 205*d46edd67SSong Liu static int bpf_stats_handler(struct ctl_table *table, int write, 206*d46edd67SSong Liu void __user *buffer, size_t *lenp, 207*d46edd67SSong Liu loff_t *ppos) 208*d46edd67SSong Liu { 209*d46edd67SSong Liu struct static_key *key = (struct static_key *)table->data; 210*d46edd67SSong Liu static int saved_val; 211*d46edd67SSong Liu int val, ret; 212*d46edd67SSong Liu struct ctl_table tmp = { 213*d46edd67SSong Liu .data = &val, 214*d46edd67SSong Liu .maxlen = sizeof(val), 215*d46edd67SSong Liu .mode = table->mode, 216*d46edd67SSong Liu .extra1 = SYSCTL_ZERO, 217*d46edd67SSong Liu .extra2 = SYSCTL_ONE, 218*d46edd67SSong Liu }; 219*d46edd67SSong Liu 220*d46edd67SSong Liu if (write && !capable(CAP_SYS_ADMIN)) 221*d46edd67SSong Liu return -EPERM; 222*d46edd67SSong Liu 223*d46edd67SSong Liu mutex_lock(&bpf_stats_enabled_mutex); 224*d46edd67SSong Liu val = saved_val; 225*d46edd67SSong Liu ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 226*d46edd67SSong Liu if (write && !ret && val != saved_val) { 227*d46edd67SSong Liu if (val) 228*d46edd67SSong Liu static_key_slow_inc(key); 229*d46edd67SSong Liu else 230*d46edd67SSong Liu static_key_slow_dec(key); 231*d46edd67SSong Liu saved_val = val; 232*d46edd67SSong Liu } 233*d46edd67SSong Liu mutex_unlock(&bpf_stats_enabled_mutex); 234*d46edd67SSong Liu return ret; 235*d46edd67SSong Liu } 236*d46edd67SSong Liu #endif 237*d46edd67SSong Liu 238f461d2dcSChristoph Hellwig /* 239f461d2dcSChristoph Hellwig * /proc/sys support 240f461d2dcSChristoph Hellwig */ 241f461d2dcSChristoph Hellwig 242f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL 243f461d2dcSChristoph Hellwig 244f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write, 24532927393SChristoph Hellwig char *buffer, size_t *lenp, loff_t *ppos) 246f461d2dcSChristoph Hellwig { 247f461d2dcSChristoph Hellwig size_t len; 24832927393SChristoph Hellwig char c, *p; 249f461d2dcSChristoph Hellwig 250f461d2dcSChristoph Hellwig if (!data || !maxlen || !*lenp) { 251f461d2dcSChristoph Hellwig *lenp = 0; 252f461d2dcSChristoph Hellwig return 0; 253f461d2dcSChristoph Hellwig } 254f461d2dcSChristoph Hellwig 255f461d2dcSChristoph Hellwig if (write) { 256f461d2dcSChristoph Hellwig if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { 257f461d2dcSChristoph Hellwig /* Only continue writes not past the end of buffer. */ 258f461d2dcSChristoph Hellwig len = strlen(data); 259f461d2dcSChristoph Hellwig if (len > maxlen - 1) 260f461d2dcSChristoph Hellwig len = maxlen - 1; 261f461d2dcSChristoph Hellwig 262f461d2dcSChristoph Hellwig if (*ppos > len) 263f461d2dcSChristoph Hellwig return 0; 264f461d2dcSChristoph Hellwig len = *ppos; 265f461d2dcSChristoph Hellwig } else { 266f461d2dcSChristoph Hellwig /* Start writing from beginning of buffer. */ 267f461d2dcSChristoph Hellwig len = 0; 268f461d2dcSChristoph Hellwig } 269f461d2dcSChristoph Hellwig 270f461d2dcSChristoph Hellwig *ppos += *lenp; 271f461d2dcSChristoph Hellwig p = buffer; 272f461d2dcSChristoph Hellwig while ((p - buffer) < *lenp && len < maxlen - 1) { 27332927393SChristoph Hellwig c = *(p++); 274f461d2dcSChristoph Hellwig if (c == 0 || c == '\n') 275f461d2dcSChristoph Hellwig break; 276f461d2dcSChristoph Hellwig data[len++] = c; 277f461d2dcSChristoph Hellwig } 278f461d2dcSChristoph Hellwig data[len] = 0; 279f461d2dcSChristoph Hellwig } else { 280f461d2dcSChristoph Hellwig len = strlen(data); 281f461d2dcSChristoph Hellwig if (len > maxlen) 282f461d2dcSChristoph Hellwig len = maxlen; 283f461d2dcSChristoph Hellwig 284f461d2dcSChristoph Hellwig if (*ppos > len) { 285f461d2dcSChristoph Hellwig *lenp = 0; 286f461d2dcSChristoph Hellwig return 0; 287f461d2dcSChristoph Hellwig } 288f461d2dcSChristoph Hellwig 289f461d2dcSChristoph Hellwig data += *ppos; 290f461d2dcSChristoph Hellwig len -= *ppos; 291f461d2dcSChristoph Hellwig 292f461d2dcSChristoph Hellwig if (len > *lenp) 293f461d2dcSChristoph Hellwig len = *lenp; 294f461d2dcSChristoph Hellwig if (len) 29532927393SChristoph Hellwig memcpy(buffer, data, len); 296f461d2dcSChristoph Hellwig if (len < *lenp) { 29732927393SChristoph Hellwig buffer[len] = '\n'; 298f461d2dcSChristoph Hellwig len++; 299f461d2dcSChristoph Hellwig } 300f461d2dcSChristoph Hellwig *lenp = len; 301f461d2dcSChristoph Hellwig *ppos += len; 302f461d2dcSChristoph Hellwig } 303f461d2dcSChristoph Hellwig return 0; 304f461d2dcSChristoph Hellwig } 305f461d2dcSChristoph Hellwig 306f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table) 307f461d2dcSChristoph Hellwig { 308f461d2dcSChristoph Hellwig pr_warn_once("%s wrote to %s when file position was not 0!\n" 309f461d2dcSChristoph Hellwig "This will not be supported in the future. To silence this\n" 310f461d2dcSChristoph Hellwig "warning, set kernel.sysctl_writes_strict = -1\n", 311f461d2dcSChristoph Hellwig current->comm, table->procname); 312f461d2dcSChristoph Hellwig } 313f461d2dcSChristoph Hellwig 314f461d2dcSChristoph Hellwig /** 315f461d2dcSChristoph Hellwig * proc_first_pos_non_zero_ignore - check if first position is allowed 316f461d2dcSChristoph Hellwig * @ppos: file position 317f461d2dcSChristoph Hellwig * @table: the sysctl table 318f461d2dcSChristoph Hellwig * 319f461d2dcSChristoph Hellwig * Returns true if the first position is non-zero and the sysctl_writes_strict 320f461d2dcSChristoph Hellwig * mode indicates this is not allowed for numeric input types. String proc 321f461d2dcSChristoph Hellwig * handlers can ignore the return value. 322f461d2dcSChristoph Hellwig */ 323f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos, 324f461d2dcSChristoph Hellwig struct ctl_table *table) 325f461d2dcSChristoph Hellwig { 326f461d2dcSChristoph Hellwig if (!*ppos) 327f461d2dcSChristoph Hellwig return false; 328f461d2dcSChristoph Hellwig 329f461d2dcSChristoph Hellwig switch (sysctl_writes_strict) { 330f461d2dcSChristoph Hellwig case SYSCTL_WRITES_STRICT: 331f461d2dcSChristoph Hellwig return true; 332f461d2dcSChristoph Hellwig case SYSCTL_WRITES_WARN: 333f461d2dcSChristoph Hellwig warn_sysctl_write(table); 334f461d2dcSChristoph Hellwig return false; 335f461d2dcSChristoph Hellwig default: 336f461d2dcSChristoph Hellwig return false; 337f461d2dcSChristoph Hellwig } 338f461d2dcSChristoph Hellwig } 339f461d2dcSChristoph Hellwig 340f461d2dcSChristoph Hellwig /** 341f461d2dcSChristoph Hellwig * proc_dostring - read a string sysctl 342f461d2dcSChristoph Hellwig * @table: the sysctl table 343f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 344f461d2dcSChristoph Hellwig * @buffer: the user buffer 345f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 346f461d2dcSChristoph Hellwig * @ppos: file position 347f461d2dcSChristoph Hellwig * 348f461d2dcSChristoph Hellwig * Reads/writes a string from/to the user buffer. If the kernel 349f461d2dcSChristoph Hellwig * buffer provided is not large enough to hold the string, the 350f461d2dcSChristoph Hellwig * string is truncated. The copied string is %NULL-terminated. 351f461d2dcSChristoph Hellwig * If the string is being read by the user process, it is copied 352f461d2dcSChristoph Hellwig * and a newline '\n' is added. It is truncated if the buffer is 353f461d2dcSChristoph Hellwig * not large enough. 354f461d2dcSChristoph Hellwig * 355f461d2dcSChristoph Hellwig * Returns 0 on success. 356f461d2dcSChristoph Hellwig */ 357f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 35832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 359f461d2dcSChristoph Hellwig { 360f461d2dcSChristoph Hellwig if (write) 361f461d2dcSChristoph Hellwig proc_first_pos_non_zero_ignore(ppos, table); 362f461d2dcSChristoph Hellwig 36332927393SChristoph Hellwig return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, 36432927393SChristoph Hellwig ppos); 365f461d2dcSChristoph Hellwig } 366f461d2dcSChristoph Hellwig 367f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf) 368f461d2dcSChristoph Hellwig { 369f461d2dcSChristoph Hellwig size_t ret; 370f461d2dcSChristoph Hellwig char *tmp = skip_spaces(*buf); 371f461d2dcSChristoph Hellwig ret = tmp - *buf; 372f461d2dcSChristoph Hellwig *buf = tmp; 373f461d2dcSChristoph Hellwig return ret; 374f461d2dcSChristoph Hellwig } 375f461d2dcSChristoph Hellwig 376f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v) 377f461d2dcSChristoph Hellwig { 378f461d2dcSChristoph Hellwig while (*size) { 379f461d2dcSChristoph Hellwig if (**buf != v) 380f461d2dcSChristoph Hellwig break; 381f461d2dcSChristoph Hellwig (*size)--; 382f461d2dcSChristoph Hellwig (*buf)++; 383f461d2dcSChristoph Hellwig } 384f461d2dcSChristoph Hellwig } 385f461d2dcSChristoph Hellwig 386f461d2dcSChristoph Hellwig /** 387f461d2dcSChristoph Hellwig * strtoul_lenient - parse an ASCII formatted integer from a buffer and only 388f461d2dcSChristoph Hellwig * fail on overflow 389f461d2dcSChristoph Hellwig * 390f461d2dcSChristoph Hellwig * @cp: kernel buffer containing the string to parse 391f461d2dcSChristoph Hellwig * @endp: pointer to store the trailing characters 392f461d2dcSChristoph Hellwig * @base: the base to use 393f461d2dcSChristoph Hellwig * @res: where the parsed integer will be stored 394f461d2dcSChristoph Hellwig * 395f461d2dcSChristoph Hellwig * In case of success 0 is returned and @res will contain the parsed integer, 396f461d2dcSChristoph Hellwig * @endp will hold any trailing characters. 397f461d2dcSChristoph Hellwig * This function will fail the parse on overflow. If there wasn't an overflow 398f461d2dcSChristoph Hellwig * the function will defer the decision what characters count as invalid to the 399f461d2dcSChristoph Hellwig * caller. 400f461d2dcSChristoph Hellwig */ 401f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base, 402f461d2dcSChristoph Hellwig unsigned long *res) 403f461d2dcSChristoph Hellwig { 404f461d2dcSChristoph Hellwig unsigned long long result; 405f461d2dcSChristoph Hellwig unsigned int rv; 406f461d2dcSChristoph Hellwig 407f461d2dcSChristoph Hellwig cp = _parse_integer_fixup_radix(cp, &base); 408f461d2dcSChristoph Hellwig rv = _parse_integer(cp, base, &result); 409f461d2dcSChristoph Hellwig if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) 410f461d2dcSChristoph Hellwig return -ERANGE; 411f461d2dcSChristoph Hellwig 412f461d2dcSChristoph Hellwig cp += rv; 413f461d2dcSChristoph Hellwig 414f461d2dcSChristoph Hellwig if (endp) 415f461d2dcSChristoph Hellwig *endp = (char *)cp; 416f461d2dcSChristoph Hellwig 417f461d2dcSChristoph Hellwig *res = (unsigned long)result; 418f461d2dcSChristoph Hellwig return 0; 419f461d2dcSChristoph Hellwig } 420f461d2dcSChristoph Hellwig 421f461d2dcSChristoph Hellwig #define TMPBUFLEN 22 422f461d2dcSChristoph Hellwig /** 423f461d2dcSChristoph Hellwig * proc_get_long - reads an ASCII formatted integer from a user buffer 424f461d2dcSChristoph Hellwig * 425f461d2dcSChristoph Hellwig * @buf: a kernel buffer 426f461d2dcSChristoph Hellwig * @size: size of the kernel buffer 427f461d2dcSChristoph Hellwig * @val: this is where the number will be stored 428f461d2dcSChristoph Hellwig * @neg: set to %TRUE if number is negative 429f461d2dcSChristoph Hellwig * @perm_tr: a vector which contains the allowed trailers 430f461d2dcSChristoph Hellwig * @perm_tr_len: size of the perm_tr vector 431f461d2dcSChristoph Hellwig * @tr: pointer to store the trailer character 432f461d2dcSChristoph Hellwig * 433f461d2dcSChristoph Hellwig * In case of success %0 is returned and @buf and @size are updated with 434f461d2dcSChristoph Hellwig * the amount of bytes read. If @tr is non-NULL and a trailing 435f461d2dcSChristoph Hellwig * character exists (size is non-zero after returning from this 436f461d2dcSChristoph Hellwig * function), @tr is updated with the trailing character. 437f461d2dcSChristoph Hellwig */ 438f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size, 439f461d2dcSChristoph Hellwig unsigned long *val, bool *neg, 440f461d2dcSChristoph Hellwig const char *perm_tr, unsigned perm_tr_len, char *tr) 441f461d2dcSChristoph Hellwig { 442f461d2dcSChristoph Hellwig int len; 443f461d2dcSChristoph Hellwig char *p, tmp[TMPBUFLEN]; 444f461d2dcSChristoph Hellwig 445f461d2dcSChristoph Hellwig if (!*size) 446f461d2dcSChristoph Hellwig return -EINVAL; 447f461d2dcSChristoph Hellwig 448f461d2dcSChristoph Hellwig len = *size; 449f461d2dcSChristoph Hellwig if (len > TMPBUFLEN - 1) 450f461d2dcSChristoph Hellwig len = TMPBUFLEN - 1; 451f461d2dcSChristoph Hellwig 452f461d2dcSChristoph Hellwig memcpy(tmp, *buf, len); 453f461d2dcSChristoph Hellwig 454f461d2dcSChristoph Hellwig tmp[len] = 0; 455f461d2dcSChristoph Hellwig p = tmp; 456f461d2dcSChristoph Hellwig if (*p == '-' && *size > 1) { 457f461d2dcSChristoph Hellwig *neg = true; 458f461d2dcSChristoph Hellwig p++; 459f461d2dcSChristoph Hellwig } else 460f461d2dcSChristoph Hellwig *neg = false; 461f461d2dcSChristoph Hellwig if (!isdigit(*p)) 462f461d2dcSChristoph Hellwig return -EINVAL; 463f461d2dcSChristoph Hellwig 464f461d2dcSChristoph Hellwig if (strtoul_lenient(p, &p, 0, val)) 465f461d2dcSChristoph Hellwig return -EINVAL; 466f461d2dcSChristoph Hellwig 467f461d2dcSChristoph Hellwig len = p - tmp; 468f461d2dcSChristoph Hellwig 469f461d2dcSChristoph Hellwig /* We don't know if the next char is whitespace thus we may accept 470f461d2dcSChristoph Hellwig * invalid integers (e.g. 1234...a) or two integers instead of one 471f461d2dcSChristoph Hellwig * (e.g. 123...1). So lets not allow such large numbers. */ 472f461d2dcSChristoph Hellwig if (len == TMPBUFLEN - 1) 473f461d2dcSChristoph Hellwig return -EINVAL; 474f461d2dcSChristoph Hellwig 475f461d2dcSChristoph Hellwig if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 476f461d2dcSChristoph Hellwig return -EINVAL; 477f461d2dcSChristoph Hellwig 478f461d2dcSChristoph Hellwig if (tr && (len < *size)) 479f461d2dcSChristoph Hellwig *tr = *p; 480f461d2dcSChristoph Hellwig 481f461d2dcSChristoph Hellwig *buf += len; 482f461d2dcSChristoph Hellwig *size -= len; 483f461d2dcSChristoph Hellwig 484f461d2dcSChristoph Hellwig return 0; 485f461d2dcSChristoph Hellwig } 486f461d2dcSChristoph Hellwig 487f461d2dcSChristoph Hellwig /** 488f461d2dcSChristoph Hellwig * proc_put_long - converts an integer to a decimal ASCII formatted string 489f461d2dcSChristoph Hellwig * 490f461d2dcSChristoph Hellwig * @buf: the user buffer 491f461d2dcSChristoph Hellwig * @size: the size of the user buffer 492f461d2dcSChristoph Hellwig * @val: the integer to be converted 493f461d2dcSChristoph Hellwig * @neg: sign of the number, %TRUE for negative 494f461d2dcSChristoph Hellwig * 49532927393SChristoph Hellwig * In case of success @buf and @size are updated with the amount of bytes 49632927393SChristoph Hellwig * written. 497f461d2dcSChristoph Hellwig */ 49832927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg) 499f461d2dcSChristoph Hellwig { 500f461d2dcSChristoph Hellwig int len; 501f461d2dcSChristoph Hellwig char tmp[TMPBUFLEN], *p = tmp; 502f461d2dcSChristoph Hellwig 503f461d2dcSChristoph Hellwig sprintf(p, "%s%lu", neg ? "-" : "", val); 504f461d2dcSChristoph Hellwig len = strlen(tmp); 505f461d2dcSChristoph Hellwig if (len > *size) 506f461d2dcSChristoph Hellwig len = *size; 50732927393SChristoph Hellwig memcpy(*buf, tmp, len); 508f461d2dcSChristoph Hellwig *size -= len; 509f461d2dcSChristoph Hellwig *buf += len; 510f461d2dcSChristoph Hellwig } 511f461d2dcSChristoph Hellwig #undef TMPBUFLEN 512f461d2dcSChristoph Hellwig 51332927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c) 514f461d2dcSChristoph Hellwig { 515f461d2dcSChristoph Hellwig if (*size) { 51632927393SChristoph Hellwig char **buffer = (char **)buf; 51732927393SChristoph Hellwig **buffer = c; 51832927393SChristoph Hellwig 51932927393SChristoph Hellwig (*size)--; 52032927393SChristoph Hellwig (*buffer)++; 521f461d2dcSChristoph Hellwig *buf = *buffer; 522f461d2dcSChristoph Hellwig } 523f461d2dcSChristoph Hellwig } 524f461d2dcSChristoph Hellwig 525f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 526f461d2dcSChristoph Hellwig int *valp, 527f461d2dcSChristoph Hellwig int write, void *data) 528f461d2dcSChristoph Hellwig { 529f461d2dcSChristoph Hellwig if (write) { 530f461d2dcSChristoph Hellwig if (*negp) { 531f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX + 1) 532f461d2dcSChristoph Hellwig return -EINVAL; 533f461d2dcSChristoph Hellwig *valp = -*lvalp; 534f461d2dcSChristoph Hellwig } else { 535f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX) 536f461d2dcSChristoph Hellwig return -EINVAL; 537f461d2dcSChristoph Hellwig *valp = *lvalp; 538f461d2dcSChristoph Hellwig } 539f461d2dcSChristoph Hellwig } else { 540f461d2dcSChristoph Hellwig int val = *valp; 541f461d2dcSChristoph Hellwig if (val < 0) { 542f461d2dcSChristoph Hellwig *negp = true; 543f461d2dcSChristoph Hellwig *lvalp = -(unsigned long)val; 544f461d2dcSChristoph Hellwig } else { 545f461d2dcSChristoph Hellwig *negp = false; 546f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 547f461d2dcSChristoph Hellwig } 548f461d2dcSChristoph Hellwig } 549f461d2dcSChristoph Hellwig return 0; 550f461d2dcSChristoph Hellwig } 551f461d2dcSChristoph Hellwig 552f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp, 553f461d2dcSChristoph Hellwig unsigned int *valp, 554f461d2dcSChristoph Hellwig int write, void *data) 555f461d2dcSChristoph Hellwig { 556f461d2dcSChristoph Hellwig if (write) { 557f461d2dcSChristoph Hellwig if (*lvalp > UINT_MAX) 558f461d2dcSChristoph Hellwig return -EINVAL; 559f461d2dcSChristoph Hellwig *valp = *lvalp; 560f461d2dcSChristoph Hellwig } else { 561f461d2dcSChristoph Hellwig unsigned int val = *valp; 562f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 563f461d2dcSChristoph Hellwig } 564f461d2dcSChristoph Hellwig return 0; 565f461d2dcSChristoph Hellwig } 566f461d2dcSChristoph Hellwig 567f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 568f461d2dcSChristoph Hellwig 569f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 57032927393SChristoph Hellwig int write, void *buffer, 571f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 572f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 573f461d2dcSChristoph Hellwig int write, void *data), 574f461d2dcSChristoph Hellwig void *data) 575f461d2dcSChristoph Hellwig { 576f461d2dcSChristoph Hellwig int *i, vleft, first = 1, err = 0; 577f461d2dcSChristoph Hellwig size_t left; 57832927393SChristoph Hellwig char *p; 579f461d2dcSChristoph Hellwig 580f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 581f461d2dcSChristoph Hellwig *lenp = 0; 582f461d2dcSChristoph Hellwig return 0; 583f461d2dcSChristoph Hellwig } 584f461d2dcSChristoph Hellwig 585f461d2dcSChristoph Hellwig i = (int *) tbl_data; 586f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 587f461d2dcSChristoph Hellwig left = *lenp; 588f461d2dcSChristoph Hellwig 589f461d2dcSChristoph Hellwig if (!conv) 590f461d2dcSChristoph Hellwig conv = do_proc_dointvec_conv; 591f461d2dcSChristoph Hellwig 592f461d2dcSChristoph Hellwig if (write) { 593f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 594f461d2dcSChristoph Hellwig goto out; 595f461d2dcSChristoph Hellwig 596f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 597f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 59832927393SChristoph Hellwig p = buffer; 599f461d2dcSChristoph Hellwig } 600f461d2dcSChristoph Hellwig 601f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first=0) { 602f461d2dcSChristoph Hellwig unsigned long lval; 603f461d2dcSChristoph Hellwig bool neg; 604f461d2dcSChristoph Hellwig 605f461d2dcSChristoph Hellwig if (write) { 606f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 607f461d2dcSChristoph Hellwig 608f461d2dcSChristoph Hellwig if (!left) 609f461d2dcSChristoph Hellwig break; 610f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 611f461d2dcSChristoph Hellwig proc_wspace_sep, 612f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 613f461d2dcSChristoph Hellwig if (err) 614f461d2dcSChristoph Hellwig break; 615f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 1, data)) { 616f461d2dcSChristoph Hellwig err = -EINVAL; 617f461d2dcSChristoph Hellwig break; 618f461d2dcSChristoph Hellwig } 619f461d2dcSChristoph Hellwig } else { 620f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 0, data)) { 621f461d2dcSChristoph Hellwig err = -EINVAL; 622f461d2dcSChristoph Hellwig break; 623f461d2dcSChristoph Hellwig } 624f461d2dcSChristoph Hellwig if (!first) 62532927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 62632927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, neg); 627f461d2dcSChristoph Hellwig } 628f461d2dcSChristoph Hellwig } 629f461d2dcSChristoph Hellwig 630f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 63132927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 632f461d2dcSChristoph Hellwig if (write && !err && left) 633f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 63432927393SChristoph Hellwig if (write && first) 635f461d2dcSChristoph Hellwig return err ? : -EINVAL; 636f461d2dcSChristoph Hellwig *lenp -= left; 637f461d2dcSChristoph Hellwig out: 638f461d2dcSChristoph Hellwig *ppos += *lenp; 639f461d2dcSChristoph Hellwig return err; 640f461d2dcSChristoph Hellwig } 641f461d2dcSChristoph Hellwig 642f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write, 64332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 644f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 645f461d2dcSChristoph Hellwig int write, void *data), 646f461d2dcSChristoph Hellwig void *data) 647f461d2dcSChristoph Hellwig { 648f461d2dcSChristoph Hellwig return __do_proc_dointvec(table->data, table, write, 649f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 650f461d2dcSChristoph Hellwig } 651f461d2dcSChristoph Hellwig 652f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data, 653f461d2dcSChristoph Hellwig struct ctl_table *table, 65432927393SChristoph Hellwig void *buffer, 655f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 656f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 657f461d2dcSChristoph Hellwig unsigned int *valp, 658f461d2dcSChristoph Hellwig int write, void *data), 659f461d2dcSChristoph Hellwig void *data) 660f461d2dcSChristoph Hellwig { 661f461d2dcSChristoph Hellwig unsigned long lval; 662f461d2dcSChristoph Hellwig int err = 0; 663f461d2dcSChristoph Hellwig size_t left; 664f461d2dcSChristoph Hellwig bool neg; 66532927393SChristoph Hellwig char *p = buffer; 666f461d2dcSChristoph Hellwig 667f461d2dcSChristoph Hellwig left = *lenp; 668f461d2dcSChristoph Hellwig 669f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 670f461d2dcSChristoph Hellwig goto bail_early; 671f461d2dcSChristoph Hellwig 672f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 673f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 674f461d2dcSChristoph Hellwig 675f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 676f461d2dcSChristoph Hellwig if (!left) { 677f461d2dcSChristoph Hellwig err = -EINVAL; 678f461d2dcSChristoph Hellwig goto out_free; 679f461d2dcSChristoph Hellwig } 680f461d2dcSChristoph Hellwig 681f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 682f461d2dcSChristoph Hellwig proc_wspace_sep, 683f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 684f461d2dcSChristoph Hellwig if (err || neg) { 685f461d2dcSChristoph Hellwig err = -EINVAL; 686f461d2dcSChristoph Hellwig goto out_free; 687f461d2dcSChristoph Hellwig } 688f461d2dcSChristoph Hellwig 689f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 1, data)) { 690f461d2dcSChristoph Hellwig err = -EINVAL; 691f461d2dcSChristoph Hellwig goto out_free; 692f461d2dcSChristoph Hellwig } 693f461d2dcSChristoph Hellwig 694f461d2dcSChristoph Hellwig if (!err && left) 695f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 696f461d2dcSChristoph Hellwig 697f461d2dcSChristoph Hellwig out_free: 698f461d2dcSChristoph Hellwig if (err) 699f461d2dcSChristoph Hellwig return -EINVAL; 700f461d2dcSChristoph Hellwig 701f461d2dcSChristoph Hellwig return 0; 702f461d2dcSChristoph Hellwig 703f461d2dcSChristoph Hellwig /* This is in keeping with old __do_proc_dointvec() */ 704f461d2dcSChristoph Hellwig bail_early: 705f461d2dcSChristoph Hellwig *ppos += *lenp; 706f461d2dcSChristoph Hellwig return err; 707f461d2dcSChristoph Hellwig } 708f461d2dcSChristoph Hellwig 70932927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer, 710f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 711f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 712f461d2dcSChristoph Hellwig unsigned int *valp, 713f461d2dcSChristoph Hellwig int write, void *data), 714f461d2dcSChristoph Hellwig void *data) 715f461d2dcSChristoph Hellwig { 716f461d2dcSChristoph Hellwig unsigned long lval; 717f461d2dcSChristoph Hellwig int err = 0; 718f461d2dcSChristoph Hellwig size_t left; 719f461d2dcSChristoph Hellwig 720f461d2dcSChristoph Hellwig left = *lenp; 721f461d2dcSChristoph Hellwig 722f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 0, data)) { 723f461d2dcSChristoph Hellwig err = -EINVAL; 724f461d2dcSChristoph Hellwig goto out; 725f461d2dcSChristoph Hellwig } 726f461d2dcSChristoph Hellwig 72732927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, false); 72832927393SChristoph Hellwig if (!left) 729f461d2dcSChristoph Hellwig goto out; 730f461d2dcSChristoph Hellwig 73132927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 732f461d2dcSChristoph Hellwig 733f461d2dcSChristoph Hellwig out: 734f461d2dcSChristoph Hellwig *lenp -= left; 735f461d2dcSChristoph Hellwig *ppos += *lenp; 736f461d2dcSChristoph Hellwig 737f461d2dcSChristoph Hellwig return err; 738f461d2dcSChristoph Hellwig } 739f461d2dcSChristoph Hellwig 740f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, 74132927393SChristoph Hellwig int write, void *buffer, 742f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 743f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 744f461d2dcSChristoph Hellwig unsigned int *valp, 745f461d2dcSChristoph Hellwig int write, void *data), 746f461d2dcSChristoph Hellwig void *data) 747f461d2dcSChristoph Hellwig { 748f461d2dcSChristoph Hellwig unsigned int *i, vleft; 749f461d2dcSChristoph Hellwig 750f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 751f461d2dcSChristoph Hellwig *lenp = 0; 752f461d2dcSChristoph Hellwig return 0; 753f461d2dcSChristoph Hellwig } 754f461d2dcSChristoph Hellwig 755f461d2dcSChristoph Hellwig i = (unsigned int *) tbl_data; 756f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 757f461d2dcSChristoph Hellwig 758f461d2dcSChristoph Hellwig /* 759f461d2dcSChristoph Hellwig * Arrays are not supported, keep this simple. *Do not* add 760f461d2dcSChristoph Hellwig * support for them. 761f461d2dcSChristoph Hellwig */ 762f461d2dcSChristoph Hellwig if (vleft != 1) { 763f461d2dcSChristoph Hellwig *lenp = 0; 764f461d2dcSChristoph Hellwig return -EINVAL; 765f461d2dcSChristoph Hellwig } 766f461d2dcSChristoph Hellwig 767f461d2dcSChristoph Hellwig if (!conv) 768f461d2dcSChristoph Hellwig conv = do_proc_douintvec_conv; 769f461d2dcSChristoph Hellwig 770f461d2dcSChristoph Hellwig if (write) 771f461d2dcSChristoph Hellwig return do_proc_douintvec_w(i, table, buffer, lenp, ppos, 772f461d2dcSChristoph Hellwig conv, data); 773f461d2dcSChristoph Hellwig return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); 774f461d2dcSChristoph Hellwig } 775f461d2dcSChristoph Hellwig 776f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write, 77732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 778f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 779f461d2dcSChristoph Hellwig unsigned int *valp, 780f461d2dcSChristoph Hellwig int write, void *data), 781f461d2dcSChristoph Hellwig void *data) 782f461d2dcSChristoph Hellwig { 783f461d2dcSChristoph Hellwig return __do_proc_douintvec(table->data, table, write, 784f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 785f461d2dcSChristoph Hellwig } 786f461d2dcSChristoph Hellwig 787f461d2dcSChristoph Hellwig /** 788f461d2dcSChristoph Hellwig * proc_dointvec - read a vector of integers 789f461d2dcSChristoph Hellwig * @table: the sysctl table 790f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 791f461d2dcSChristoph Hellwig * @buffer: the user buffer 792f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 793f461d2dcSChristoph Hellwig * @ppos: file position 794f461d2dcSChristoph Hellwig * 795f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 796f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 797f461d2dcSChristoph Hellwig * 798f461d2dcSChristoph Hellwig * Returns 0 on success. 799f461d2dcSChristoph Hellwig */ 80032927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer, 80132927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 802f461d2dcSChristoph Hellwig { 803f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 804f461d2dcSChristoph Hellwig } 805f461d2dcSChristoph Hellwig 806f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION 807f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, 80832927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos) 809f461d2dcSChristoph Hellwig { 810f461d2dcSChristoph Hellwig int ret, old; 811f461d2dcSChristoph Hellwig 812f461d2dcSChristoph Hellwig if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) 813f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 814f461d2dcSChristoph Hellwig 815f461d2dcSChristoph Hellwig old = *(int *)table->data; 816f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 817f461d2dcSChristoph Hellwig if (ret) 818f461d2dcSChristoph Hellwig return ret; 819f461d2dcSChristoph Hellwig if (old != *(int *)table->data) 820f461d2dcSChristoph Hellwig pr_warn_once("sysctl attribute %s changed by %s[%d]\n", 821f461d2dcSChristoph Hellwig table->procname, current->comm, 822f461d2dcSChristoph Hellwig task_pid_nr(current)); 823f461d2dcSChristoph Hellwig return ret; 824f461d2dcSChristoph Hellwig } 825f461d2dcSChristoph Hellwig #endif 826f461d2dcSChristoph Hellwig 827f461d2dcSChristoph Hellwig /** 828f461d2dcSChristoph Hellwig * proc_douintvec - read a vector of unsigned integers 829f461d2dcSChristoph Hellwig * @table: the sysctl table 830f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 831f461d2dcSChristoph Hellwig * @buffer: the user buffer 832f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 833f461d2dcSChristoph Hellwig * @ppos: file position 834f461d2dcSChristoph Hellwig * 835f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 836f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 837f461d2dcSChristoph Hellwig * 838f461d2dcSChristoph Hellwig * Returns 0 on success. 839f461d2dcSChristoph Hellwig */ 84032927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer, 84132927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 842f461d2dcSChristoph Hellwig { 843f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 844f461d2dcSChristoph Hellwig do_proc_douintvec_conv, NULL); 845f461d2dcSChristoph Hellwig } 846f461d2dcSChristoph Hellwig 847f461d2dcSChristoph Hellwig /* 848f461d2dcSChristoph Hellwig * Taint values can only be increased 849f461d2dcSChristoph Hellwig * This means we can safely use a temporary. 850f461d2dcSChristoph Hellwig */ 851f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write, 85232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 853f461d2dcSChristoph Hellwig { 854f461d2dcSChristoph Hellwig struct ctl_table t; 855f461d2dcSChristoph Hellwig unsigned long tmptaint = get_taint(); 856f461d2dcSChristoph Hellwig int err; 857f461d2dcSChristoph Hellwig 858f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 859f461d2dcSChristoph Hellwig return -EPERM; 860f461d2dcSChristoph Hellwig 861f461d2dcSChristoph Hellwig t = *table; 862f461d2dcSChristoph Hellwig t.data = &tmptaint; 863f461d2dcSChristoph Hellwig err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 864f461d2dcSChristoph Hellwig if (err < 0) 865f461d2dcSChristoph Hellwig return err; 866f461d2dcSChristoph Hellwig 867f461d2dcSChristoph Hellwig if (write) { 868f461d2dcSChristoph Hellwig /* 869f461d2dcSChristoph Hellwig * Poor man's atomic or. Not worth adding a primitive 870f461d2dcSChristoph Hellwig * to everyone's atomic.h for this 871f461d2dcSChristoph Hellwig */ 872f461d2dcSChristoph Hellwig int i; 873f461d2dcSChristoph Hellwig for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 874f461d2dcSChristoph Hellwig if ((tmptaint >> i) & 1) 875f461d2dcSChristoph Hellwig add_taint(i, LOCKDEP_STILL_OK); 876f461d2dcSChristoph Hellwig } 877f461d2dcSChristoph Hellwig } 878f461d2dcSChristoph Hellwig 879f461d2dcSChristoph Hellwig return err; 880f461d2dcSChristoph Hellwig } 881f461d2dcSChristoph Hellwig 882f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK 883f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 88432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 885f461d2dcSChristoph Hellwig { 886f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 887f461d2dcSChristoph Hellwig return -EPERM; 888f461d2dcSChristoph Hellwig 889f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 890f461d2dcSChristoph Hellwig } 891f461d2dcSChristoph Hellwig #endif 892f461d2dcSChristoph Hellwig 893f461d2dcSChristoph Hellwig /** 894f461d2dcSChristoph Hellwig * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure 895f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 896f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 897f461d2dcSChristoph Hellwig * 898f461d2dcSChristoph Hellwig * The do_proc_dointvec_minmax_conv_param structure provides the 899f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 900f461d2dcSChristoph Hellwig * parameters that use the proc_dointvec_minmax() handler. 901f461d2dcSChristoph Hellwig */ 902f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param { 903f461d2dcSChristoph Hellwig int *min; 904f461d2dcSChristoph Hellwig int *max; 905f461d2dcSChristoph Hellwig }; 906f461d2dcSChristoph Hellwig 907f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 908f461d2dcSChristoph Hellwig int *valp, 909f461d2dcSChristoph Hellwig int write, void *data) 910f461d2dcSChristoph Hellwig { 911f461d2dcSChristoph Hellwig int tmp, ret; 912f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param *param = data; 913f461d2dcSChristoph Hellwig /* 914f461d2dcSChristoph Hellwig * If writing, first do so via a temporary local int so we can 915f461d2dcSChristoph Hellwig * bounds-check it before touching *valp. 916f461d2dcSChristoph Hellwig */ 917f461d2dcSChristoph Hellwig int *ip = write ? &tmp : valp; 918f461d2dcSChristoph Hellwig 919f461d2dcSChristoph Hellwig ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); 920f461d2dcSChristoph Hellwig if (ret) 921f461d2dcSChristoph Hellwig return ret; 922f461d2dcSChristoph Hellwig 923f461d2dcSChristoph Hellwig if (write) { 924f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 925f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 926f461d2dcSChristoph Hellwig return -EINVAL; 927f461d2dcSChristoph Hellwig *valp = tmp; 928f461d2dcSChristoph Hellwig } 929f461d2dcSChristoph Hellwig 930f461d2dcSChristoph Hellwig return 0; 931f461d2dcSChristoph Hellwig } 932f461d2dcSChristoph Hellwig 933f461d2dcSChristoph Hellwig /** 934f461d2dcSChristoph Hellwig * proc_dointvec_minmax - read a vector of integers with min/max values 935f461d2dcSChristoph Hellwig * @table: the sysctl table 936f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 937f461d2dcSChristoph Hellwig * @buffer: the user buffer 938f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 939f461d2dcSChristoph Hellwig * @ppos: file position 940f461d2dcSChristoph Hellwig * 941f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 942f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 943f461d2dcSChristoph Hellwig * 944f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 945f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 946f461d2dcSChristoph Hellwig * 947f461d2dcSChristoph Hellwig * Returns 0 on success or -EINVAL on write when the range check fails. 948f461d2dcSChristoph Hellwig */ 949f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 95032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 951f461d2dcSChristoph Hellwig { 952f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param param = { 953f461d2dcSChristoph Hellwig .min = (int *) table->extra1, 954f461d2dcSChristoph Hellwig .max = (int *) table->extra2, 955f461d2dcSChristoph Hellwig }; 956f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 957f461d2dcSChristoph Hellwig do_proc_dointvec_minmax_conv, ¶m); 958f461d2dcSChristoph Hellwig } 959f461d2dcSChristoph Hellwig 960f461d2dcSChristoph Hellwig /** 961f461d2dcSChristoph Hellwig * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure 962f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 963f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 964f461d2dcSChristoph Hellwig * 965f461d2dcSChristoph Hellwig * The do_proc_douintvec_minmax_conv_param structure provides the 966f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 967f461d2dcSChristoph Hellwig * parameters that use the proc_douintvec_minmax() handler. 968f461d2dcSChristoph Hellwig */ 969f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param { 970f461d2dcSChristoph Hellwig unsigned int *min; 971f461d2dcSChristoph Hellwig unsigned int *max; 972f461d2dcSChristoph Hellwig }; 973f461d2dcSChristoph Hellwig 974f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, 975f461d2dcSChristoph Hellwig unsigned int *valp, 976f461d2dcSChristoph Hellwig int write, void *data) 977f461d2dcSChristoph Hellwig { 978f461d2dcSChristoph Hellwig int ret; 979f461d2dcSChristoph Hellwig unsigned int tmp; 980f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param *param = data; 981f461d2dcSChristoph Hellwig /* write via temporary local uint for bounds-checking */ 982f461d2dcSChristoph Hellwig unsigned int *up = write ? &tmp : valp; 983f461d2dcSChristoph Hellwig 984f461d2dcSChristoph Hellwig ret = do_proc_douintvec_conv(lvalp, up, write, data); 985f461d2dcSChristoph Hellwig if (ret) 986f461d2dcSChristoph Hellwig return ret; 987f461d2dcSChristoph Hellwig 988f461d2dcSChristoph Hellwig if (write) { 989f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 990f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 991f461d2dcSChristoph Hellwig return -ERANGE; 992f461d2dcSChristoph Hellwig 993f461d2dcSChristoph Hellwig *valp = tmp; 994f461d2dcSChristoph Hellwig } 995f461d2dcSChristoph Hellwig 996f461d2dcSChristoph Hellwig return 0; 997f461d2dcSChristoph Hellwig } 998f461d2dcSChristoph Hellwig 999f461d2dcSChristoph Hellwig /** 1000f461d2dcSChristoph Hellwig * proc_douintvec_minmax - read a vector of unsigned ints with min/max values 1001f461d2dcSChristoph Hellwig * @table: the sysctl table 1002f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1003f461d2dcSChristoph Hellwig * @buffer: the user buffer 1004f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1005f461d2dcSChristoph Hellwig * @ppos: file position 1006f461d2dcSChristoph Hellwig * 1007f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 1008f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. Negative 1009f461d2dcSChristoph Hellwig * strings are not allowed. 1010f461d2dcSChristoph Hellwig * 1011f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1012f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). There is a final sanity 1013f461d2dcSChristoph Hellwig * check for UINT_MAX to avoid having to support wrap around uses from 1014f461d2dcSChristoph Hellwig * userspace. 1015f461d2dcSChristoph Hellwig * 1016f461d2dcSChristoph Hellwig * Returns 0 on success or -ERANGE on write when the range check fails. 1017f461d2dcSChristoph Hellwig */ 1018f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 101932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1020f461d2dcSChristoph Hellwig { 1021f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param param = { 1022f461d2dcSChristoph Hellwig .min = (unsigned int *) table->extra1, 1023f461d2dcSChristoph Hellwig .max = (unsigned int *) table->extra2, 1024f461d2dcSChristoph Hellwig }; 1025f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1026f461d2dcSChristoph Hellwig do_proc_douintvec_minmax_conv, ¶m); 1027f461d2dcSChristoph Hellwig } 1028f461d2dcSChristoph Hellwig 1029f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp, 1030f461d2dcSChristoph Hellwig unsigned int *valp, 1031f461d2dcSChristoph Hellwig int write, void *data) 1032f461d2dcSChristoph Hellwig { 1033f461d2dcSChristoph Hellwig if (write) { 1034f461d2dcSChristoph Hellwig unsigned int val; 1035f461d2dcSChristoph Hellwig 1036f461d2dcSChristoph Hellwig val = round_pipe_size(*lvalp); 1037f461d2dcSChristoph Hellwig if (val == 0) 1038f461d2dcSChristoph Hellwig return -EINVAL; 1039f461d2dcSChristoph Hellwig 1040f461d2dcSChristoph Hellwig *valp = val; 1041f461d2dcSChristoph Hellwig } else { 1042f461d2dcSChristoph Hellwig unsigned int val = *valp; 1043f461d2dcSChristoph Hellwig *lvalp = (unsigned long) val; 1044f461d2dcSChristoph Hellwig } 1045f461d2dcSChristoph Hellwig 1046f461d2dcSChristoph Hellwig return 0; 1047f461d2dcSChristoph Hellwig } 1048f461d2dcSChristoph Hellwig 1049f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write, 105032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1051f461d2dcSChristoph Hellwig { 1052f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1053f461d2dcSChristoph Hellwig do_proc_dopipe_max_size_conv, NULL); 1054f461d2dcSChristoph Hellwig } 1055f461d2dcSChristoph Hellwig 1056f461d2dcSChristoph Hellwig static void validate_coredump_safety(void) 1057f461d2dcSChristoph Hellwig { 1058f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1059f461d2dcSChristoph Hellwig if (suid_dumpable == SUID_DUMP_ROOT && 1060f461d2dcSChristoph Hellwig core_pattern[0] != '/' && core_pattern[0] != '|') { 1061f461d2dcSChristoph Hellwig printk(KERN_WARNING 1062f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n" 1063f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n" 1064f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n" 1065f461d2dcSChristoph Hellwig ); 1066f461d2dcSChristoph Hellwig } 1067f461d2dcSChristoph Hellwig #endif 1068f461d2dcSChristoph Hellwig } 1069f461d2dcSChristoph Hellwig 1070f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 107132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1072f461d2dcSChristoph Hellwig { 1073f461d2dcSChristoph Hellwig int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 1074f461d2dcSChristoph Hellwig if (!error) 1075f461d2dcSChristoph Hellwig validate_coredump_safety(); 1076f461d2dcSChristoph Hellwig return error; 1077f461d2dcSChristoph Hellwig } 1078f461d2dcSChristoph Hellwig 1079f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1080f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write, 108132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1082f461d2dcSChristoph Hellwig { 1083f461d2dcSChristoph Hellwig int error = proc_dostring(table, write, buffer, lenp, ppos); 1084f461d2dcSChristoph Hellwig if (!error) 1085f461d2dcSChristoph Hellwig validate_coredump_safety(); 1086f461d2dcSChristoph Hellwig return error; 1087f461d2dcSChristoph Hellwig } 1088f461d2dcSChristoph Hellwig #endif 1089f461d2dcSChristoph Hellwig 1090f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ 1091f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write, 109232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1093f461d2dcSChristoph Hellwig { 1094f461d2dcSChristoph Hellwig int tmp, ret; 1095f461d2dcSChristoph Hellwig 1096f461d2dcSChristoph Hellwig tmp = sysrq_mask(); 1097f461d2dcSChristoph Hellwig 1098f461d2dcSChristoph Hellwig ret = __do_proc_dointvec(&tmp, table, write, buffer, 1099f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1100f461d2dcSChristoph Hellwig if (ret || !write) 1101f461d2dcSChristoph Hellwig return ret; 1102f461d2dcSChristoph Hellwig 1103f461d2dcSChristoph Hellwig if (write) 1104f461d2dcSChristoph Hellwig sysrq_toggle_support(tmp); 1105f461d2dcSChristoph Hellwig 1106f461d2dcSChristoph Hellwig return 0; 1107f461d2dcSChristoph Hellwig } 1108f461d2dcSChristoph Hellwig #endif 1109f461d2dcSChristoph Hellwig 111032927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, 111132927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos, 111232927393SChristoph Hellwig unsigned long convmul, unsigned long convdiv) 1113f461d2dcSChristoph Hellwig { 1114f461d2dcSChristoph Hellwig unsigned long *i, *min, *max; 1115f461d2dcSChristoph Hellwig int vleft, first = 1, err = 0; 1116f461d2dcSChristoph Hellwig size_t left; 111732927393SChristoph Hellwig char *p; 1118f461d2dcSChristoph Hellwig 1119f461d2dcSChristoph Hellwig if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 1120f461d2dcSChristoph Hellwig *lenp = 0; 1121f461d2dcSChristoph Hellwig return 0; 1122f461d2dcSChristoph Hellwig } 1123f461d2dcSChristoph Hellwig 1124f461d2dcSChristoph Hellwig i = (unsigned long *) data; 1125f461d2dcSChristoph Hellwig min = (unsigned long *) table->extra1; 1126f461d2dcSChristoph Hellwig max = (unsigned long *) table->extra2; 1127f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(unsigned long); 1128f461d2dcSChristoph Hellwig left = *lenp; 1129f461d2dcSChristoph Hellwig 1130f461d2dcSChristoph Hellwig if (write) { 1131f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 1132f461d2dcSChristoph Hellwig goto out; 1133f461d2dcSChristoph Hellwig 1134f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 1135f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 113632927393SChristoph Hellwig p = buffer; 1137f461d2dcSChristoph Hellwig } 1138f461d2dcSChristoph Hellwig 1139f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first = 0) { 1140f461d2dcSChristoph Hellwig unsigned long val; 1141f461d2dcSChristoph Hellwig 1142f461d2dcSChristoph Hellwig if (write) { 1143f461d2dcSChristoph Hellwig bool neg; 1144f461d2dcSChristoph Hellwig 1145f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 1146f461d2dcSChristoph Hellwig if (!left) 1147f461d2dcSChristoph Hellwig break; 1148f461d2dcSChristoph Hellwig 1149f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val, &neg, 1150f461d2dcSChristoph Hellwig proc_wspace_sep, 1151f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 1152f461d2dcSChristoph Hellwig if (err) 1153f461d2dcSChristoph Hellwig break; 1154f461d2dcSChristoph Hellwig if (neg) 1155f461d2dcSChristoph Hellwig continue; 1156f461d2dcSChristoph Hellwig val = convmul * val / convdiv; 1157f461d2dcSChristoph Hellwig if ((min && val < *min) || (max && val > *max)) { 1158f461d2dcSChristoph Hellwig err = -EINVAL; 1159f461d2dcSChristoph Hellwig break; 1160f461d2dcSChristoph Hellwig } 1161f461d2dcSChristoph Hellwig *i = val; 1162f461d2dcSChristoph Hellwig } else { 1163f461d2dcSChristoph Hellwig val = convdiv * (*i) / convmul; 116432927393SChristoph Hellwig if (!first) 116532927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 116632927393SChristoph Hellwig proc_put_long(&buffer, &left, val, false); 1167f461d2dcSChristoph Hellwig } 1168f461d2dcSChristoph Hellwig } 1169f461d2dcSChristoph Hellwig 1170f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 117132927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1172f461d2dcSChristoph Hellwig if (write && !err) 1173f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 117432927393SChristoph Hellwig if (write && first) 1175f461d2dcSChristoph Hellwig return err ? : -EINVAL; 1176f461d2dcSChristoph Hellwig *lenp -= left; 1177f461d2dcSChristoph Hellwig out: 1178f461d2dcSChristoph Hellwig *ppos += *lenp; 1179f461d2dcSChristoph Hellwig return err; 1180f461d2dcSChristoph Hellwig } 1181f461d2dcSChristoph Hellwig 1182f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 118332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, 1184f461d2dcSChristoph Hellwig unsigned long convdiv) 1185f461d2dcSChristoph Hellwig { 1186f461d2dcSChristoph Hellwig return __do_proc_doulongvec_minmax(table->data, table, write, 1187f461d2dcSChristoph Hellwig buffer, lenp, ppos, convmul, convdiv); 1188f461d2dcSChristoph Hellwig } 1189f461d2dcSChristoph Hellwig 1190f461d2dcSChristoph Hellwig /** 1191f461d2dcSChristoph Hellwig * proc_doulongvec_minmax - read a vector of long integers with min/max values 1192f461d2dcSChristoph Hellwig * @table: the sysctl table 1193f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1194f461d2dcSChristoph Hellwig * @buffer: the user buffer 1195f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1196f461d2dcSChristoph Hellwig * @ppos: file position 1197f461d2dcSChristoph Hellwig * 1198f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1199f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1200f461d2dcSChristoph Hellwig * 1201f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1202f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1203f461d2dcSChristoph Hellwig * 1204f461d2dcSChristoph Hellwig * Returns 0 on success. 1205f461d2dcSChristoph Hellwig */ 1206f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 120732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1208f461d2dcSChristoph Hellwig { 1209f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 1210f461d2dcSChristoph Hellwig } 1211f461d2dcSChristoph Hellwig 1212f461d2dcSChristoph Hellwig /** 1213f461d2dcSChristoph Hellwig * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 1214f461d2dcSChristoph Hellwig * @table: the sysctl table 1215f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1216f461d2dcSChristoph Hellwig * @buffer: the user buffer 1217f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1218f461d2dcSChristoph Hellwig * @ppos: file position 1219f461d2dcSChristoph Hellwig * 1220f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1221f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. The values 1222f461d2dcSChristoph Hellwig * are treated as milliseconds, and converted to jiffies when they are stored. 1223f461d2dcSChristoph Hellwig * 1224f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1225f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1226f461d2dcSChristoph Hellwig * 1227f461d2dcSChristoph Hellwig * Returns 0 on success. 1228f461d2dcSChristoph Hellwig */ 1229f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 123032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1231f461d2dcSChristoph Hellwig { 1232f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, 1233f461d2dcSChristoph Hellwig lenp, ppos, HZ, 1000l); 1234f461d2dcSChristoph Hellwig } 1235f461d2dcSChristoph Hellwig 1236f461d2dcSChristoph Hellwig 1237f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 1238f461d2dcSChristoph Hellwig int *valp, 1239f461d2dcSChristoph Hellwig int write, void *data) 1240f461d2dcSChristoph Hellwig { 1241f461d2dcSChristoph Hellwig if (write) { 1242f461d2dcSChristoph Hellwig if (*lvalp > INT_MAX / HZ) 1243f461d2dcSChristoph Hellwig return 1; 1244f461d2dcSChristoph Hellwig *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 1245f461d2dcSChristoph Hellwig } else { 1246f461d2dcSChristoph Hellwig int val = *valp; 1247f461d2dcSChristoph Hellwig unsigned long lval; 1248f461d2dcSChristoph Hellwig if (val < 0) { 1249f461d2dcSChristoph Hellwig *negp = true; 1250f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1251f461d2dcSChristoph Hellwig } else { 1252f461d2dcSChristoph Hellwig *negp = false; 1253f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1254f461d2dcSChristoph Hellwig } 1255f461d2dcSChristoph Hellwig *lvalp = lval / HZ; 1256f461d2dcSChristoph Hellwig } 1257f461d2dcSChristoph Hellwig return 0; 1258f461d2dcSChristoph Hellwig } 1259f461d2dcSChristoph Hellwig 1260f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 1261f461d2dcSChristoph Hellwig int *valp, 1262f461d2dcSChristoph Hellwig int write, void *data) 1263f461d2dcSChristoph Hellwig { 1264f461d2dcSChristoph Hellwig if (write) { 1265f461d2dcSChristoph Hellwig if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 1266f461d2dcSChristoph Hellwig return 1; 1267f461d2dcSChristoph Hellwig *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 1268f461d2dcSChristoph Hellwig } else { 1269f461d2dcSChristoph Hellwig int val = *valp; 1270f461d2dcSChristoph Hellwig unsigned long lval; 1271f461d2dcSChristoph Hellwig if (val < 0) { 1272f461d2dcSChristoph Hellwig *negp = true; 1273f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1274f461d2dcSChristoph Hellwig } else { 1275f461d2dcSChristoph Hellwig *negp = false; 1276f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1277f461d2dcSChristoph Hellwig } 1278f461d2dcSChristoph Hellwig *lvalp = jiffies_to_clock_t(lval); 1279f461d2dcSChristoph Hellwig } 1280f461d2dcSChristoph Hellwig return 0; 1281f461d2dcSChristoph Hellwig } 1282f461d2dcSChristoph Hellwig 1283f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 1284f461d2dcSChristoph Hellwig int *valp, 1285f461d2dcSChristoph Hellwig int write, void *data) 1286f461d2dcSChristoph Hellwig { 1287f461d2dcSChristoph Hellwig if (write) { 1288f461d2dcSChristoph Hellwig unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 1289f461d2dcSChristoph Hellwig 1290f461d2dcSChristoph Hellwig if (jif > INT_MAX) 1291f461d2dcSChristoph Hellwig return 1; 1292f461d2dcSChristoph Hellwig *valp = (int)jif; 1293f461d2dcSChristoph Hellwig } else { 1294f461d2dcSChristoph Hellwig int val = *valp; 1295f461d2dcSChristoph Hellwig unsigned long lval; 1296f461d2dcSChristoph Hellwig if (val < 0) { 1297f461d2dcSChristoph Hellwig *negp = true; 1298f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1299f461d2dcSChristoph Hellwig } else { 1300f461d2dcSChristoph Hellwig *negp = false; 1301f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1302f461d2dcSChristoph Hellwig } 1303f461d2dcSChristoph Hellwig *lvalp = jiffies_to_msecs(lval); 1304f461d2dcSChristoph Hellwig } 1305f461d2dcSChristoph Hellwig return 0; 1306f461d2dcSChristoph Hellwig } 1307f461d2dcSChristoph Hellwig 1308f461d2dcSChristoph Hellwig /** 1309f461d2dcSChristoph Hellwig * proc_dointvec_jiffies - read a vector of integers as seconds 1310f461d2dcSChristoph Hellwig * @table: the sysctl table 1311f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1312f461d2dcSChristoph Hellwig * @buffer: the user buffer 1313f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1314f461d2dcSChristoph Hellwig * @ppos: file position 1315f461d2dcSChristoph Hellwig * 1316f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1317f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1318f461d2dcSChristoph Hellwig * The values read are assumed to be in seconds, and are converted into 1319f461d2dcSChristoph Hellwig * jiffies. 1320f461d2dcSChristoph Hellwig * 1321f461d2dcSChristoph Hellwig * Returns 0 on success. 1322f461d2dcSChristoph Hellwig */ 1323f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 132432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1325f461d2dcSChristoph Hellwig { 1326f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1327f461d2dcSChristoph Hellwig do_proc_dointvec_jiffies_conv,NULL); 1328f461d2dcSChristoph Hellwig } 1329f461d2dcSChristoph Hellwig 1330f461d2dcSChristoph Hellwig /** 1331f461d2dcSChristoph Hellwig * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 1332f461d2dcSChristoph Hellwig * @table: the sysctl table 1333f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1334f461d2dcSChristoph Hellwig * @buffer: the user buffer 1335f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1336f461d2dcSChristoph Hellwig * @ppos: pointer to the file position 1337f461d2dcSChristoph Hellwig * 1338f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1339f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1340f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/USER_HZ seconds, and 1341f461d2dcSChristoph Hellwig * are converted into jiffies. 1342f461d2dcSChristoph Hellwig * 1343f461d2dcSChristoph Hellwig * Returns 0 on success. 1344f461d2dcSChristoph Hellwig */ 1345f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 134632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1347f461d2dcSChristoph Hellwig { 1348f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1349f461d2dcSChristoph Hellwig do_proc_dointvec_userhz_jiffies_conv,NULL); 1350f461d2dcSChristoph Hellwig } 1351f461d2dcSChristoph Hellwig 1352f461d2dcSChristoph Hellwig /** 1353f461d2dcSChristoph Hellwig * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 1354f461d2dcSChristoph Hellwig * @table: the sysctl table 1355f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1356f461d2dcSChristoph Hellwig * @buffer: the user buffer 1357f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1358f461d2dcSChristoph Hellwig * @ppos: file position 1359f461d2dcSChristoph Hellwig * @ppos: the current position in the file 1360f461d2dcSChristoph Hellwig * 1361f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1362f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1363f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/1000 seconds, and 1364f461d2dcSChristoph Hellwig * are converted into jiffies. 1365f461d2dcSChristoph Hellwig * 1366f461d2dcSChristoph Hellwig * Returns 0 on success. 1367f461d2dcSChristoph Hellwig */ 136832927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer, 136932927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1370f461d2dcSChristoph Hellwig { 1371f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 1372f461d2dcSChristoph Hellwig do_proc_dointvec_ms_jiffies_conv, NULL); 1373f461d2dcSChristoph Hellwig } 1374f461d2dcSChristoph Hellwig 137532927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer, 137632927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1377f461d2dcSChristoph Hellwig { 1378f461d2dcSChristoph Hellwig struct pid *new_pid; 1379f461d2dcSChristoph Hellwig pid_t tmp; 1380f461d2dcSChristoph Hellwig int r; 1381f461d2dcSChristoph Hellwig 1382f461d2dcSChristoph Hellwig tmp = pid_vnr(cad_pid); 1383f461d2dcSChristoph Hellwig 1384f461d2dcSChristoph Hellwig r = __do_proc_dointvec(&tmp, table, write, buffer, 1385f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1386f461d2dcSChristoph Hellwig if (r || !write) 1387f461d2dcSChristoph Hellwig return r; 1388f461d2dcSChristoph Hellwig 1389f461d2dcSChristoph Hellwig new_pid = find_get_pid(tmp); 1390f461d2dcSChristoph Hellwig if (!new_pid) 1391f461d2dcSChristoph Hellwig return -ESRCH; 1392f461d2dcSChristoph Hellwig 1393f461d2dcSChristoph Hellwig put_pid(xchg(&cad_pid, new_pid)); 1394f461d2dcSChristoph Hellwig return 0; 1395f461d2dcSChristoph Hellwig } 1396f461d2dcSChristoph Hellwig 1397f461d2dcSChristoph Hellwig /** 1398f461d2dcSChristoph Hellwig * proc_do_large_bitmap - read/write from/to a large bitmap 1399f461d2dcSChristoph Hellwig * @table: the sysctl table 1400f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1401f461d2dcSChristoph Hellwig * @buffer: the user buffer 1402f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1403f461d2dcSChristoph Hellwig * @ppos: file position 1404f461d2dcSChristoph Hellwig * 1405f461d2dcSChristoph Hellwig * The bitmap is stored at table->data and the bitmap length (in bits) 1406f461d2dcSChristoph Hellwig * in table->maxlen. 1407f461d2dcSChristoph Hellwig * 1408f461d2dcSChristoph Hellwig * We use a range comma separated format (e.g. 1,3-4,10-10) so that 1409f461d2dcSChristoph Hellwig * large bitmaps may be represented in a compact manner. Writing into 1410f461d2dcSChristoph Hellwig * the file will clear the bitmap then update it with the given input. 1411f461d2dcSChristoph Hellwig * 1412f461d2dcSChristoph Hellwig * Returns 0 on success. 1413f461d2dcSChristoph Hellwig */ 1414f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 141532927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1416f461d2dcSChristoph Hellwig { 1417f461d2dcSChristoph Hellwig int err = 0; 1418f461d2dcSChristoph Hellwig bool first = 1; 1419f461d2dcSChristoph Hellwig size_t left = *lenp; 1420f461d2dcSChristoph Hellwig unsigned long bitmap_len = table->maxlen; 1421f461d2dcSChristoph Hellwig unsigned long *bitmap = *(unsigned long **) table->data; 1422f461d2dcSChristoph Hellwig unsigned long *tmp_bitmap = NULL; 1423f461d2dcSChristoph Hellwig char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1424f461d2dcSChristoph Hellwig 1425f461d2dcSChristoph Hellwig if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { 1426f461d2dcSChristoph Hellwig *lenp = 0; 1427f461d2dcSChristoph Hellwig return 0; 1428f461d2dcSChristoph Hellwig } 1429f461d2dcSChristoph Hellwig 1430f461d2dcSChristoph Hellwig if (write) { 143132927393SChristoph Hellwig char *p = buffer; 1432f461d2dcSChristoph Hellwig size_t skipped = 0; 1433f461d2dcSChristoph Hellwig 1434f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) { 1435f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 1436f461d2dcSChristoph Hellwig /* How much of the buffer we'll skip this pass */ 1437f461d2dcSChristoph Hellwig skipped = *lenp - left; 1438f461d2dcSChristoph Hellwig } 1439f461d2dcSChristoph Hellwig 1440f461d2dcSChristoph Hellwig tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); 144132927393SChristoph Hellwig if (!tmp_bitmap) 1442f461d2dcSChristoph Hellwig return -ENOMEM; 1443f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1444f461d2dcSChristoph Hellwig while (!err && left) { 1445f461d2dcSChristoph Hellwig unsigned long val_a, val_b; 1446f461d2dcSChristoph Hellwig bool neg; 1447f461d2dcSChristoph Hellwig size_t saved_left; 1448f461d2dcSChristoph Hellwig 1449f461d2dcSChristoph Hellwig /* In case we stop parsing mid-number, we can reset */ 1450f461d2dcSChristoph Hellwig saved_left = left; 1451f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_a, &neg, tr_a, 1452f461d2dcSChristoph Hellwig sizeof(tr_a), &c); 1453f461d2dcSChristoph Hellwig /* 1454f461d2dcSChristoph Hellwig * If we consumed the entirety of a truncated buffer or 1455f461d2dcSChristoph Hellwig * only one char is left (may be a "-"), then stop here, 1456f461d2dcSChristoph Hellwig * reset, & come back for more. 1457f461d2dcSChristoph Hellwig */ 1458f461d2dcSChristoph Hellwig if ((left <= 1) && skipped) { 1459f461d2dcSChristoph Hellwig left = saved_left; 1460f461d2dcSChristoph Hellwig break; 1461f461d2dcSChristoph Hellwig } 1462f461d2dcSChristoph Hellwig 1463f461d2dcSChristoph Hellwig if (err) 1464f461d2dcSChristoph Hellwig break; 1465f461d2dcSChristoph Hellwig if (val_a >= bitmap_len || neg) { 1466f461d2dcSChristoph Hellwig err = -EINVAL; 1467f461d2dcSChristoph Hellwig break; 1468f461d2dcSChristoph Hellwig } 1469f461d2dcSChristoph Hellwig 1470f461d2dcSChristoph Hellwig val_b = val_a; 1471f461d2dcSChristoph Hellwig if (left) { 1472f461d2dcSChristoph Hellwig p++; 1473f461d2dcSChristoph Hellwig left--; 1474f461d2dcSChristoph Hellwig } 1475f461d2dcSChristoph Hellwig 1476f461d2dcSChristoph Hellwig if (c == '-') { 1477f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_b, 1478f461d2dcSChristoph Hellwig &neg, tr_b, sizeof(tr_b), 1479f461d2dcSChristoph Hellwig &c); 1480f461d2dcSChristoph Hellwig /* 1481f461d2dcSChristoph Hellwig * If we consumed all of a truncated buffer or 1482f461d2dcSChristoph Hellwig * then stop here, reset, & come back for more. 1483f461d2dcSChristoph Hellwig */ 1484f461d2dcSChristoph Hellwig if (!left && skipped) { 1485f461d2dcSChristoph Hellwig left = saved_left; 1486f461d2dcSChristoph Hellwig break; 1487f461d2dcSChristoph Hellwig } 1488f461d2dcSChristoph Hellwig 1489f461d2dcSChristoph Hellwig if (err) 1490f461d2dcSChristoph Hellwig break; 1491f461d2dcSChristoph Hellwig if (val_b >= bitmap_len || neg || 1492f461d2dcSChristoph Hellwig val_a > val_b) { 1493f461d2dcSChristoph Hellwig err = -EINVAL; 1494f461d2dcSChristoph Hellwig break; 1495f461d2dcSChristoph Hellwig } 1496f461d2dcSChristoph Hellwig if (left) { 1497f461d2dcSChristoph Hellwig p++; 1498f461d2dcSChristoph Hellwig left--; 1499f461d2dcSChristoph Hellwig } 1500f461d2dcSChristoph Hellwig } 1501f461d2dcSChristoph Hellwig 1502f461d2dcSChristoph Hellwig bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 1503f461d2dcSChristoph Hellwig first = 0; 1504f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1505f461d2dcSChristoph Hellwig } 1506f461d2dcSChristoph Hellwig left += skipped; 1507f461d2dcSChristoph Hellwig } else { 1508f461d2dcSChristoph Hellwig unsigned long bit_a, bit_b = 0; 1509f461d2dcSChristoph Hellwig 1510f461d2dcSChristoph Hellwig while (left) { 1511f461d2dcSChristoph Hellwig bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 1512f461d2dcSChristoph Hellwig if (bit_a >= bitmap_len) 1513f461d2dcSChristoph Hellwig break; 1514f461d2dcSChristoph Hellwig bit_b = find_next_zero_bit(bitmap, bitmap_len, 1515f461d2dcSChristoph Hellwig bit_a + 1) - 1; 1516f461d2dcSChristoph Hellwig 151732927393SChristoph Hellwig if (!first) 151832927393SChristoph Hellwig proc_put_char(&buffer, &left, ','); 151932927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_a, false); 1520f461d2dcSChristoph Hellwig if (bit_a != bit_b) { 152132927393SChristoph Hellwig proc_put_char(&buffer, &left, '-'); 152232927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_b, false); 1523f461d2dcSChristoph Hellwig } 1524f461d2dcSChristoph Hellwig 1525f461d2dcSChristoph Hellwig first = 0; bit_b++; 1526f461d2dcSChristoph Hellwig } 152732927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1528f461d2dcSChristoph Hellwig } 1529f461d2dcSChristoph Hellwig 1530f461d2dcSChristoph Hellwig if (!err) { 1531f461d2dcSChristoph Hellwig if (write) { 1532f461d2dcSChristoph Hellwig if (*ppos) 1533f461d2dcSChristoph Hellwig bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 1534f461d2dcSChristoph Hellwig else 1535f461d2dcSChristoph Hellwig bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 1536f461d2dcSChristoph Hellwig } 1537f461d2dcSChristoph Hellwig *lenp -= left; 1538f461d2dcSChristoph Hellwig *ppos += *lenp; 1539f461d2dcSChristoph Hellwig } 1540f461d2dcSChristoph Hellwig 1541f461d2dcSChristoph Hellwig bitmap_free(tmp_bitmap); 1542f461d2dcSChristoph Hellwig return err; 1543f461d2dcSChristoph Hellwig } 1544f461d2dcSChristoph Hellwig 1545f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */ 1546f461d2dcSChristoph Hellwig 1547f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 154832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1549f461d2dcSChristoph Hellwig { 1550f461d2dcSChristoph Hellwig return -ENOSYS; 1551f461d2dcSChristoph Hellwig } 1552f461d2dcSChristoph Hellwig 1553f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, 155432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1555f461d2dcSChristoph Hellwig { 1556f461d2dcSChristoph Hellwig return -ENOSYS; 1557f461d2dcSChristoph Hellwig } 1558f461d2dcSChristoph Hellwig 1559f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, 156032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1561f461d2dcSChristoph Hellwig { 1562f461d2dcSChristoph Hellwig return -ENOSYS; 1563f461d2dcSChristoph Hellwig } 1564f461d2dcSChristoph Hellwig 1565f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 156632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1567f461d2dcSChristoph Hellwig { 1568f461d2dcSChristoph Hellwig return -ENOSYS; 1569f461d2dcSChristoph Hellwig } 1570f461d2dcSChristoph Hellwig 1571f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 157232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1573f461d2dcSChristoph Hellwig { 1574f461d2dcSChristoph Hellwig return -ENOSYS; 1575f461d2dcSChristoph Hellwig } 1576f461d2dcSChristoph Hellwig 1577f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 157832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1579f461d2dcSChristoph Hellwig { 1580f461d2dcSChristoph Hellwig return -ENOSYS; 1581f461d2dcSChristoph Hellwig } 1582f461d2dcSChristoph Hellwig 1583f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 158432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1585f461d2dcSChristoph Hellwig { 1586f461d2dcSChristoph Hellwig return -ENOSYS; 1587f461d2dcSChristoph Hellwig } 1588f461d2dcSChristoph Hellwig 1589f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 159032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1591f461d2dcSChristoph Hellwig { 1592f461d2dcSChristoph Hellwig return -ENOSYS; 1593f461d2dcSChristoph Hellwig } 1594f461d2dcSChristoph Hellwig 1595f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 159632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1597f461d2dcSChristoph Hellwig { 1598f461d2dcSChristoph Hellwig return -ENOSYS; 1599f461d2dcSChristoph Hellwig } 1600f461d2dcSChristoph Hellwig 1601f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 160232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1603f461d2dcSChristoph Hellwig { 1604f461d2dcSChristoph Hellwig return -ENOSYS; 1605f461d2dcSChristoph Hellwig } 1606f461d2dcSChristoph Hellwig 1607f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 160832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1609f461d2dcSChristoph Hellwig { 1610f461d2dcSChristoph Hellwig return -ENOSYS; 1611f461d2dcSChristoph Hellwig } 1612f461d2dcSChristoph Hellwig 1613f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 1614f461d2dcSChristoph Hellwig 1615f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL) 1616f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write, 161732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1618f461d2dcSChristoph Hellwig { 1619f461d2dcSChristoph Hellwig struct static_key *key = (struct static_key *)table->data; 1620f461d2dcSChristoph Hellwig static DEFINE_MUTEX(static_key_mutex); 1621f461d2dcSChristoph Hellwig int val, ret; 1622f461d2dcSChristoph Hellwig struct ctl_table tmp = { 1623f461d2dcSChristoph Hellwig .data = &val, 1624f461d2dcSChristoph Hellwig .maxlen = sizeof(val), 1625f461d2dcSChristoph Hellwig .mode = table->mode, 1626f461d2dcSChristoph Hellwig .extra1 = SYSCTL_ZERO, 1627f461d2dcSChristoph Hellwig .extra2 = SYSCTL_ONE, 1628f461d2dcSChristoph Hellwig }; 1629f461d2dcSChristoph Hellwig 1630f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 1631f461d2dcSChristoph Hellwig return -EPERM; 1632f461d2dcSChristoph Hellwig 1633f461d2dcSChristoph Hellwig mutex_lock(&static_key_mutex); 1634f461d2dcSChristoph Hellwig val = static_key_enabled(key); 1635f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 1636f461d2dcSChristoph Hellwig if (write && !ret) { 1637f461d2dcSChristoph Hellwig if (val) 1638f461d2dcSChristoph Hellwig static_key_enable(key); 1639f461d2dcSChristoph Hellwig else 1640f461d2dcSChristoph Hellwig static_key_disable(key); 1641f461d2dcSChristoph Hellwig } 1642f461d2dcSChristoph Hellwig mutex_unlock(&static_key_mutex); 1643f461d2dcSChristoph Hellwig return ret; 1644f461d2dcSChristoph Hellwig } 1645f461d2dcSChristoph Hellwig 1646d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 16472bba22c5SMike Galbraith { 16482bba22c5SMike Galbraith .procname = "sched_child_runs_first", 16492bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 16502bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 16512bba22c5SMike Galbraith .mode = 0644, 16526d456111SEric W. Biederman .proc_handler = proc_dointvec, 16532bba22c5SMike Galbraith }, 165477e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 165577e54a1fSIngo Molnar { 1656b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 1657b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 165877e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 165977e54a1fSIngo Molnar .mode = 0644, 1660702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 1661b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 1662b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 166377e54a1fSIngo Molnar }, 166477e54a1fSIngo Molnar { 166521805085SPeter Zijlstra .procname = "sched_latency_ns", 166621805085SPeter Zijlstra .data = &sysctl_sched_latency, 166721805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 166821805085SPeter Zijlstra .mode = 0644, 1669702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 167021805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 167121805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 167221805085SPeter Zijlstra }, 167321805085SPeter Zijlstra { 167477e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 167577e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 167677e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 167777e54a1fSIngo Molnar .mode = 0644, 1678702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 167977e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 168077e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 168177e54a1fSIngo Molnar }, 1682cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP 168377e54a1fSIngo Molnar { 16841983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 16851983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 16861983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 16871983a922SChristian Ehrhardt .mode = 0644, 1688702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 16891983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 16901983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 16912398f2c6SPeter Zijlstra }, 16922398f2c6SPeter Zijlstra { 1693d00535dbSNamhyung Kim .procname = "sched_migration_cost_ns", 1694da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 1695da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 1696da84d961SIngo Molnar .mode = 0644, 16976d456111SEric W. Biederman .proc_handler = proc_dointvec, 1698da84d961SIngo Molnar }, 1699b82d9fddSPeter Zijlstra { 1700b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 1701b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 1702b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 1703fa85ae24SPeter Zijlstra .mode = 0644, 17046d456111SEric W. Biederman .proc_handler = proc_dointvec, 1705fa85ae24SPeter Zijlstra }, 1706cb251765SMel Gorman #ifdef CONFIG_SCHEDSTATS 1707cb251765SMel Gorman { 1708cb251765SMel Gorman .procname = "sched_schedstats", 1709cb251765SMel Gorman .data = NULL, 1710cb251765SMel Gorman .maxlen = sizeof(unsigned int), 1711cb251765SMel Gorman .mode = 0644, 1712cb251765SMel Gorman .proc_handler = sysctl_schedstats, 1713eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1714eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1715cb251765SMel Gorman }, 1716cb251765SMel Gorman #endif /* CONFIG_SCHEDSTATS */ 1717cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */ 1718cbee9f88SPeter Zijlstra #ifdef CONFIG_NUMA_BALANCING 1719cbee9f88SPeter Zijlstra { 17204b96a29bSPeter Zijlstra .procname = "numa_balancing_scan_delay_ms", 17214b96a29bSPeter Zijlstra .data = &sysctl_numa_balancing_scan_delay, 17224b96a29bSPeter Zijlstra .maxlen = sizeof(unsigned int), 17234b96a29bSPeter Zijlstra .mode = 0644, 17244b96a29bSPeter Zijlstra .proc_handler = proc_dointvec, 17254b96a29bSPeter Zijlstra }, 17264b96a29bSPeter Zijlstra { 1727cbee9f88SPeter Zijlstra .procname = "numa_balancing_scan_period_min_ms", 1728cbee9f88SPeter Zijlstra .data = &sysctl_numa_balancing_scan_period_min, 1729cbee9f88SPeter Zijlstra .maxlen = sizeof(unsigned int), 1730cbee9f88SPeter Zijlstra .mode = 0644, 1731cbee9f88SPeter Zijlstra .proc_handler = proc_dointvec, 1732cbee9f88SPeter Zijlstra }, 1733cbee9f88SPeter Zijlstra { 1734cbee9f88SPeter Zijlstra .procname = "numa_balancing_scan_period_max_ms", 1735cbee9f88SPeter Zijlstra .data = &sysctl_numa_balancing_scan_period_max, 1736cbee9f88SPeter Zijlstra .maxlen = sizeof(unsigned int), 1737cbee9f88SPeter Zijlstra .mode = 0644, 1738cbee9f88SPeter Zijlstra .proc_handler = proc_dointvec, 1739cbee9f88SPeter Zijlstra }, 17406e5fb223SPeter Zijlstra { 17416e5fb223SPeter Zijlstra .procname = "numa_balancing_scan_size_mb", 17426e5fb223SPeter Zijlstra .data = &sysctl_numa_balancing_scan_size, 17436e5fb223SPeter Zijlstra .maxlen = sizeof(unsigned int), 17446e5fb223SPeter Zijlstra .mode = 0644, 174564192658SKirill Tkhai .proc_handler = proc_dointvec_minmax, 1746eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 17476e5fb223SPeter Zijlstra }, 17483a7053b3SMel Gorman { 174954a43d54SAndi Kleen .procname = "numa_balancing", 175054a43d54SAndi Kleen .data = NULL, /* filled in by handler */ 175154a43d54SAndi Kleen .maxlen = sizeof(unsigned int), 175254a43d54SAndi Kleen .mode = 0644, 175354a43d54SAndi Kleen .proc_handler = sysctl_numa_balancing, 1754eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1755eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 175654a43d54SAndi Kleen }, 1757cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */ 1758cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */ 17591799e35dSIngo Molnar { 17609f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 17619f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 17629f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 17639f0c1e56SPeter Zijlstra .mode = 0644, 17646d456111SEric W. Biederman .proc_handler = sched_rt_handler, 17659f0c1e56SPeter Zijlstra }, 17669f0c1e56SPeter Zijlstra { 17679f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 17689f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 17699f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 17709f0c1e56SPeter Zijlstra .mode = 0644, 17716d456111SEric W. Biederman .proc_handler = sched_rt_handler, 17729f0c1e56SPeter Zijlstra }, 1773ce0dbbbbSClark Williams { 1774ce0dbbbbSClark Williams .procname = "sched_rr_timeslice_ms", 1775975e155eSShile Zhang .data = &sysctl_sched_rr_timeslice, 1776ce0dbbbbSClark Williams .maxlen = sizeof(int), 1777ce0dbbbbSClark Williams .mode = 0644, 1778ce0dbbbbSClark Williams .proc_handler = sched_rr_handler, 1779ce0dbbbbSClark Williams }, 1780e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK 1781e8f14172SPatrick Bellasi { 1782e8f14172SPatrick Bellasi .procname = "sched_util_clamp_min", 1783e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_min, 1784e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1785e8f14172SPatrick Bellasi .mode = 0644, 1786e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1787e8f14172SPatrick Bellasi }, 1788e8f14172SPatrick Bellasi { 1789e8f14172SPatrick Bellasi .procname = "sched_util_clamp_max", 1790e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_max, 1791e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1792e8f14172SPatrick Bellasi .mode = 0644, 1793e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1794e8f14172SPatrick Bellasi }, 1795e8f14172SPatrick Bellasi #endif 17965091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 17975091faa4SMike Galbraith { 17985091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 17995091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 18005091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 18015091faa4SMike Galbraith .mode = 0644, 18021747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 1803eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1804eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18055091faa4SMike Galbraith }, 18065091faa4SMike Galbraith #endif 1807ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 1808ec12cb7fSPaul Turner { 1809ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 1810ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 1811ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 1812ec12cb7fSPaul Turner .mode = 0644, 1813ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 1814eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 1815ec12cb7fSPaul Turner }, 1816ec12cb7fSPaul Turner #endif 18178d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) 18188d5d0cfbSQuentin Perret { 18198d5d0cfbSQuentin Perret .procname = "sched_energy_aware", 18208d5d0cfbSQuentin Perret .data = &sysctl_sched_energy_aware, 18218d5d0cfbSQuentin Perret .maxlen = sizeof(unsigned int), 18228d5d0cfbSQuentin Perret .mode = 0644, 18238d5d0cfbSQuentin Perret .proc_handler = sched_energy_aware_handler, 1824eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1825eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18268d5d0cfbSQuentin Perret }, 18278d5d0cfbSQuentin Perret #endif 1828f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 1829f20786ffSPeter Zijlstra { 1830f20786ffSPeter Zijlstra .procname = "prove_locking", 1831f20786ffSPeter Zijlstra .data = &prove_locking, 1832f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1833f20786ffSPeter Zijlstra .mode = 0644, 18346d456111SEric W. Biederman .proc_handler = proc_dointvec, 1835f20786ffSPeter Zijlstra }, 1836f20786ffSPeter Zijlstra #endif 1837f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 1838f20786ffSPeter Zijlstra { 1839f20786ffSPeter Zijlstra .procname = "lock_stat", 1840f20786ffSPeter Zijlstra .data = &lock_stat, 1841f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1842f20786ffSPeter Zijlstra .mode = 0644, 18436d456111SEric W. Biederman .proc_handler = proc_dointvec, 1844f20786ffSPeter Zijlstra }, 1845f20786ffSPeter Zijlstra #endif 184677e54a1fSIngo Molnar { 18471da177e4SLinus Torvalds .procname = "panic", 18481da177e4SLinus Torvalds .data = &panic_timeout, 18491da177e4SLinus Torvalds .maxlen = sizeof(int), 18501da177e4SLinus Torvalds .mode = 0644, 18516d456111SEric W. Biederman .proc_handler = proc_dointvec, 18521da177e4SLinus Torvalds }, 1853046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 18541da177e4SLinus Torvalds { 18551da177e4SLinus Torvalds .procname = "core_uses_pid", 18561da177e4SLinus Torvalds .data = &core_uses_pid, 18571da177e4SLinus Torvalds .maxlen = sizeof(int), 18581da177e4SLinus Torvalds .mode = 0644, 18596d456111SEric W. Biederman .proc_handler = proc_dointvec, 18601da177e4SLinus Torvalds }, 18611da177e4SLinus Torvalds { 18621da177e4SLinus Torvalds .procname = "core_pattern", 18631da177e4SLinus Torvalds .data = core_pattern, 186471ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 18651da177e4SLinus Torvalds .mode = 0644, 186654b50199SKees Cook .proc_handler = proc_dostring_coredump, 18671da177e4SLinus Torvalds }, 1868a293980cSNeil Horman { 1869a293980cSNeil Horman .procname = "core_pipe_limit", 1870a293980cSNeil Horman .data = &core_pipe_limit, 1871a293980cSNeil Horman .maxlen = sizeof(unsigned int), 1872a293980cSNeil Horman .mode = 0644, 18736d456111SEric W. Biederman .proc_handler = proc_dointvec, 1874a293980cSNeil Horman }, 1875046d662fSAlex Kelly #endif 187634f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 18771da177e4SLinus Torvalds { 18781da177e4SLinus Torvalds .procname = "tainted", 187925ddbb18SAndi Kleen .maxlen = sizeof(long), 188034f5a398STheodore Ts'o .mode = 0644, 18816d456111SEric W. Biederman .proc_handler = proc_taint, 18821da177e4SLinus Torvalds }, 1883f4aacea2SKees Cook { 1884f4aacea2SKees Cook .procname = "sysctl_writes_strict", 1885f4aacea2SKees Cook .data = &sysctl_writes_strict, 1886f4aacea2SKees Cook .maxlen = sizeof(int), 1887f4aacea2SKees Cook .mode = 0644, 1888f4aacea2SKees Cook .proc_handler = proc_dointvec_minmax, 1889f4aacea2SKees Cook .extra1 = &neg_one, 1890eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1891f4aacea2SKees Cook }, 189234f5a398STheodore Ts'o #endif 18939745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 18949745512cSArjan van de Ven { 18959745512cSArjan van de Ven .procname = "latencytop", 18969745512cSArjan van de Ven .data = &latencytop_enabled, 18979745512cSArjan van de Ven .maxlen = sizeof(int), 18989745512cSArjan van de Ven .mode = 0644, 1899cb251765SMel Gorman .proc_handler = sysctl_latencytop, 19009745512cSArjan van de Ven }, 19019745512cSArjan van de Ven #endif 19021da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 19031da177e4SLinus Torvalds { 19041da177e4SLinus Torvalds .procname = "real-root-dev", 19051da177e4SLinus Torvalds .data = &real_root_dev, 19061da177e4SLinus Torvalds .maxlen = sizeof(int), 19071da177e4SLinus Torvalds .mode = 0644, 19086d456111SEric W. Biederman .proc_handler = proc_dointvec, 19091da177e4SLinus Torvalds }, 19101da177e4SLinus Torvalds #endif 191145807a1dSIngo Molnar { 191245807a1dSIngo Molnar .procname = "print-fatal-signals", 191345807a1dSIngo Molnar .data = &print_fatal_signals, 191445807a1dSIngo Molnar .maxlen = sizeof(int), 191545807a1dSIngo Molnar .mode = 0644, 19166d456111SEric W. Biederman .proc_handler = proc_dointvec, 191745807a1dSIngo Molnar }, 191872c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 19191da177e4SLinus Torvalds { 19201da177e4SLinus Torvalds .procname = "reboot-cmd", 19211da177e4SLinus Torvalds .data = reboot_command, 19221da177e4SLinus Torvalds .maxlen = 256, 19231da177e4SLinus Torvalds .mode = 0644, 19246d456111SEric W. Biederman .proc_handler = proc_dostring, 19251da177e4SLinus Torvalds }, 19261da177e4SLinus Torvalds { 19271da177e4SLinus Torvalds .procname = "stop-a", 19281da177e4SLinus Torvalds .data = &stop_a_enabled, 19291da177e4SLinus Torvalds .maxlen = sizeof (int), 19301da177e4SLinus Torvalds .mode = 0644, 19316d456111SEric W. Biederman .proc_handler = proc_dointvec, 19321da177e4SLinus Torvalds }, 19331da177e4SLinus Torvalds { 19341da177e4SLinus Torvalds .procname = "scons-poweroff", 19351da177e4SLinus Torvalds .data = &scons_pwroff, 19361da177e4SLinus Torvalds .maxlen = sizeof (int), 19371da177e4SLinus Torvalds .mode = 0644, 19386d456111SEric W. Biederman .proc_handler = proc_dointvec, 19391da177e4SLinus Torvalds }, 19401da177e4SLinus Torvalds #endif 19410871420fSDavid S. Miller #ifdef CONFIG_SPARC64 19420871420fSDavid S. Miller { 19430871420fSDavid S. Miller .procname = "tsb-ratio", 19440871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 19450871420fSDavid S. Miller .maxlen = sizeof (int), 19460871420fSDavid S. Miller .mode = 0644, 19476d456111SEric W. Biederman .proc_handler = proc_dointvec, 19480871420fSDavid S. Miller }, 19490871420fSDavid S. Miller #endif 1950b67114dbSHelge Deller #ifdef CONFIG_PARISC 19511da177e4SLinus Torvalds { 19521da177e4SLinus Torvalds .procname = "soft-power", 19531da177e4SLinus Torvalds .data = &pwrsw_enabled, 19541da177e4SLinus Torvalds .maxlen = sizeof (int), 19551da177e4SLinus Torvalds .mode = 0644, 19566d456111SEric W. Biederman .proc_handler = proc_dointvec, 19571da177e4SLinus Torvalds }, 1958bf14e3b9SVineet Gupta #endif 1959bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW 19601da177e4SLinus Torvalds { 19611da177e4SLinus Torvalds .procname = "unaligned-trap", 19621da177e4SLinus Torvalds .data = &unaligned_enabled, 19631da177e4SLinus Torvalds .maxlen = sizeof (int), 19641da177e4SLinus Torvalds .mode = 0644, 19656d456111SEric W. Biederman .proc_handler = proc_dointvec, 19661da177e4SLinus Torvalds }, 19671da177e4SLinus Torvalds #endif 19681da177e4SLinus Torvalds { 19691da177e4SLinus Torvalds .procname = "ctrl-alt-del", 19701da177e4SLinus Torvalds .data = &C_A_D, 19711da177e4SLinus Torvalds .maxlen = sizeof(int), 19721da177e4SLinus Torvalds .mode = 0644, 19736d456111SEric W. Biederman .proc_handler = proc_dointvec, 19741da177e4SLinus Torvalds }, 1975606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 1976b0fc494fSSteven Rostedt { 1977b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 1978b0fc494fSSteven Rostedt .data = &ftrace_enabled, 1979b0fc494fSSteven Rostedt .maxlen = sizeof(int), 1980b0fc494fSSteven Rostedt .mode = 0644, 19816d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 1982b0fc494fSSteven Rostedt }, 1983b0fc494fSSteven Rostedt #endif 1984f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 1985f38f1d2aSSteven Rostedt { 1986f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 1987f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 1988f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 1989f38f1d2aSSteven Rostedt .mode = 0644, 19906d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 1991f38f1d2aSSteven Rostedt }, 1992f38f1d2aSSteven Rostedt #endif 1993944ac425SSteven Rostedt #ifdef CONFIG_TRACING 1994944ac425SSteven Rostedt { 19953299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 1996944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 1997944ac425SSteven Rostedt .maxlen = sizeof(int), 1998944ac425SSteven Rostedt .mode = 0644, 19996d456111SEric W. Biederman .proc_handler = proc_dointvec, 2000944ac425SSteven Rostedt }, 2001de7edd31SSteven Rostedt (Red Hat) { 2002de7edd31SSteven Rostedt (Red Hat) .procname = "traceoff_on_warning", 2003de7edd31SSteven Rostedt (Red Hat) .data = &__disable_trace_on_warning, 2004de7edd31SSteven Rostedt (Red Hat) .maxlen = sizeof(__disable_trace_on_warning), 2005de7edd31SSteven Rostedt (Red Hat) .mode = 0644, 2006de7edd31SSteven Rostedt (Red Hat) .proc_handler = proc_dointvec, 2007de7edd31SSteven Rostedt (Red Hat) }, 20080daa2302SSteven Rostedt (Red Hat) { 20090daa2302SSteven Rostedt (Red Hat) .procname = "tracepoint_printk", 20100daa2302SSteven Rostedt (Red Hat) .data = &tracepoint_printk, 20110daa2302SSteven Rostedt (Red Hat) .maxlen = sizeof(tracepoint_printk), 20120daa2302SSteven Rostedt (Red Hat) .mode = 0644, 201342391745SSteven Rostedt (Red Hat) .proc_handler = tracepoint_printk_sysctl, 20140daa2302SSteven Rostedt (Red Hat) }, 2015944ac425SSteven Rostedt #endif 20162965faa5SDave Young #ifdef CONFIG_KEXEC_CORE 20177984754bSKees Cook { 20187984754bSKees Cook .procname = "kexec_load_disabled", 20197984754bSKees Cook .data = &kexec_load_disabled, 20207984754bSKees Cook .maxlen = sizeof(int), 20217984754bSKees Cook .mode = 0644, 20227984754bSKees Cook /* only handle a transition from default "0" to "1" */ 20237984754bSKees Cook .proc_handler = proc_dointvec_minmax, 2024eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2025eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20267984754bSKees Cook }, 20277984754bSKees Cook #endif 2028a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 20291da177e4SLinus Torvalds { 20301da177e4SLinus Torvalds .procname = "modprobe", 20311da177e4SLinus Torvalds .data = &modprobe_path, 20321da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 20331da177e4SLinus Torvalds .mode = 0644, 20346d456111SEric W. Biederman .proc_handler = proc_dostring, 20351da177e4SLinus Torvalds }, 20363d43321bSKees Cook { 20373d43321bSKees Cook .procname = "modules_disabled", 20383d43321bSKees Cook .data = &modules_disabled, 20393d43321bSKees Cook .maxlen = sizeof(int), 20403d43321bSKees Cook .mode = 0644, 20413d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 20426d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2043eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2044eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20453d43321bSKees Cook }, 20461da177e4SLinus Torvalds #endif 204786d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER 20481da177e4SLinus Torvalds { 20491da177e4SLinus Torvalds .procname = "hotplug", 2050312c004dSKay Sievers .data = &uevent_helper, 2051312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 20521da177e4SLinus Torvalds .mode = 0644, 20536d456111SEric W. Biederman .proc_handler = proc_dostring, 20541da177e4SLinus Torvalds }, 205586d56134SMichael Marineau #endif 20561da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 20571da177e4SLinus Torvalds { 20581da177e4SLinus Torvalds .procname = "sg-big-buff", 20591da177e4SLinus Torvalds .data = &sg_big_buff, 20601da177e4SLinus Torvalds .maxlen = sizeof (int), 20611da177e4SLinus Torvalds .mode = 0444, 20626d456111SEric W. Biederman .proc_handler = proc_dointvec, 20631da177e4SLinus Torvalds }, 20641da177e4SLinus Torvalds #endif 20651da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 20661da177e4SLinus Torvalds { 20671da177e4SLinus Torvalds .procname = "acct", 20681da177e4SLinus Torvalds .data = &acct_parm, 20691da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 20701da177e4SLinus Torvalds .mode = 0644, 20716d456111SEric W. Biederman .proc_handler = proc_dointvec, 20721da177e4SLinus Torvalds }, 20731da177e4SLinus Torvalds #endif 20741da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 20751da177e4SLinus Torvalds { 20761da177e4SLinus Torvalds .procname = "sysrq", 2077eaee4172SDmitry Safonov .data = NULL, 20781da177e4SLinus Torvalds .maxlen = sizeof (int), 20791da177e4SLinus Torvalds .mode = 0644, 208097f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 20811da177e4SLinus Torvalds }, 20821da177e4SLinus Torvalds #endif 2083d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 20841da177e4SLinus Torvalds { 20851da177e4SLinus Torvalds .procname = "cad_pid", 20869ec52099SCedric Le Goater .data = NULL, 20871da177e4SLinus Torvalds .maxlen = sizeof (int), 20881da177e4SLinus Torvalds .mode = 0600, 20896d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 20901da177e4SLinus Torvalds }, 2091d6f8ff73SRandy Dunlap #endif 20921da177e4SLinus Torvalds { 20931da177e4SLinus Torvalds .procname = "threads-max", 209416db3d3fSHeinrich Schuchardt .data = NULL, 20951da177e4SLinus Torvalds .maxlen = sizeof(int), 20961da177e4SLinus Torvalds .mode = 0644, 209716db3d3fSHeinrich Schuchardt .proc_handler = sysctl_max_threads, 20981da177e4SLinus Torvalds }, 20991da177e4SLinus Torvalds { 21001da177e4SLinus Torvalds .procname = "random", 21011da177e4SLinus Torvalds .mode = 0555, 21021da177e4SLinus Torvalds .child = random_table, 21031da177e4SLinus Torvalds }, 21041da177e4SLinus Torvalds { 210517f60a7dSEric Paris .procname = "usermodehelper", 210617f60a7dSEric Paris .mode = 0555, 210717f60a7dSEric Paris .child = usermodehelper_table, 210817f60a7dSEric Paris }, 2109ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER 2110ceb18132SLuis R. Rodriguez { 2111ceb18132SLuis R. Rodriguez .procname = "firmware_config", 2112ceb18132SLuis R. Rodriguez .mode = 0555, 2113ceb18132SLuis R. Rodriguez .child = firmware_config_table, 2114ceb18132SLuis R. Rodriguez }, 2115ceb18132SLuis R. Rodriguez #endif 211617f60a7dSEric Paris { 21171da177e4SLinus Torvalds .procname = "overflowuid", 21181da177e4SLinus Torvalds .data = &overflowuid, 21191da177e4SLinus Torvalds .maxlen = sizeof(int), 21201da177e4SLinus Torvalds .mode = 0644, 21216d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21221da177e4SLinus Torvalds .extra1 = &minolduid, 21231da177e4SLinus Torvalds .extra2 = &maxolduid, 21241da177e4SLinus Torvalds }, 21251da177e4SLinus Torvalds { 21261da177e4SLinus Torvalds .procname = "overflowgid", 21271da177e4SLinus Torvalds .data = &overflowgid, 21281da177e4SLinus Torvalds .maxlen = sizeof(int), 21291da177e4SLinus Torvalds .mode = 0644, 21306d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21311da177e4SLinus Torvalds .extra1 = &minolduid, 21321da177e4SLinus Torvalds .extra2 = &maxolduid, 21331da177e4SLinus Torvalds }, 2134347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 21351da177e4SLinus Torvalds { 21361da177e4SLinus Torvalds .procname = "userprocess_debug", 2137ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 21381da177e4SLinus Torvalds .maxlen = sizeof(int), 21391da177e4SLinus Torvalds .mode = 0644, 21406d456111SEric W. Biederman .proc_handler = proc_dointvec, 21411da177e4SLinus Torvalds }, 21421da177e4SLinus Torvalds #endif 21431da177e4SLinus Torvalds { 21441da177e4SLinus Torvalds .procname = "pid_max", 21451da177e4SLinus Torvalds .data = &pid_max, 21461da177e4SLinus Torvalds .maxlen = sizeof (int), 21471da177e4SLinus Torvalds .mode = 0644, 21486d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21491da177e4SLinus Torvalds .extra1 = &pid_max_min, 21501da177e4SLinus Torvalds .extra2 = &pid_max_max, 21511da177e4SLinus Torvalds }, 21521da177e4SLinus Torvalds { 21531da177e4SLinus Torvalds .procname = "panic_on_oops", 21541da177e4SLinus Torvalds .data = &panic_on_oops, 21551da177e4SLinus Torvalds .maxlen = sizeof(int), 21561da177e4SLinus Torvalds .mode = 0644, 21576d456111SEric W. Biederman .proc_handler = proc_dointvec, 21581da177e4SLinus Torvalds }, 215981c9d43fSFeng Tang { 216081c9d43fSFeng Tang .procname = "panic_print", 216181c9d43fSFeng Tang .data = &panic_print, 216281c9d43fSFeng Tang .maxlen = sizeof(unsigned long), 216381c9d43fSFeng Tang .mode = 0644, 216481c9d43fSFeng Tang .proc_handler = proc_doulongvec_minmax, 216581c9d43fSFeng Tang }, 21667ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 21677ef3d2fdSJoe Perches { 21687ef3d2fdSJoe Perches .procname = "printk", 21697ef3d2fdSJoe Perches .data = &console_loglevel, 21707ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 21717ef3d2fdSJoe Perches .mode = 0644, 21726d456111SEric W. Biederman .proc_handler = proc_dointvec, 21737ef3d2fdSJoe Perches }, 21741da177e4SLinus Torvalds { 21751da177e4SLinus Torvalds .procname = "printk_ratelimit", 2176717115e1SDave Young .data = &printk_ratelimit_state.interval, 21771da177e4SLinus Torvalds .maxlen = sizeof(int), 21781da177e4SLinus Torvalds .mode = 0644, 21796d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 21801da177e4SLinus Torvalds }, 21811da177e4SLinus Torvalds { 21821da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 2183717115e1SDave Young .data = &printk_ratelimit_state.burst, 21841da177e4SLinus Torvalds .maxlen = sizeof(int), 21851da177e4SLinus Torvalds .mode = 0644, 21866d456111SEric W. Biederman .proc_handler = proc_dointvec, 21871da177e4SLinus Torvalds }, 2188af91322eSDave Young { 2189af91322eSDave Young .procname = "printk_delay", 2190af91322eSDave Young .data = &printk_delay_msec, 2191af91322eSDave Young .maxlen = sizeof(int), 2192af91322eSDave Young .mode = 0644, 21936d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2194eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2195af91322eSDave Young .extra2 = &ten_thousand, 2196af91322eSDave Young }, 21971da177e4SLinus Torvalds { 2198750afe7bSBorislav Petkov .procname = "printk_devkmsg", 2199750afe7bSBorislav Petkov .data = devkmsg_log_str, 2200750afe7bSBorislav Petkov .maxlen = DEVKMSG_STR_MAX_SIZE, 2201750afe7bSBorislav Petkov .mode = 0644, 2202750afe7bSBorislav Petkov .proc_handler = devkmsg_sysctl_set_loglvl, 2203750afe7bSBorislav Petkov }, 2204750afe7bSBorislav Petkov { 2205eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 2206eaf06b24SDan Rosenberg .data = &dmesg_restrict, 2207eaf06b24SDan Rosenberg .maxlen = sizeof(int), 2208eaf06b24SDan Rosenberg .mode = 0644, 2209620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2210eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2211eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2212eaf06b24SDan Rosenberg }, 2213455cd5abSDan Rosenberg { 2214455cd5abSDan Rosenberg .procname = "kptr_restrict", 2215455cd5abSDan Rosenberg .data = &kptr_restrict, 2216455cd5abSDan Rosenberg .maxlen = sizeof(int), 2217455cd5abSDan Rosenberg .mode = 0644, 2218620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2219eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2220455cd5abSDan Rosenberg .extra2 = &two, 2221455cd5abSDan Rosenberg }, 2222df6e61d4SJoe Perches #endif 2223eaf06b24SDan Rosenberg { 22241da177e4SLinus Torvalds .procname = "ngroups_max", 22251da177e4SLinus Torvalds .data = &ngroups_max, 22261da177e4SLinus Torvalds .maxlen = sizeof (int), 22271da177e4SLinus Torvalds .mode = 0444, 22286d456111SEric W. Biederman .proc_handler = proc_dointvec, 22291da177e4SLinus Torvalds }, 223073efc039SDan Ballard { 223173efc039SDan Ballard .procname = "cap_last_cap", 223273efc039SDan Ballard .data = (void *)&cap_last_cap, 223373efc039SDan Ballard .maxlen = sizeof(int), 223473efc039SDan Ballard .mode = 0444, 223573efc039SDan Ballard .proc_handler = proc_dointvec, 223673efc039SDan Ballard }, 223758687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 2238504d7cf1SDon Zickus { 223958687acbSDon Zickus .procname = "watchdog", 22403c00ea82SFrederic Weisbecker .data = &watchdog_user_enabled, 2241504d7cf1SDon Zickus .maxlen = sizeof(int), 2242504d7cf1SDon Zickus .mode = 0644, 2243195daf66SUlrich Obergfell .proc_handler = proc_watchdog, 2244eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2245eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 224658687acbSDon Zickus }, 224758687acbSDon Zickus { 224858687acbSDon Zickus .procname = "watchdog_thresh", 2249586692a5SMandeep Singh Baines .data = &watchdog_thresh, 225058687acbSDon Zickus .maxlen = sizeof(int), 225158687acbSDon Zickus .mode = 0644, 2252195daf66SUlrich Obergfell .proc_handler = proc_watchdog_thresh, 2253eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 225458687acbSDon Zickus .extra2 = &sixty, 2255504d7cf1SDon Zickus }, 22562508ce18SDon Zickus { 2257195daf66SUlrich Obergfell .procname = "nmi_watchdog", 22587feeb9cdSThomas Gleixner .data = &nmi_watchdog_user_enabled, 2259195daf66SUlrich Obergfell .maxlen = sizeof(int), 226051d4052bSThomas Gleixner .mode = NMI_WATCHDOG_SYSCTL_PERM, 2261195daf66SUlrich Obergfell .proc_handler = proc_nmi_watchdog, 2262eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2263eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2264195daf66SUlrich Obergfell }, 2265195daf66SUlrich Obergfell { 226605a4a952SNicholas Piggin .procname = "watchdog_cpumask", 226705a4a952SNicholas Piggin .data = &watchdog_cpumask_bits, 226805a4a952SNicholas Piggin .maxlen = NR_CPUS, 226905a4a952SNicholas Piggin .mode = 0644, 227005a4a952SNicholas Piggin .proc_handler = proc_watchdog_cpumask, 227105a4a952SNicholas Piggin }, 227205a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR 227305a4a952SNicholas Piggin { 2274195daf66SUlrich Obergfell .procname = "soft_watchdog", 22757feeb9cdSThomas Gleixner .data = &soft_watchdog_user_enabled, 2276195daf66SUlrich Obergfell .maxlen = sizeof(int), 2277195daf66SUlrich Obergfell .mode = 0644, 2278195daf66SUlrich Obergfell .proc_handler = proc_soft_watchdog, 2279eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2280eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2281195daf66SUlrich Obergfell }, 2282195daf66SUlrich Obergfell { 22832508ce18SDon Zickus .procname = "softlockup_panic", 22842508ce18SDon Zickus .data = &softlockup_panic, 22852508ce18SDon Zickus .maxlen = sizeof(int), 22862508ce18SDon Zickus .mode = 0644, 22872508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 2288eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2289eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 22902508ce18SDon Zickus }, 2291ed235875SAaron Tomlin #ifdef CONFIG_SMP 2292ed235875SAaron Tomlin { 2293ed235875SAaron Tomlin .procname = "softlockup_all_cpu_backtrace", 2294ed235875SAaron Tomlin .data = &sysctl_softlockup_all_cpu_backtrace, 2295ed235875SAaron Tomlin .maxlen = sizeof(int), 2296ed235875SAaron Tomlin .mode = 0644, 2297ed235875SAaron Tomlin .proc_handler = proc_dointvec_minmax, 2298eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2299eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2300ed235875SAaron Tomlin }, 230105a4a952SNicholas Piggin #endif /* CONFIG_SMP */ 230205a4a952SNicholas Piggin #endif 230305a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR 230405a4a952SNicholas Piggin { 230505a4a952SNicholas Piggin .procname = "hardlockup_panic", 230605a4a952SNicholas Piggin .data = &hardlockup_panic, 230705a4a952SNicholas Piggin .maxlen = sizeof(int), 230805a4a952SNicholas Piggin .mode = 0644, 230905a4a952SNicholas Piggin .proc_handler = proc_dointvec_minmax, 2310eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2311eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 231205a4a952SNicholas Piggin }, 231305a4a952SNicholas Piggin #ifdef CONFIG_SMP 231455537871SJiri Kosina { 231555537871SJiri Kosina .procname = "hardlockup_all_cpu_backtrace", 231655537871SJiri Kosina .data = &sysctl_hardlockup_all_cpu_backtrace, 231755537871SJiri Kosina .maxlen = sizeof(int), 231855537871SJiri Kosina .mode = 0644, 231955537871SJiri Kosina .proc_handler = proc_dointvec_minmax, 2320eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2321eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 232255537871SJiri Kosina }, 2323ed235875SAaron Tomlin #endif /* CONFIG_SMP */ 23245dc30558SDon Zickus #endif 232505a4a952SNicholas Piggin #endif 232605a4a952SNicholas Piggin 23275dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 23285dc30558SDon Zickus { 23295dc30558SDon Zickus .procname = "unknown_nmi_panic", 23305dc30558SDon Zickus .data = &unknown_nmi_panic, 23315dc30558SDon Zickus .maxlen = sizeof (int), 23325dc30558SDon Zickus .mode = 0644, 23335dc30558SDon Zickus .proc_handler = proc_dointvec, 23345dc30558SDon Zickus }, 2335504d7cf1SDon Zickus #endif 23361da177e4SLinus Torvalds #if defined(CONFIG_X86) 23371da177e4SLinus Torvalds { 23388da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 23398da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 23408da5addaSDon Zickus .maxlen = sizeof(int), 23418da5addaSDon Zickus .mode = 0644, 23426d456111SEric W. Biederman .proc_handler = proc_dointvec, 23438da5addaSDon Zickus }, 23448da5addaSDon Zickus { 23455211a242SKurt Garloff .procname = "panic_on_io_nmi", 23465211a242SKurt Garloff .data = &panic_on_io_nmi, 23475211a242SKurt Garloff .maxlen = sizeof(int), 23485211a242SKurt Garloff .mode = 0644, 23496d456111SEric W. Biederman .proc_handler = proc_dointvec, 23505211a242SKurt Garloff }, 235155af7796SMitsuo Hayasaka #ifdef CONFIG_DEBUG_STACKOVERFLOW 235255af7796SMitsuo Hayasaka { 235355af7796SMitsuo Hayasaka .procname = "panic_on_stackoverflow", 235455af7796SMitsuo Hayasaka .data = &sysctl_panic_on_stackoverflow, 235555af7796SMitsuo Hayasaka .maxlen = sizeof(int), 235655af7796SMitsuo Hayasaka .mode = 0644, 235755af7796SMitsuo Hayasaka .proc_handler = proc_dointvec, 235855af7796SMitsuo Hayasaka }, 235955af7796SMitsuo Hayasaka #endif 23605211a242SKurt Garloff { 23611da177e4SLinus Torvalds .procname = "bootloader_type", 23621da177e4SLinus Torvalds .data = &bootloader_type, 23631da177e4SLinus Torvalds .maxlen = sizeof (int), 23641da177e4SLinus Torvalds .mode = 0444, 23656d456111SEric W. Biederman .proc_handler = proc_dointvec, 23661da177e4SLinus Torvalds }, 23670741f4d2SChuck Ebbert { 23685031296cSH. Peter Anvin .procname = "bootloader_version", 23695031296cSH. Peter Anvin .data = &bootloader_version, 23705031296cSH. Peter Anvin .maxlen = sizeof (int), 23715031296cSH. Peter Anvin .mode = 0444, 23726d456111SEric W. Biederman .proc_handler = proc_dointvec, 23735031296cSH. Peter Anvin }, 23745031296cSH. Peter Anvin { 23756e7c4025SIngo Molnar .procname = "io_delay_type", 23766e7c4025SIngo Molnar .data = &io_delay_type, 23776e7c4025SIngo Molnar .maxlen = sizeof(int), 23786e7c4025SIngo Molnar .mode = 0644, 23796d456111SEric W. Biederman .proc_handler = proc_dointvec, 23806e7c4025SIngo Molnar }, 23811da177e4SLinus Torvalds #endif 23827a9166e3SLuke Yang #if defined(CONFIG_MMU) 23831da177e4SLinus Torvalds { 23841da177e4SLinus Torvalds .procname = "randomize_va_space", 23851da177e4SLinus Torvalds .data = &randomize_va_space, 23861da177e4SLinus Torvalds .maxlen = sizeof(int), 23871da177e4SLinus Torvalds .mode = 0644, 23886d456111SEric W. Biederman .proc_handler = proc_dointvec, 23891da177e4SLinus Torvalds }, 23907a9166e3SLuke Yang #endif 23910152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 2392951f22d5SMartin Schwidefsky { 2393951f22d5SMartin Schwidefsky .procname = "spin_retry", 2394951f22d5SMartin Schwidefsky .data = &spin_retry, 2395951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 2396951f22d5SMartin Schwidefsky .mode = 0644, 23976d456111SEric W. Biederman .proc_handler = proc_dointvec, 2398951f22d5SMartin Schwidefsky }, 2399951f22d5SMartin Schwidefsky #endif 2400673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 2401c255d844SPavel Machek { 2402c255d844SPavel Machek .procname = "acpi_video_flags", 240377afcf78SPavel Machek .data = &acpi_realmode_flags, 2404c255d844SPavel Machek .maxlen = sizeof (unsigned long), 2405c255d844SPavel Machek .mode = 0644, 24066d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 2407c255d844SPavel Machek }, 2408c255d844SPavel Machek #endif 2409b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN 2410d2b176edSJes Sorensen { 2411d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 2412d2b176edSJes Sorensen .data = &no_unaligned_warning, 2413d2b176edSJes Sorensen .maxlen = sizeof (int), 2414d2b176edSJes Sorensen .mode = 0644, 24156d456111SEric W. Biederman .proc_handler = proc_dointvec, 2416d2b176edSJes Sorensen }, 2417b6fca725SVineet Gupta #endif 2418b6fca725SVineet Gupta #ifdef CONFIG_IA64 241988fc241fSDoug Chapman { 242088fc241fSDoug Chapman .procname = "unaligned-dump-stack", 242188fc241fSDoug Chapman .data = &unaligned_dump_stack, 242288fc241fSDoug Chapman .maxlen = sizeof (int), 242388fc241fSDoug Chapman .mode = 0644, 24246d456111SEric W. Biederman .proc_handler = proc_dointvec, 242588fc241fSDoug Chapman }, 2426d2b176edSJes Sorensen #endif 2427e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 2428e162b39aSMandeep Singh Baines { 2429e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 2430e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 2431e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 2432e162b39aSMandeep Singh Baines .mode = 0644, 24336d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2434eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2435eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2436e162b39aSMandeep Singh Baines }, 243782a1fcb9SIngo Molnar { 243882a1fcb9SIngo Molnar .procname = "hung_task_check_count", 243982a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 2440cd64647fSLi Zefan .maxlen = sizeof(int), 244182a1fcb9SIngo Molnar .mode = 0644, 2442cd64647fSLi Zefan .proc_handler = proc_dointvec_minmax, 2443eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 244482a1fcb9SIngo Molnar }, 244582a1fcb9SIngo Molnar { 244682a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 244782a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 244890739081SIngo Molnar .maxlen = sizeof(unsigned long), 244982a1fcb9SIngo Molnar .mode = 0644, 24506d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 245180df2847SLiu Hua .extra2 = &hung_task_timeout_max, 245282a1fcb9SIngo Molnar }, 245382a1fcb9SIngo Molnar { 2454a2e51445SDmitry Vyukov .procname = "hung_task_check_interval_secs", 2455a2e51445SDmitry Vyukov .data = &sysctl_hung_task_check_interval_secs, 2456a2e51445SDmitry Vyukov .maxlen = sizeof(unsigned long), 2457a2e51445SDmitry Vyukov .mode = 0644, 2458a2e51445SDmitry Vyukov .proc_handler = proc_dohung_task_timeout_secs, 2459a2e51445SDmitry Vyukov .extra2 = &hung_task_timeout_max, 2460a2e51445SDmitry Vyukov }, 2461a2e51445SDmitry Vyukov { 246282a1fcb9SIngo Molnar .procname = "hung_task_warnings", 246382a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 2464270750dbSAaron Tomlin .maxlen = sizeof(int), 246582a1fcb9SIngo Molnar .mode = 0644, 2466270750dbSAaron Tomlin .proc_handler = proc_dointvec_minmax, 2467270750dbSAaron Tomlin .extra1 = &neg_one, 246882a1fcb9SIngo Molnar }, 2469c4f3b63fSRavikiran G Thirumalai #endif 247023f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 247123f78d4aSIngo Molnar { 247223f78d4aSIngo Molnar .procname = "max_lock_depth", 247323f78d4aSIngo Molnar .data = &max_lock_depth, 247423f78d4aSIngo Molnar .maxlen = sizeof(int), 247523f78d4aSIngo Molnar .mode = 0644, 24766d456111SEric W. Biederman .proc_handler = proc_dointvec, 247723f78d4aSIngo Molnar }, 247823f78d4aSIngo Molnar #endif 247910a0a8d4SJeremy Fitzhardinge { 248010a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 248110a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 248210a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 248310a0a8d4SJeremy Fitzhardinge .mode = 0644, 24846d456111SEric W. Biederman .proc_handler = proc_dostring, 248510a0a8d4SJeremy Fitzhardinge }, 24860b77f5bfSDavid Howells #ifdef CONFIG_KEYS 24870b77f5bfSDavid Howells { 24880b77f5bfSDavid Howells .procname = "keys", 24890b77f5bfSDavid Howells .mode = 0555, 24900b77f5bfSDavid Howells .child = key_sysctls, 24910b77f5bfSDavid Howells }, 24920b77f5bfSDavid Howells #endif 2493cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 2494aa4a2218SVince Weaver /* 2495aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 2496aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 2497aa4a2218SVince Weaver * 2498aa4a2218SVince Weaver * So it's an ABI, do not remove! 2499aa4a2218SVince Weaver */ 25001ccd1549SPeter Zijlstra { 2501cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 2502cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 2503cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 25041ccd1549SPeter Zijlstra .mode = 0644, 25056d456111SEric W. Biederman .proc_handler = proc_dointvec, 25061ccd1549SPeter Zijlstra }, 2507c5078f78SPeter Zijlstra { 2508cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 2509cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 2510cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 2511c5078f78SPeter Zijlstra .mode = 0644, 25126d456111SEric W. Biederman .proc_handler = proc_dointvec, 2513c5078f78SPeter Zijlstra }, 2514a78ac325SPeter Zijlstra { 2515cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 2516cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 2517cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 2518a78ac325SPeter Zijlstra .mode = 0644, 2519163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 2520eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2521a78ac325SPeter Zijlstra }, 252214c63f17SDave Hansen { 252314c63f17SDave Hansen .procname = "perf_cpu_time_max_percent", 252414c63f17SDave Hansen .data = &sysctl_perf_cpu_time_max_percent, 252514c63f17SDave Hansen .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), 252614c63f17SDave Hansen .mode = 0644, 252714c63f17SDave Hansen .proc_handler = perf_cpu_time_max_percent_handler, 2528eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 252914c63f17SDave Hansen .extra2 = &one_hundred, 253014c63f17SDave Hansen }, 2531c5dfd78eSArnaldo Carvalho de Melo { 2532c5dfd78eSArnaldo Carvalho de Melo .procname = "perf_event_max_stack", 2533a831100aSArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_stack, 2534c5dfd78eSArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_stack), 2535c5dfd78eSArnaldo Carvalho de Melo .mode = 0644, 2536c5dfd78eSArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2537eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2538c5dfd78eSArnaldo Carvalho de Melo .extra2 = &six_hundred_forty_kb, 2539c5dfd78eSArnaldo Carvalho de Melo }, 2540c85b0334SArnaldo Carvalho de Melo { 2541c85b0334SArnaldo Carvalho de Melo .procname = "perf_event_max_contexts_per_stack", 2542c85b0334SArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_contexts_per_stack, 2543c85b0334SArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), 2544c85b0334SArnaldo Carvalho de Melo .mode = 0644, 2545c85b0334SArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2546eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2547c85b0334SArnaldo Carvalho de Melo .extra2 = &one_thousand, 2548c85b0334SArnaldo Carvalho de Melo }, 25491ccd1549SPeter Zijlstra #endif 25509e3961a0SPrarit Bhargava { 25519e3961a0SPrarit Bhargava .procname = "panic_on_warn", 25529e3961a0SPrarit Bhargava .data = &panic_on_warn, 25539e3961a0SPrarit Bhargava .maxlen = sizeof(int), 25549e3961a0SPrarit Bhargava .mode = 0644, 25559e3961a0SPrarit Bhargava .proc_handler = proc_dointvec_minmax, 2556eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2557eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 25589e3961a0SPrarit Bhargava }, 2559bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 2560bc7a34b8SThomas Gleixner { 2561bc7a34b8SThomas Gleixner .procname = "timer_migration", 2562bc7a34b8SThomas Gleixner .data = &sysctl_timer_migration, 2563bc7a34b8SThomas Gleixner .maxlen = sizeof(unsigned int), 2564bc7a34b8SThomas Gleixner .mode = 0644, 2565bc7a34b8SThomas Gleixner .proc_handler = timer_migration_handler, 2566eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2567eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2568bc7a34b8SThomas Gleixner }, 2569bc7a34b8SThomas Gleixner #endif 25701be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL 25711be7f75dSAlexei Starovoitov { 25721be7f75dSAlexei Starovoitov .procname = "unprivileged_bpf_disabled", 25731be7f75dSAlexei Starovoitov .data = &sysctl_unprivileged_bpf_disabled, 25741be7f75dSAlexei Starovoitov .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), 25751be7f75dSAlexei Starovoitov .mode = 0644, 25761be7f75dSAlexei Starovoitov /* only handle a transition from default "0" to "1" */ 25771be7f75dSAlexei Starovoitov .proc_handler = proc_dointvec_minmax, 2578eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2579eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 25801be7f75dSAlexei Starovoitov }, 2581492ecee8SAlexei Starovoitov { 2582492ecee8SAlexei Starovoitov .procname = "bpf_stats_enabled", 2583a8e11e5cSEric Dumazet .data = &bpf_stats_enabled_key.key, 2584a8e11e5cSEric Dumazet .maxlen = sizeof(bpf_stats_enabled_key), 2585492ecee8SAlexei Starovoitov .mode = 0644, 2586*d46edd67SSong Liu .proc_handler = bpf_stats_handler, 2587492ecee8SAlexei Starovoitov }, 25883fcc5530SAlexei Starovoitov #endif 2589b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU) 2590088e9d25SDaniel Bristot de Oliveira { 2591088e9d25SDaniel Bristot de Oliveira .procname = "panic_on_rcu_stall", 2592088e9d25SDaniel Bristot de Oliveira .data = &sysctl_panic_on_rcu_stall, 2593088e9d25SDaniel Bristot de Oliveira .maxlen = sizeof(sysctl_panic_on_rcu_stall), 2594088e9d25SDaniel Bristot de Oliveira .mode = 0644, 2595088e9d25SDaniel Bristot de Oliveira .proc_handler = proc_dointvec_minmax, 2596eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2597eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2598088e9d25SDaniel Bristot de Oliveira }, 2599088e9d25SDaniel Bristot de Oliveira #endif 2600964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 2601964c9dffSAlexander Popov { 2602964c9dffSAlexander Popov .procname = "stack_erasing", 2603964c9dffSAlexander Popov .data = NULL, 2604964c9dffSAlexander Popov .maxlen = sizeof(int), 2605964c9dffSAlexander Popov .mode = 0600, 2606964c9dffSAlexander Popov .proc_handler = stack_erasing_sysctl, 2607eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2608eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2609964c9dffSAlexander Popov }, 2610964c9dffSAlexander Popov #endif 26116fce56ecSEric W. Biederman { } 26121da177e4SLinus Torvalds }; 26131da177e4SLinus Torvalds 2614d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 26151da177e4SLinus Torvalds { 26161da177e4SLinus Torvalds .procname = "overcommit_memory", 26171da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 26181da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 26191da177e4SLinus Torvalds .mode = 0644, 2620cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2621eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2622cb16e95fSPetr Holasek .extra2 = &two, 26231da177e4SLinus Torvalds }, 26241da177e4SLinus Torvalds { 2625fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 2626fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 2627fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 2628fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 2629cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2630eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2631cb16e95fSPetr Holasek .extra2 = &two, 2632fadd8fbdSKAMEZAWA Hiroyuki }, 2633fadd8fbdSKAMEZAWA Hiroyuki { 2634fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 2635fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 2636fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 2637fe071d7eSDavid Rientjes .mode = 0644, 26386d456111SEric W. Biederman .proc_handler = proc_dointvec, 2639fe071d7eSDavid Rientjes }, 2640fe071d7eSDavid Rientjes { 2641fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 2642fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 2643fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 2644fef1bdd6SDavid Rientjes .mode = 0644, 26456d456111SEric W. Biederman .proc_handler = proc_dointvec, 2646fef1bdd6SDavid Rientjes }, 2647fef1bdd6SDavid Rientjes { 26481da177e4SLinus Torvalds .procname = "overcommit_ratio", 26491da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 26501da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 26511da177e4SLinus Torvalds .mode = 0644, 265249f0ce5fSJerome Marchand .proc_handler = overcommit_ratio_handler, 265349f0ce5fSJerome Marchand }, 265449f0ce5fSJerome Marchand { 265549f0ce5fSJerome Marchand .procname = "overcommit_kbytes", 265649f0ce5fSJerome Marchand .data = &sysctl_overcommit_kbytes, 265749f0ce5fSJerome Marchand .maxlen = sizeof(sysctl_overcommit_kbytes), 265849f0ce5fSJerome Marchand .mode = 0644, 265949f0ce5fSJerome Marchand .proc_handler = overcommit_kbytes_handler, 26601da177e4SLinus Torvalds }, 26611da177e4SLinus Torvalds { 26621da177e4SLinus Torvalds .procname = "page-cluster", 26631da177e4SLinus Torvalds .data = &page_cluster, 26641da177e4SLinus Torvalds .maxlen = sizeof(int), 26651da177e4SLinus Torvalds .mode = 0644, 2666cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2667eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 26681da177e4SLinus Torvalds }, 26691da177e4SLinus Torvalds { 26701da177e4SLinus Torvalds .procname = "dirty_background_ratio", 26711da177e4SLinus Torvalds .data = &dirty_background_ratio, 26721da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 26731da177e4SLinus Torvalds .mode = 0644, 26746d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 2675eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 26761da177e4SLinus Torvalds .extra2 = &one_hundred, 26771da177e4SLinus Torvalds }, 26781da177e4SLinus Torvalds { 26792da02997SDavid Rientjes .procname = "dirty_background_bytes", 26802da02997SDavid Rientjes .data = &dirty_background_bytes, 26812da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 26822da02997SDavid Rientjes .mode = 0644, 26836d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 2684fc3501d4SSven Wegener .extra1 = &one_ul, 26852da02997SDavid Rientjes }, 26862da02997SDavid Rientjes { 26871da177e4SLinus Torvalds .procname = "dirty_ratio", 26881da177e4SLinus Torvalds .data = &vm_dirty_ratio, 26891da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 26901da177e4SLinus Torvalds .mode = 0644, 26916d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 2692eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 26931da177e4SLinus Torvalds .extra2 = &one_hundred, 26941da177e4SLinus Torvalds }, 26951da177e4SLinus Torvalds { 26962da02997SDavid Rientjes .procname = "dirty_bytes", 26972da02997SDavid Rientjes .data = &vm_dirty_bytes, 26982da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 26992da02997SDavid Rientjes .mode = 0644, 27006d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 27019e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 27022da02997SDavid Rientjes }, 27032da02997SDavid Rientjes { 27041da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 2705f6ef9438SBart Samwel .data = &dirty_writeback_interval, 2706f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 27071da177e4SLinus Torvalds .mode = 0644, 27086d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 27091da177e4SLinus Torvalds }, 27101da177e4SLinus Torvalds { 27111da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 2712f6ef9438SBart Samwel .data = &dirty_expire_interval, 2713f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 27141da177e4SLinus Torvalds .mode = 0644, 2715cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2716eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27171da177e4SLinus Torvalds }, 27181da177e4SLinus Torvalds { 27191efff914STheodore Ts'o .procname = "dirtytime_expire_seconds", 27201efff914STheodore Ts'o .data = &dirtytime_expire_interval, 27212d87b309SRandy Dunlap .maxlen = sizeof(dirtytime_expire_interval), 27221efff914STheodore Ts'o .mode = 0644, 27231efff914STheodore Ts'o .proc_handler = dirtytime_interval_handler, 2724eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27251efff914STheodore Ts'o }, 27261efff914STheodore Ts'o { 27271da177e4SLinus Torvalds .procname = "swappiness", 27281da177e4SLinus Torvalds .data = &vm_swappiness, 27291da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 27301da177e4SLinus Torvalds .mode = 0644, 27316d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2732eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27331da177e4SLinus Torvalds .extra2 = &one_hundred, 27341da177e4SLinus Torvalds }, 27351da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 27361da177e4SLinus Torvalds { 27371da177e4SLinus Torvalds .procname = "nr_hugepages", 2738e5ff2159SAndi Kleen .data = NULL, 27391da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 27401da177e4SLinus Torvalds .mode = 0644, 27416d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 27421da177e4SLinus Torvalds }, 274306808b08SLee Schermerhorn #ifdef CONFIG_NUMA 274406808b08SLee Schermerhorn { 274506808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 274606808b08SLee Schermerhorn .data = NULL, 274706808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 274806808b08SLee Schermerhorn .mode = 0644, 274906808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 275006808b08SLee Schermerhorn }, 27514518085eSKemi Wang { 27524518085eSKemi Wang .procname = "numa_stat", 27534518085eSKemi Wang .data = &sysctl_vm_numa_stat, 27544518085eSKemi Wang .maxlen = sizeof(int), 27554518085eSKemi Wang .mode = 0644, 27564518085eSKemi Wang .proc_handler = sysctl_vm_numa_stat_handler, 2757eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2758eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 27594518085eSKemi Wang }, 276006808b08SLee Schermerhorn #endif 27611da177e4SLinus Torvalds { 27621da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 27631da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 27641da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 27651da177e4SLinus Torvalds .mode = 0644, 27666d456111SEric W. Biederman .proc_handler = proc_dointvec, 27671da177e4SLinus Torvalds }, 2768396faf03SMel Gorman { 2769d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 2770e5ff2159SAndi Kleen .data = NULL, 2771e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 2772d1c3fb1fSNishanth Aravamudan .mode = 0644, 27736d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 2774d1c3fb1fSNishanth Aravamudan }, 27751da177e4SLinus Torvalds #endif 27761da177e4SLinus Torvalds { 27771da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 27781da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 27791da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 27801da177e4SLinus Torvalds .mode = 0644, 27816d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 27821da177e4SLinus Torvalds }, 27831da177e4SLinus Torvalds { 27849d0243bcSAndrew Morton .procname = "drop_caches", 27859d0243bcSAndrew Morton .data = &sysctl_drop_caches, 27869d0243bcSAndrew Morton .maxlen = sizeof(int), 2787204cb79aSJohannes Weiner .mode = 0200, 27889d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 2789eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 27905509a5d2SDave Hansen .extra2 = &four, 27919d0243bcSAndrew Morton }, 279276ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 279376ab0f53SMel Gorman { 279476ab0f53SMel Gorman .procname = "compact_memory", 279576ab0f53SMel Gorman .data = &sysctl_compact_memory, 279676ab0f53SMel Gorman .maxlen = sizeof(int), 279776ab0f53SMel Gorman .mode = 0200, 279876ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 279976ab0f53SMel Gorman }, 28005e771905SMel Gorman { 28015e771905SMel Gorman .procname = "extfrag_threshold", 28025e771905SMel Gorman .data = &sysctl_extfrag_threshold, 28035e771905SMel Gorman .maxlen = sizeof(int), 28045e771905SMel Gorman .mode = 0644, 28056b7e5cadSMatthew Wilcox .proc_handler = proc_dointvec_minmax, 28065e771905SMel Gorman .extra1 = &min_extfrag_threshold, 28075e771905SMel Gorman .extra2 = &max_extfrag_threshold, 28085e771905SMel Gorman }, 28095bbe3547SEric B Munson { 28105bbe3547SEric B Munson .procname = "compact_unevictable_allowed", 28115bbe3547SEric B Munson .data = &sysctl_compact_unevictable_allowed, 28125bbe3547SEric B Munson .maxlen = sizeof(int), 28135bbe3547SEric B Munson .mode = 0644, 28146923aa0dSSebastian Andrzej Siewior .proc_handler = proc_dointvec_minmax_warn_RT_change, 2815eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2816eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 28175bbe3547SEric B Munson }, 28185e771905SMel Gorman 281976ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 28209d0243bcSAndrew Morton { 28211da177e4SLinus Torvalds .procname = "min_free_kbytes", 28221da177e4SLinus Torvalds .data = &min_free_kbytes, 28231da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 28241da177e4SLinus Torvalds .mode = 0644, 28256d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 2826eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28271da177e4SLinus Torvalds }, 28288ad4b1fbSRohit Seth { 28291c30844dSMel Gorman .procname = "watermark_boost_factor", 28301c30844dSMel Gorman .data = &watermark_boost_factor, 28311c30844dSMel Gorman .maxlen = sizeof(watermark_boost_factor), 28321c30844dSMel Gorman .mode = 0644, 283326363af5SChristoph Hellwig .proc_handler = proc_dointvec_minmax, 2834eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28351c30844dSMel Gorman }, 28361c30844dSMel Gorman { 2837795ae7a0SJohannes Weiner .procname = "watermark_scale_factor", 2838795ae7a0SJohannes Weiner .data = &watermark_scale_factor, 2839795ae7a0SJohannes Weiner .maxlen = sizeof(watermark_scale_factor), 2840795ae7a0SJohannes Weiner .mode = 0644, 2841795ae7a0SJohannes Weiner .proc_handler = watermark_scale_factor_sysctl_handler, 2842eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2843795ae7a0SJohannes Weiner .extra2 = &one_thousand, 2844795ae7a0SJohannes Weiner }, 2845795ae7a0SJohannes Weiner { 28468ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 28478ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 28488ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 28498ad4b1fbSRohit Seth .mode = 0644, 28506d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 2851eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28528ad4b1fbSRohit Seth }, 28531da177e4SLinus Torvalds #ifdef CONFIG_MMU 28541da177e4SLinus Torvalds { 28551da177e4SLinus Torvalds .procname = "max_map_count", 28561da177e4SLinus Torvalds .data = &sysctl_max_map_count, 28571da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 28581da177e4SLinus Torvalds .mode = 0644, 28593e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 2860eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28611da177e4SLinus Torvalds }, 2862dd8632a1SPaul Mundt #else 2863dd8632a1SPaul Mundt { 2864dd8632a1SPaul Mundt .procname = "nr_trim_pages", 2865dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 2866dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 2867dd8632a1SPaul Mundt .mode = 0644, 28686d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2869eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2870dd8632a1SPaul Mundt }, 28711da177e4SLinus Torvalds #endif 28721da177e4SLinus Torvalds { 28731da177e4SLinus Torvalds .procname = "laptop_mode", 28741da177e4SLinus Torvalds .data = &laptop_mode, 28751da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 28761da177e4SLinus Torvalds .mode = 0644, 28776d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 28781da177e4SLinus Torvalds }, 28791da177e4SLinus Torvalds { 28801da177e4SLinus Torvalds .procname = "block_dump", 28811da177e4SLinus Torvalds .data = &block_dump, 28821da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 28831da177e4SLinus Torvalds .mode = 0644, 28846d456111SEric W. Biederman .proc_handler = proc_dointvec, 2885eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28861da177e4SLinus Torvalds }, 28871da177e4SLinus Torvalds { 28881da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 28891da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 28901da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 28911da177e4SLinus Torvalds .mode = 0644, 28926d456111SEric W. Biederman .proc_handler = proc_dointvec, 2893eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28941da177e4SLinus Torvalds }, 289567f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 289667f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 28971da177e4SLinus Torvalds { 28981da177e4SLinus Torvalds .procname = "legacy_va_layout", 28991da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 29001da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 29011da177e4SLinus Torvalds .mode = 0644, 29026d456111SEric W. Biederman .proc_handler = proc_dointvec, 2903eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29041da177e4SLinus Torvalds }, 29051da177e4SLinus Torvalds #endif 29061743660bSChristoph Lameter #ifdef CONFIG_NUMA 29071743660bSChristoph Lameter { 29081743660bSChristoph Lameter .procname = "zone_reclaim_mode", 2909a5f5f91dSMel Gorman .data = &node_reclaim_mode, 2910a5f5f91dSMel Gorman .maxlen = sizeof(node_reclaim_mode), 29111743660bSChristoph Lameter .mode = 0644, 29126d456111SEric W. Biederman .proc_handler = proc_dointvec, 2913eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29141743660bSChristoph Lameter }, 29159614634fSChristoph Lameter { 29169614634fSChristoph Lameter .procname = "min_unmapped_ratio", 29179614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 29189614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 29199614634fSChristoph Lameter .mode = 0644, 29206d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 2921eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29229614634fSChristoph Lameter .extra2 = &one_hundred, 29239614634fSChristoph Lameter }, 29240ff38490SChristoph Lameter { 29250ff38490SChristoph Lameter .procname = "min_slab_ratio", 29260ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 29270ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 29280ff38490SChristoph Lameter .mode = 0644, 29296d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 2930eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29310ff38490SChristoph Lameter .extra2 = &one_hundred, 29320ff38490SChristoph Lameter }, 29331743660bSChristoph Lameter #endif 293477461ab3SChristoph Lameter #ifdef CONFIG_SMP 293577461ab3SChristoph Lameter { 293677461ab3SChristoph Lameter .procname = "stat_interval", 293777461ab3SChristoph Lameter .data = &sysctl_stat_interval, 293877461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 293977461ab3SChristoph Lameter .mode = 0644, 29406d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 294177461ab3SChristoph Lameter }, 294252b6f46bSHugh Dickins { 294352b6f46bSHugh Dickins .procname = "stat_refresh", 294452b6f46bSHugh Dickins .data = NULL, 294552b6f46bSHugh Dickins .maxlen = 0, 294652b6f46bSHugh Dickins .mode = 0600, 294752b6f46bSHugh Dickins .proc_handler = vmstat_refresh, 294852b6f46bSHugh Dickins }, 294977461ab3SChristoph Lameter #endif 29506e141546SDavid Howells #ifdef CONFIG_MMU 2951ed032189SEric Paris { 2952ed032189SEric Paris .procname = "mmap_min_addr", 2953788084abSEric Paris .data = &dac_mmap_min_addr, 2954ed032189SEric Paris .maxlen = sizeof(unsigned long), 2955ed032189SEric Paris .mode = 0644, 29566d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 2957ed032189SEric Paris }, 29586e141546SDavid Howells #endif 2959f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 2960f0c0b2b8SKAMEZAWA Hiroyuki { 2961f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 2962f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 2963f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 2964f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 29656d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 2966f0c0b2b8SKAMEZAWA Hiroyuki }, 2967f0c0b2b8SKAMEZAWA Hiroyuki #endif 29682b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 29695c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 2970e6e5494cSIngo Molnar { 2971e6e5494cSIngo Molnar .procname = "vdso_enabled", 29723d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32 29733d7ee969SAndy Lutomirski .data = &vdso32_enabled, 29743d7ee969SAndy Lutomirski .maxlen = sizeof(vdso32_enabled), 29753d7ee969SAndy Lutomirski #else 2976e6e5494cSIngo Molnar .data = &vdso_enabled, 2977e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 29783d7ee969SAndy Lutomirski #endif 2979e6e5494cSIngo Molnar .mode = 0644, 29806d456111SEric W. Biederman .proc_handler = proc_dointvec, 2981eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2982e6e5494cSIngo Molnar }, 2983e6e5494cSIngo Molnar #endif 2984195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 2985195cf453SBron Gondwana { 2986195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 2987195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 2988195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 2989195cf453SBron Gondwana .mode = 0644, 29906d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2991eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2992eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2993195cf453SBron Gondwana }, 2994195cf453SBron Gondwana #endif 29956a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 29966a46079cSAndi Kleen { 29976a46079cSAndi Kleen .procname = "memory_failure_early_kill", 29986a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 29996a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 30006a46079cSAndi Kleen .mode = 0644, 30016d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3002eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3003eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 30046a46079cSAndi Kleen }, 30056a46079cSAndi Kleen { 30066a46079cSAndi Kleen .procname = "memory_failure_recovery", 30076a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 30086a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 30096a46079cSAndi Kleen .mode = 0644, 30106d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3011eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3012eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 30136a46079cSAndi Kleen }, 30146a46079cSAndi Kleen #endif 3015c9b1d098SAndrew Shewmaker { 3016c9b1d098SAndrew Shewmaker .procname = "user_reserve_kbytes", 3017c9b1d098SAndrew Shewmaker .data = &sysctl_user_reserve_kbytes, 3018c9b1d098SAndrew Shewmaker .maxlen = sizeof(sysctl_user_reserve_kbytes), 3019c9b1d098SAndrew Shewmaker .mode = 0644, 3020c9b1d098SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 3021c9b1d098SAndrew Shewmaker }, 30224eeab4f5SAndrew Shewmaker { 30234eeab4f5SAndrew Shewmaker .procname = "admin_reserve_kbytes", 30244eeab4f5SAndrew Shewmaker .data = &sysctl_admin_reserve_kbytes, 30254eeab4f5SAndrew Shewmaker .maxlen = sizeof(sysctl_admin_reserve_kbytes), 30264eeab4f5SAndrew Shewmaker .mode = 0644, 30274eeab4f5SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 30284eeab4f5SAndrew Shewmaker }, 3029d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS 3030d07e2259SDaniel Cashman { 3031d07e2259SDaniel Cashman .procname = "mmap_rnd_bits", 3032d07e2259SDaniel Cashman .data = &mmap_rnd_bits, 3033d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_bits), 3034d07e2259SDaniel Cashman .mode = 0600, 3035d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3036d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_bits_min, 3037d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_bits_max, 3038d07e2259SDaniel Cashman }, 3039d07e2259SDaniel Cashman #endif 3040d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS 3041d07e2259SDaniel Cashman { 3042d07e2259SDaniel Cashman .procname = "mmap_rnd_compat_bits", 3043d07e2259SDaniel Cashman .data = &mmap_rnd_compat_bits, 3044d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_compat_bits), 3045d07e2259SDaniel Cashman .mode = 0600, 3046d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3047d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_compat_bits_min, 3048d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_compat_bits_max, 3049d07e2259SDaniel Cashman }, 3050d07e2259SDaniel Cashman #endif 3051cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD 3052cefdca0aSPeter Xu { 3053cefdca0aSPeter Xu .procname = "unprivileged_userfaultfd", 3054cefdca0aSPeter Xu .data = &sysctl_unprivileged_userfaultfd, 3055cefdca0aSPeter Xu .maxlen = sizeof(sysctl_unprivileged_userfaultfd), 3056cefdca0aSPeter Xu .mode = 0644, 3057cefdca0aSPeter Xu .proc_handler = proc_dointvec_minmax, 3058eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3059eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3060cefdca0aSPeter Xu }, 3061cefdca0aSPeter Xu #endif 30626fce56ecSEric W. Biederman { } 30631da177e4SLinus Torvalds }; 30641da177e4SLinus Torvalds 3065d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 30661da177e4SLinus Torvalds { 30671da177e4SLinus Torvalds .procname = "inode-nr", 30681da177e4SLinus Torvalds .data = &inodes_stat, 30693942c07cSGlauber Costa .maxlen = 2*sizeof(long), 30701da177e4SLinus Torvalds .mode = 0444, 3071cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 30721da177e4SLinus Torvalds }, 30731da177e4SLinus Torvalds { 30741da177e4SLinus Torvalds .procname = "inode-state", 30751da177e4SLinus Torvalds .data = &inodes_stat, 30763942c07cSGlauber Costa .maxlen = 7*sizeof(long), 30771da177e4SLinus Torvalds .mode = 0444, 3078cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 30791da177e4SLinus Torvalds }, 30801da177e4SLinus Torvalds { 30811da177e4SLinus Torvalds .procname = "file-nr", 30821da177e4SLinus Torvalds .data = &files_stat, 3083518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 30841da177e4SLinus Torvalds .mode = 0444, 30856d456111SEric W. Biederman .proc_handler = proc_nr_files, 30861da177e4SLinus Torvalds }, 30871da177e4SLinus Torvalds { 30881da177e4SLinus Torvalds .procname = "file-max", 30891da177e4SLinus Torvalds .data = &files_stat.max_files, 3090518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 30911da177e4SLinus Torvalds .mode = 0644, 3092518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 30939002b214SWill Deacon .extra1 = &zero_ul, 309432a5ad9cSChristian Brauner .extra2 = &long_max, 30951da177e4SLinus Torvalds }, 30961da177e4SLinus Torvalds { 30979cfe015aSEric Dumazet .procname = "nr_open", 30989cfe015aSEric Dumazet .data = &sysctl_nr_open, 30999b80a184SAlexey Dobriyan .maxlen = sizeof(unsigned int), 31009cfe015aSEric Dumazet .mode = 0644, 31016d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3102eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 3103eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 31049cfe015aSEric Dumazet }, 31059cfe015aSEric Dumazet { 31061da177e4SLinus Torvalds .procname = "dentry-state", 31071da177e4SLinus Torvalds .data = &dentry_stat, 31083942c07cSGlauber Costa .maxlen = 6*sizeof(long), 31091da177e4SLinus Torvalds .mode = 0444, 3110312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 31111da177e4SLinus Torvalds }, 31121da177e4SLinus Torvalds { 31131da177e4SLinus Torvalds .procname = "overflowuid", 31141da177e4SLinus Torvalds .data = &fs_overflowuid, 31151da177e4SLinus Torvalds .maxlen = sizeof(int), 31161da177e4SLinus Torvalds .mode = 0644, 31176d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 31181da177e4SLinus Torvalds .extra1 = &minolduid, 31191da177e4SLinus Torvalds .extra2 = &maxolduid, 31201da177e4SLinus Torvalds }, 31211da177e4SLinus Torvalds { 31221da177e4SLinus Torvalds .procname = "overflowgid", 31231da177e4SLinus Torvalds .data = &fs_overflowgid, 31241da177e4SLinus Torvalds .maxlen = sizeof(int), 31251da177e4SLinus Torvalds .mode = 0644, 31266d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 31271da177e4SLinus Torvalds .extra1 = &minolduid, 31281da177e4SLinus Torvalds .extra2 = &maxolduid, 31291da177e4SLinus Torvalds }, 3130bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 31311da177e4SLinus Torvalds { 31321da177e4SLinus Torvalds .procname = "leases-enable", 31331da177e4SLinus Torvalds .data = &leases_enable, 31341da177e4SLinus Torvalds .maxlen = sizeof(int), 31351da177e4SLinus Torvalds .mode = 0644, 31366d456111SEric W. Biederman .proc_handler = proc_dointvec, 31371da177e4SLinus Torvalds }, 3138bfcd17a6SThomas Petazzoni #endif 31391da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 31401da177e4SLinus Torvalds { 31411da177e4SLinus Torvalds .procname = "dir-notify-enable", 31421da177e4SLinus Torvalds .data = &dir_notify_enable, 31431da177e4SLinus Torvalds .maxlen = sizeof(int), 31441da177e4SLinus Torvalds .mode = 0644, 31456d456111SEric W. Biederman .proc_handler = proc_dointvec, 31461da177e4SLinus Torvalds }, 31471da177e4SLinus Torvalds #endif 31481da177e4SLinus Torvalds #ifdef CONFIG_MMU 3149bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 31501da177e4SLinus Torvalds { 31511da177e4SLinus Torvalds .procname = "lease-break-time", 31521da177e4SLinus Torvalds .data = &lease_break_time, 31531da177e4SLinus Torvalds .maxlen = sizeof(int), 31541da177e4SLinus Torvalds .mode = 0644, 31556d456111SEric W. Biederman .proc_handler = proc_dointvec, 31561da177e4SLinus Torvalds }, 3157bfcd17a6SThomas Petazzoni #endif 3158ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 31591da177e4SLinus Torvalds { 31601da177e4SLinus Torvalds .procname = "aio-nr", 31611da177e4SLinus Torvalds .data = &aio_nr, 31621da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 31631da177e4SLinus Torvalds .mode = 0444, 31646d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 31651da177e4SLinus Torvalds }, 31661da177e4SLinus Torvalds { 31671da177e4SLinus Torvalds .procname = "aio-max-nr", 31681da177e4SLinus Torvalds .data = &aio_max_nr, 31691da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 31701da177e4SLinus Torvalds .mode = 0644, 31716d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 31721da177e4SLinus Torvalds }, 3173ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 31742d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 31750399cb08SRobert Love { 31760399cb08SRobert Love .procname = "inotify", 31770399cb08SRobert Love .mode = 0555, 31780399cb08SRobert Love .child = inotify_table, 31790399cb08SRobert Love }, 31800399cb08SRobert Love #endif 31817ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 31827ef9964eSDavide Libenzi { 31837ef9964eSDavide Libenzi .procname = "epoll", 31847ef9964eSDavide Libenzi .mode = 0555, 31857ef9964eSDavide Libenzi .child = epoll_table, 31867ef9964eSDavide Libenzi }, 31877ef9964eSDavide Libenzi #endif 31881da177e4SLinus Torvalds #endif 3189d6e71144SAlan Cox { 3190800179c9SKees Cook .procname = "protected_symlinks", 3191800179c9SKees Cook .data = &sysctl_protected_symlinks, 3192800179c9SKees Cook .maxlen = sizeof(int), 3193800179c9SKees Cook .mode = 0600, 3194800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3195eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3196eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3197800179c9SKees Cook }, 3198800179c9SKees Cook { 3199800179c9SKees Cook .procname = "protected_hardlinks", 3200800179c9SKees Cook .data = &sysctl_protected_hardlinks, 3201800179c9SKees Cook .maxlen = sizeof(int), 3202800179c9SKees Cook .mode = 0600, 3203800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3204eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3205eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3206800179c9SKees Cook }, 3207800179c9SKees Cook { 320830aba665SSalvatore Mesoraca .procname = "protected_fifos", 320930aba665SSalvatore Mesoraca .data = &sysctl_protected_fifos, 321030aba665SSalvatore Mesoraca .maxlen = sizeof(int), 321130aba665SSalvatore Mesoraca .mode = 0600, 321230aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3213eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 321430aba665SSalvatore Mesoraca .extra2 = &two, 321530aba665SSalvatore Mesoraca }, 321630aba665SSalvatore Mesoraca { 321730aba665SSalvatore Mesoraca .procname = "protected_regular", 321830aba665SSalvatore Mesoraca .data = &sysctl_protected_regular, 321930aba665SSalvatore Mesoraca .maxlen = sizeof(int), 322030aba665SSalvatore Mesoraca .mode = 0600, 322130aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3222eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 322330aba665SSalvatore Mesoraca .extra2 = &two, 322430aba665SSalvatore Mesoraca }, 322530aba665SSalvatore Mesoraca { 3226d6e71144SAlan Cox .procname = "suid_dumpable", 3227d6e71144SAlan Cox .data = &suid_dumpable, 3228d6e71144SAlan Cox .maxlen = sizeof(int), 3229d6e71144SAlan Cox .mode = 0644, 323054b50199SKees Cook .proc_handler = proc_dointvec_minmax_coredump, 3231eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 32328e654fbaSMatthew Wilcox .extra2 = &two, 3233d6e71144SAlan Cox }, 32342abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 32352abc26fcSEric W. Biederman { 32362abc26fcSEric W. Biederman .procname = "binfmt_misc", 32372abc26fcSEric W. Biederman .mode = 0555, 3238f9bd6733SEric W. Biederman .child = sysctl_mount_point, 32392abc26fcSEric W. Biederman }, 32402abc26fcSEric W. Biederman #endif 3241b492e95bSJens Axboe { 3242ff9da691SJens Axboe .procname = "pipe-max-size", 3243ff9da691SJens Axboe .data = &pipe_max_size, 324498159d97SJoe Lawrence .maxlen = sizeof(pipe_max_size), 3245b492e95bSJens Axboe .mode = 0644, 3246319e0a21SEric Biggers .proc_handler = proc_dopipe_max_size, 3247b492e95bSJens Axboe }, 3248759c0114SWilly Tarreau { 3249759c0114SWilly Tarreau .procname = "pipe-user-pages-hard", 3250759c0114SWilly Tarreau .data = &pipe_user_pages_hard, 3251759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_hard), 3252759c0114SWilly Tarreau .mode = 0644, 3253759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3254759c0114SWilly Tarreau }, 3255759c0114SWilly Tarreau { 3256759c0114SWilly Tarreau .procname = "pipe-user-pages-soft", 3257759c0114SWilly Tarreau .data = &pipe_user_pages_soft, 3258759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_soft), 3259759c0114SWilly Tarreau .mode = 0644, 3260759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3261759c0114SWilly Tarreau }, 3262d2921684SEric W. Biederman { 3263d2921684SEric W. Biederman .procname = "mount-max", 3264d2921684SEric W. Biederman .data = &sysctl_mount_max, 3265d2921684SEric W. Biederman .maxlen = sizeof(unsigned int), 3266d2921684SEric W. Biederman .mode = 0644, 3267d2921684SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3268eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 3269d2921684SEric W. Biederman }, 32706fce56ecSEric W. Biederman { } 32711da177e4SLinus Torvalds }; 32721da177e4SLinus Torvalds 3273d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 32747ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE 3275abd4f750SMasoud Asgharifard Sharbiani { 3276abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 3277abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 3278abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 3279abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 3280abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 3281abd4f750SMasoud Asgharifard Sharbiani }, 3282abd4f750SMasoud Asgharifard Sharbiani #endif 3283b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 3284b2be84dfSMasami Hiramatsu { 3285b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 3286b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 3287b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 3288b2be84dfSMasami Hiramatsu .mode = 0644, 3289b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 3290eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3291eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3292b2be84dfSMasami Hiramatsu }, 3293b2be84dfSMasami Hiramatsu #endif 32946fce56ecSEric W. Biederman { } 32951da177e4SLinus Torvalds }; 32961da177e4SLinus Torvalds 3297d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 32986fce56ecSEric W. Biederman { } 32991da177e4SLinus Torvalds }; 33001da177e4SLinus Torvalds 3301f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = { 3302f461d2dcSChristoph Hellwig { 3303f461d2dcSChristoph Hellwig .procname = "kernel", 3304f461d2dcSChristoph Hellwig .mode = 0555, 3305f461d2dcSChristoph Hellwig .child = kern_table, 3306f461d2dcSChristoph Hellwig }, 3307f461d2dcSChristoph Hellwig { 3308f461d2dcSChristoph Hellwig .procname = "vm", 3309f461d2dcSChristoph Hellwig .mode = 0555, 3310f461d2dcSChristoph Hellwig .child = vm_table, 3311f461d2dcSChristoph Hellwig }, 3312f461d2dcSChristoph Hellwig { 3313f461d2dcSChristoph Hellwig .procname = "fs", 3314f461d2dcSChristoph Hellwig .mode = 0555, 3315f461d2dcSChristoph Hellwig .child = fs_table, 3316f461d2dcSChristoph Hellwig }, 3317f461d2dcSChristoph Hellwig { 3318f461d2dcSChristoph Hellwig .procname = "debug", 3319f461d2dcSChristoph Hellwig .mode = 0555, 3320f461d2dcSChristoph Hellwig .child = debug_table, 3321f461d2dcSChristoph Hellwig }, 3322f461d2dcSChristoph Hellwig { 3323f461d2dcSChristoph Hellwig .procname = "dev", 3324f461d2dcSChristoph Hellwig .mode = 0555, 3325f461d2dcSChristoph Hellwig .child = dev_table, 3326f461d2dcSChristoph Hellwig }, 3327f461d2dcSChristoph Hellwig { } 3328f461d2dcSChristoph Hellwig }; 3329f461d2dcSChristoph Hellwig 3330de4e83bdSEric W. Biederman int __init sysctl_init(void) 3331330d57fbSAl Viro { 3332fd4b616bSSteven Rostedt struct ctl_table_header *hdr; 3333fd4b616bSSteven Rostedt 3334fd4b616bSSteven Rostedt hdr = register_sysctl_table(sysctl_base_table); 3335fd4b616bSSteven Rostedt kmemleak_not_leak(hdr); 3336330d57fbSAl Viro return 0; 3337f7e6ced4SAl Viro } 3338b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 33391da177e4SLinus Torvalds /* 33401da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 33411da177e4SLinus Torvalds * exception granted :-) 33421da177e4SLinus Torvalds */ 33431da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 3344e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec); 33451da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 33461da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 334761d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 33481da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 33491da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 33501da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 33511da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 33521da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 33530bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap); 3354