1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * sysctl.c: General linux system control interface 4 * 5 * Begun 24 March 1995, Stephen Tweedie 6 * Added /proc support, Dec 1995 7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. 8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. 9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. 10 * Dynamic registration fixes, Stephen Tweedie. 11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. 12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris 13 * Horn. 14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. 15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. 16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill 17 * Wendling. 18 * The list_for_each() macro wasn't appropriate for the sysctl loop. 19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling 20 */ 21 22 #include <linux/module.h> 23 #include <linux/mm.h> 24 #include <linux/swap.h> 25 #include <linux/slab.h> 26 #include <linux/sysctl.h> 27 #include <linux/bitmap.h> 28 #include <linux/signal.h> 29 #include <linux/panic.h> 30 #include <linux/printk.h> 31 #include <linux/proc_fs.h> 32 #include <linux/security.h> 33 #include <linux/ctype.h> 34 #include <linux/kmemleak.h> 35 #include <linux/filter.h> 36 #include <linux/fs.h> 37 #include <linux/init.h> 38 #include <linux/kernel.h> 39 #include <linux/kobject.h> 40 #include <linux/net.h> 41 #include <linux/sysrq.h> 42 #include <linux/highuid.h> 43 #include <linux/writeback.h> 44 #include <linux/ratelimit.h> 45 #include <linux/compaction.h> 46 #include <linux/hugetlb.h> 47 #include <linux/initrd.h> 48 #include <linux/key.h> 49 #include <linux/times.h> 50 #include <linux/limits.h> 51 #include <linux/dcache.h> 52 #include <linux/syscalls.h> 53 #include <linux/vmstat.h> 54 #include <linux/nfs_fs.h> 55 #include <linux/acpi.h> 56 #include <linux/reboot.h> 57 #include <linux/ftrace.h> 58 #include <linux/perf_event.h> 59 #include <linux/oom.h> 60 #include <linux/kmod.h> 61 #include <linux/capability.h> 62 #include <linux/binfmts.h> 63 #include <linux/sched/sysctl.h> 64 #include <linux/kexec.h> 65 #include <linux/bpf.h> 66 #include <linux/mount.h> 67 #include <linux/userfaultfd_k.h> 68 #include <linux/latencytop.h> 69 #include <linux/pid.h> 70 #include <linux/delayacct.h> 71 72 #include "../lib/kstrtox.h" 73 74 #include <linux/uaccess.h> 75 #include <asm/processor.h> 76 77 #ifdef CONFIG_X86 78 #include <asm/nmi.h> 79 #include <asm/stacktrace.h> 80 #include <asm/io.h> 81 #endif 82 #ifdef CONFIG_SPARC 83 #include <asm/setup.h> 84 #endif 85 #ifdef CONFIG_BSD_PROCESS_ACCT 86 #include <linux/acct.h> 87 #endif 88 #ifdef CONFIG_RT_MUTEXES 89 #include <linux/rtmutex.h> 90 #endif 91 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 92 #include <linux/lockdep.h> 93 #endif 94 95 #if defined(CONFIG_SYSCTL) 96 97 /* Constants used for minimum and maximum */ 98 99 #ifdef CONFIG_PERF_EVENTS 100 static const int six_hundred_forty_kb = 640 * 1024; 101 #endif 102 103 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 104 static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 105 106 static const int ngroups_max = NGROUPS_MAX; 107 static const int cap_last_cap = CAP_LAST_CAP; 108 109 #ifdef CONFIG_PROC_SYSCTL 110 111 /** 112 * enum sysctl_writes_mode - supported sysctl write modes 113 * 114 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value 115 * to be written, and multiple writes on the same sysctl file descriptor 116 * will rewrite the sysctl value, regardless of file position. No warning 117 * is issued when the initial position is not 0. 118 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is 119 * not 0. 120 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at 121 * file position 0 and the value must be fully contained in the buffer 122 * sent to the write syscall. If dealing with strings respect the file 123 * position, but restrict this to the max length of the buffer, anything 124 * passed the max length will be ignored. Multiple writes will append 125 * to the buffer. 126 * 127 * These write modes control how current file position affects the behavior of 128 * updating sysctl values through the proc interface on each write. 129 */ 130 enum sysctl_writes_mode { 131 SYSCTL_WRITES_LEGACY = -1, 132 SYSCTL_WRITES_WARN = 0, 133 SYSCTL_WRITES_STRICT = 1, 134 }; 135 136 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; 137 #endif /* CONFIG_PROC_SYSCTL */ 138 139 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 140 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 141 int sysctl_legacy_va_layout; 142 #endif 143 144 #ifdef CONFIG_COMPACTION 145 /* min_extfrag_threshold is SYSCTL_ZERO */; 146 static const int max_extfrag_threshold = 1000; 147 #endif 148 149 #endif /* CONFIG_SYSCTL */ 150 151 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL) 152 static int bpf_stats_handler(struct ctl_table *table, int write, 153 void *buffer, size_t *lenp, loff_t *ppos) 154 { 155 struct static_key *key = (struct static_key *)table->data; 156 static int saved_val; 157 int val, ret; 158 struct ctl_table tmp = { 159 .data = &val, 160 .maxlen = sizeof(val), 161 .mode = table->mode, 162 .extra1 = SYSCTL_ZERO, 163 .extra2 = SYSCTL_ONE, 164 }; 165 166 if (write && !capable(CAP_SYS_ADMIN)) 167 return -EPERM; 168 169 mutex_lock(&bpf_stats_enabled_mutex); 170 val = saved_val; 171 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 172 if (write && !ret && val != saved_val) { 173 if (val) 174 static_key_slow_inc(key); 175 else 176 static_key_slow_dec(key); 177 saved_val = val; 178 } 179 mutex_unlock(&bpf_stats_enabled_mutex); 180 return ret; 181 } 182 183 static int bpf_unpriv_handler(struct ctl_table *table, int write, 184 void *buffer, size_t *lenp, loff_t *ppos) 185 { 186 int ret, unpriv_enable = *(int *)table->data; 187 bool locked_state = unpriv_enable == 1; 188 struct ctl_table tmp = *table; 189 190 if (write && !capable(CAP_SYS_ADMIN)) 191 return -EPERM; 192 193 tmp.data = &unpriv_enable; 194 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 195 if (write && !ret) { 196 if (locked_state && unpriv_enable != 1) 197 return -EPERM; 198 *(int *)table->data = unpriv_enable; 199 } 200 return ret; 201 } 202 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */ 203 204 /* 205 * /proc/sys support 206 */ 207 208 #ifdef CONFIG_PROC_SYSCTL 209 210 static int _proc_do_string(char *data, int maxlen, int write, 211 char *buffer, size_t *lenp, loff_t *ppos) 212 { 213 size_t len; 214 char c, *p; 215 216 if (!data || !maxlen || !*lenp) { 217 *lenp = 0; 218 return 0; 219 } 220 221 if (write) { 222 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { 223 /* Only continue writes not past the end of buffer. */ 224 len = strlen(data); 225 if (len > maxlen - 1) 226 len = maxlen - 1; 227 228 if (*ppos > len) 229 return 0; 230 len = *ppos; 231 } else { 232 /* Start writing from beginning of buffer. */ 233 len = 0; 234 } 235 236 *ppos += *lenp; 237 p = buffer; 238 while ((p - buffer) < *lenp && len < maxlen - 1) { 239 c = *(p++); 240 if (c == 0 || c == '\n') 241 break; 242 data[len++] = c; 243 } 244 data[len] = 0; 245 } else { 246 len = strlen(data); 247 if (len > maxlen) 248 len = maxlen; 249 250 if (*ppos > len) { 251 *lenp = 0; 252 return 0; 253 } 254 255 data += *ppos; 256 len -= *ppos; 257 258 if (len > *lenp) 259 len = *lenp; 260 if (len) 261 memcpy(buffer, data, len); 262 if (len < *lenp) { 263 buffer[len] = '\n'; 264 len++; 265 } 266 *lenp = len; 267 *ppos += len; 268 } 269 return 0; 270 } 271 272 static void warn_sysctl_write(struct ctl_table *table) 273 { 274 pr_warn_once("%s wrote to %s when file position was not 0!\n" 275 "This will not be supported in the future. To silence this\n" 276 "warning, set kernel.sysctl_writes_strict = -1\n", 277 current->comm, table->procname); 278 } 279 280 /** 281 * proc_first_pos_non_zero_ignore - check if first position is allowed 282 * @ppos: file position 283 * @table: the sysctl table 284 * 285 * Returns true if the first position is non-zero and the sysctl_writes_strict 286 * mode indicates this is not allowed for numeric input types. String proc 287 * handlers can ignore the return value. 288 */ 289 static bool proc_first_pos_non_zero_ignore(loff_t *ppos, 290 struct ctl_table *table) 291 { 292 if (!*ppos) 293 return false; 294 295 switch (sysctl_writes_strict) { 296 case SYSCTL_WRITES_STRICT: 297 return true; 298 case SYSCTL_WRITES_WARN: 299 warn_sysctl_write(table); 300 return false; 301 default: 302 return false; 303 } 304 } 305 306 /** 307 * proc_dostring - read a string sysctl 308 * @table: the sysctl table 309 * @write: %TRUE if this is a write to the sysctl file 310 * @buffer: the user buffer 311 * @lenp: the size of the user buffer 312 * @ppos: file position 313 * 314 * Reads/writes a string from/to the user buffer. If the kernel 315 * buffer provided is not large enough to hold the string, the 316 * string is truncated. The copied string is %NULL-terminated. 317 * If the string is being read by the user process, it is copied 318 * and a newline '\n' is added. It is truncated if the buffer is 319 * not large enough. 320 * 321 * Returns 0 on success. 322 */ 323 int proc_dostring(struct ctl_table *table, int write, 324 void *buffer, size_t *lenp, loff_t *ppos) 325 { 326 if (write) 327 proc_first_pos_non_zero_ignore(ppos, table); 328 329 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, 330 ppos); 331 } 332 333 static size_t proc_skip_spaces(char **buf) 334 { 335 size_t ret; 336 char *tmp = skip_spaces(*buf); 337 ret = tmp - *buf; 338 *buf = tmp; 339 return ret; 340 } 341 342 static void proc_skip_char(char **buf, size_t *size, const char v) 343 { 344 while (*size) { 345 if (**buf != v) 346 break; 347 (*size)--; 348 (*buf)++; 349 } 350 } 351 352 /** 353 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only 354 * fail on overflow 355 * 356 * @cp: kernel buffer containing the string to parse 357 * @endp: pointer to store the trailing characters 358 * @base: the base to use 359 * @res: where the parsed integer will be stored 360 * 361 * In case of success 0 is returned and @res will contain the parsed integer, 362 * @endp will hold any trailing characters. 363 * This function will fail the parse on overflow. If there wasn't an overflow 364 * the function will defer the decision what characters count as invalid to the 365 * caller. 366 */ 367 static int strtoul_lenient(const char *cp, char **endp, unsigned int base, 368 unsigned long *res) 369 { 370 unsigned long long result; 371 unsigned int rv; 372 373 cp = _parse_integer_fixup_radix(cp, &base); 374 rv = _parse_integer(cp, base, &result); 375 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) 376 return -ERANGE; 377 378 cp += rv; 379 380 if (endp) 381 *endp = (char *)cp; 382 383 *res = (unsigned long)result; 384 return 0; 385 } 386 387 #define TMPBUFLEN 22 388 /** 389 * proc_get_long - reads an ASCII formatted integer from a user buffer 390 * 391 * @buf: a kernel buffer 392 * @size: size of the kernel buffer 393 * @val: this is where the number will be stored 394 * @neg: set to %TRUE if number is negative 395 * @perm_tr: a vector which contains the allowed trailers 396 * @perm_tr_len: size of the perm_tr vector 397 * @tr: pointer to store the trailer character 398 * 399 * In case of success %0 is returned and @buf and @size are updated with 400 * the amount of bytes read. If @tr is non-NULL and a trailing 401 * character exists (size is non-zero after returning from this 402 * function), @tr is updated with the trailing character. 403 */ 404 static int proc_get_long(char **buf, size_t *size, 405 unsigned long *val, bool *neg, 406 const char *perm_tr, unsigned perm_tr_len, char *tr) 407 { 408 int len; 409 char *p, tmp[TMPBUFLEN]; 410 411 if (!*size) 412 return -EINVAL; 413 414 len = *size; 415 if (len > TMPBUFLEN - 1) 416 len = TMPBUFLEN - 1; 417 418 memcpy(tmp, *buf, len); 419 420 tmp[len] = 0; 421 p = tmp; 422 if (*p == '-' && *size > 1) { 423 *neg = true; 424 p++; 425 } else 426 *neg = false; 427 if (!isdigit(*p)) 428 return -EINVAL; 429 430 if (strtoul_lenient(p, &p, 0, val)) 431 return -EINVAL; 432 433 len = p - tmp; 434 435 /* We don't know if the next char is whitespace thus we may accept 436 * invalid integers (e.g. 1234...a) or two integers instead of one 437 * (e.g. 123...1). So lets not allow such large numbers. */ 438 if (len == TMPBUFLEN - 1) 439 return -EINVAL; 440 441 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 442 return -EINVAL; 443 444 if (tr && (len < *size)) 445 *tr = *p; 446 447 *buf += len; 448 *size -= len; 449 450 return 0; 451 } 452 453 /** 454 * proc_put_long - converts an integer to a decimal ASCII formatted string 455 * 456 * @buf: the user buffer 457 * @size: the size of the user buffer 458 * @val: the integer to be converted 459 * @neg: sign of the number, %TRUE for negative 460 * 461 * In case of success @buf and @size are updated with the amount of bytes 462 * written. 463 */ 464 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg) 465 { 466 int len; 467 char tmp[TMPBUFLEN], *p = tmp; 468 469 sprintf(p, "%s%lu", neg ? "-" : "", val); 470 len = strlen(tmp); 471 if (len > *size) 472 len = *size; 473 memcpy(*buf, tmp, len); 474 *size -= len; 475 *buf += len; 476 } 477 #undef TMPBUFLEN 478 479 static void proc_put_char(void **buf, size_t *size, char c) 480 { 481 if (*size) { 482 char **buffer = (char **)buf; 483 **buffer = c; 484 485 (*size)--; 486 (*buffer)++; 487 *buf = *buffer; 488 } 489 } 490 491 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp, 492 int *valp, 493 int write, void *data) 494 { 495 if (write) { 496 *(bool *)valp = *lvalp; 497 } else { 498 int val = *(bool *)valp; 499 500 *lvalp = (unsigned long)val; 501 *negp = false; 502 } 503 return 0; 504 } 505 506 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 507 int *valp, 508 int write, void *data) 509 { 510 if (write) { 511 if (*negp) { 512 if (*lvalp > (unsigned long) INT_MAX + 1) 513 return -EINVAL; 514 *valp = -*lvalp; 515 } else { 516 if (*lvalp > (unsigned long) INT_MAX) 517 return -EINVAL; 518 *valp = *lvalp; 519 } 520 } else { 521 int val = *valp; 522 if (val < 0) { 523 *negp = true; 524 *lvalp = -(unsigned long)val; 525 } else { 526 *negp = false; 527 *lvalp = (unsigned long)val; 528 } 529 } 530 return 0; 531 } 532 533 static int do_proc_douintvec_conv(unsigned long *lvalp, 534 unsigned int *valp, 535 int write, void *data) 536 { 537 if (write) { 538 if (*lvalp > UINT_MAX) 539 return -EINVAL; 540 *valp = *lvalp; 541 } else { 542 unsigned int val = *valp; 543 *lvalp = (unsigned long)val; 544 } 545 return 0; 546 } 547 548 static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 549 550 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 551 int write, void *buffer, 552 size_t *lenp, loff_t *ppos, 553 int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 554 int write, void *data), 555 void *data) 556 { 557 int *i, vleft, first = 1, err = 0; 558 size_t left; 559 char *p; 560 561 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 562 *lenp = 0; 563 return 0; 564 } 565 566 i = (int *) tbl_data; 567 vleft = table->maxlen / sizeof(*i); 568 left = *lenp; 569 570 if (!conv) 571 conv = do_proc_dointvec_conv; 572 573 if (write) { 574 if (proc_first_pos_non_zero_ignore(ppos, table)) 575 goto out; 576 577 if (left > PAGE_SIZE - 1) 578 left = PAGE_SIZE - 1; 579 p = buffer; 580 } 581 582 for (; left && vleft--; i++, first=0) { 583 unsigned long lval; 584 bool neg; 585 586 if (write) { 587 left -= proc_skip_spaces(&p); 588 589 if (!left) 590 break; 591 err = proc_get_long(&p, &left, &lval, &neg, 592 proc_wspace_sep, 593 sizeof(proc_wspace_sep), NULL); 594 if (err) 595 break; 596 if (conv(&neg, &lval, i, 1, data)) { 597 err = -EINVAL; 598 break; 599 } 600 } else { 601 if (conv(&neg, &lval, i, 0, data)) { 602 err = -EINVAL; 603 break; 604 } 605 if (!first) 606 proc_put_char(&buffer, &left, '\t'); 607 proc_put_long(&buffer, &left, lval, neg); 608 } 609 } 610 611 if (!write && !first && left && !err) 612 proc_put_char(&buffer, &left, '\n'); 613 if (write && !err && left) 614 left -= proc_skip_spaces(&p); 615 if (write && first) 616 return err ? : -EINVAL; 617 *lenp -= left; 618 out: 619 *ppos += *lenp; 620 return err; 621 } 622 623 static int do_proc_dointvec(struct ctl_table *table, int write, 624 void *buffer, size_t *lenp, loff_t *ppos, 625 int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 626 int write, void *data), 627 void *data) 628 { 629 return __do_proc_dointvec(table->data, table, write, 630 buffer, lenp, ppos, conv, data); 631 } 632 633 static int do_proc_douintvec_w(unsigned int *tbl_data, 634 struct ctl_table *table, 635 void *buffer, 636 size_t *lenp, loff_t *ppos, 637 int (*conv)(unsigned long *lvalp, 638 unsigned int *valp, 639 int write, void *data), 640 void *data) 641 { 642 unsigned long lval; 643 int err = 0; 644 size_t left; 645 bool neg; 646 char *p = buffer; 647 648 left = *lenp; 649 650 if (proc_first_pos_non_zero_ignore(ppos, table)) 651 goto bail_early; 652 653 if (left > PAGE_SIZE - 1) 654 left = PAGE_SIZE - 1; 655 656 left -= proc_skip_spaces(&p); 657 if (!left) { 658 err = -EINVAL; 659 goto out_free; 660 } 661 662 err = proc_get_long(&p, &left, &lval, &neg, 663 proc_wspace_sep, 664 sizeof(proc_wspace_sep), NULL); 665 if (err || neg) { 666 err = -EINVAL; 667 goto out_free; 668 } 669 670 if (conv(&lval, tbl_data, 1, data)) { 671 err = -EINVAL; 672 goto out_free; 673 } 674 675 if (!err && left) 676 left -= proc_skip_spaces(&p); 677 678 out_free: 679 if (err) 680 return -EINVAL; 681 682 return 0; 683 684 /* This is in keeping with old __do_proc_dointvec() */ 685 bail_early: 686 *ppos += *lenp; 687 return err; 688 } 689 690 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer, 691 size_t *lenp, loff_t *ppos, 692 int (*conv)(unsigned long *lvalp, 693 unsigned int *valp, 694 int write, void *data), 695 void *data) 696 { 697 unsigned long lval; 698 int err = 0; 699 size_t left; 700 701 left = *lenp; 702 703 if (conv(&lval, tbl_data, 0, data)) { 704 err = -EINVAL; 705 goto out; 706 } 707 708 proc_put_long(&buffer, &left, lval, false); 709 if (!left) 710 goto out; 711 712 proc_put_char(&buffer, &left, '\n'); 713 714 out: 715 *lenp -= left; 716 *ppos += *lenp; 717 718 return err; 719 } 720 721 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, 722 int write, void *buffer, 723 size_t *lenp, loff_t *ppos, 724 int (*conv)(unsigned long *lvalp, 725 unsigned int *valp, 726 int write, void *data), 727 void *data) 728 { 729 unsigned int *i, vleft; 730 731 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 732 *lenp = 0; 733 return 0; 734 } 735 736 i = (unsigned int *) tbl_data; 737 vleft = table->maxlen / sizeof(*i); 738 739 /* 740 * Arrays are not supported, keep this simple. *Do not* add 741 * support for them. 742 */ 743 if (vleft != 1) { 744 *lenp = 0; 745 return -EINVAL; 746 } 747 748 if (!conv) 749 conv = do_proc_douintvec_conv; 750 751 if (write) 752 return do_proc_douintvec_w(i, table, buffer, lenp, ppos, 753 conv, data); 754 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); 755 } 756 757 int do_proc_douintvec(struct ctl_table *table, int write, 758 void *buffer, size_t *lenp, loff_t *ppos, 759 int (*conv)(unsigned long *lvalp, 760 unsigned int *valp, 761 int write, void *data), 762 void *data) 763 { 764 return __do_proc_douintvec(table->data, table, write, 765 buffer, lenp, ppos, conv, data); 766 } 767 768 /** 769 * proc_dobool - read/write a bool 770 * @table: the sysctl table 771 * @write: %TRUE if this is a write to the sysctl file 772 * @buffer: the user buffer 773 * @lenp: the size of the user buffer 774 * @ppos: file position 775 * 776 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 777 * values from/to the user buffer, treated as an ASCII string. 778 * 779 * Returns 0 on success. 780 */ 781 int proc_dobool(struct ctl_table *table, int write, void *buffer, 782 size_t *lenp, loff_t *ppos) 783 { 784 return do_proc_dointvec(table, write, buffer, lenp, ppos, 785 do_proc_dobool_conv, NULL); 786 } 787 788 /** 789 * proc_dointvec - read a vector of integers 790 * @table: the sysctl table 791 * @write: %TRUE if this is a write to the sysctl file 792 * @buffer: the user buffer 793 * @lenp: the size of the user buffer 794 * @ppos: file position 795 * 796 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 797 * values from/to the user buffer, treated as an ASCII string. 798 * 799 * Returns 0 on success. 800 */ 801 int proc_dointvec(struct ctl_table *table, int write, void *buffer, 802 size_t *lenp, loff_t *ppos) 803 { 804 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 805 } 806 807 #ifdef CONFIG_COMPACTION 808 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, 809 int write, void *buffer, size_t *lenp, loff_t *ppos) 810 { 811 int ret, old; 812 813 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) 814 return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 815 816 old = *(int *)table->data; 817 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 818 if (ret) 819 return ret; 820 if (old != *(int *)table->data) 821 pr_warn_once("sysctl attribute %s changed by %s[%d]\n", 822 table->procname, current->comm, 823 task_pid_nr(current)); 824 return ret; 825 } 826 #endif 827 828 /** 829 * proc_douintvec - read a vector of unsigned integers 830 * @table: the sysctl table 831 * @write: %TRUE if this is a write to the sysctl file 832 * @buffer: the user buffer 833 * @lenp: the size of the user buffer 834 * @ppos: file position 835 * 836 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 837 * values from/to the user buffer, treated as an ASCII string. 838 * 839 * Returns 0 on success. 840 */ 841 int proc_douintvec(struct ctl_table *table, int write, void *buffer, 842 size_t *lenp, loff_t *ppos) 843 { 844 return do_proc_douintvec(table, write, buffer, lenp, ppos, 845 do_proc_douintvec_conv, NULL); 846 } 847 848 /* 849 * Taint values can only be increased 850 * This means we can safely use a temporary. 851 */ 852 static int proc_taint(struct ctl_table *table, int write, 853 void *buffer, size_t *lenp, loff_t *ppos) 854 { 855 struct ctl_table t; 856 unsigned long tmptaint = get_taint(); 857 int err; 858 859 if (write && !capable(CAP_SYS_ADMIN)) 860 return -EPERM; 861 862 t = *table; 863 t.data = &tmptaint; 864 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 865 if (err < 0) 866 return err; 867 868 if (write) { 869 int i; 870 871 /* 872 * If we are relying on panic_on_taint not producing 873 * false positives due to userspace input, bail out 874 * before setting the requested taint flags. 875 */ 876 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint)) 877 return -EINVAL; 878 879 /* 880 * Poor man's atomic or. Not worth adding a primitive 881 * to everyone's atomic.h for this 882 */ 883 for (i = 0; i < TAINT_FLAGS_COUNT; i++) 884 if ((1UL << i) & tmptaint) 885 add_taint(i, LOCKDEP_STILL_OK); 886 } 887 888 return err; 889 } 890 891 /** 892 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure 893 * @min: pointer to minimum allowable value 894 * @max: pointer to maximum allowable value 895 * 896 * The do_proc_dointvec_minmax_conv_param structure provides the 897 * minimum and maximum values for doing range checking for those sysctl 898 * parameters that use the proc_dointvec_minmax() handler. 899 */ 900 struct do_proc_dointvec_minmax_conv_param { 901 int *min; 902 int *max; 903 }; 904 905 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 906 int *valp, 907 int write, void *data) 908 { 909 int tmp, ret; 910 struct do_proc_dointvec_minmax_conv_param *param = data; 911 /* 912 * If writing, first do so via a temporary local int so we can 913 * bounds-check it before touching *valp. 914 */ 915 int *ip = write ? &tmp : valp; 916 917 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); 918 if (ret) 919 return ret; 920 921 if (write) { 922 if ((param->min && *param->min > tmp) || 923 (param->max && *param->max < tmp)) 924 return -EINVAL; 925 *valp = tmp; 926 } 927 928 return 0; 929 } 930 931 /** 932 * proc_dointvec_minmax - read a vector of integers with min/max values 933 * @table: the sysctl table 934 * @write: %TRUE if this is a write to the sysctl file 935 * @buffer: the user buffer 936 * @lenp: the size of the user buffer 937 * @ppos: file position 938 * 939 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 940 * values from/to the user buffer, treated as an ASCII string. 941 * 942 * This routine will ensure the values are within the range specified by 943 * table->extra1 (min) and table->extra2 (max). 944 * 945 * Returns 0 on success or -EINVAL on write when the range check fails. 946 */ 947 int proc_dointvec_minmax(struct ctl_table *table, int write, 948 void *buffer, size_t *lenp, loff_t *ppos) 949 { 950 struct do_proc_dointvec_minmax_conv_param param = { 951 .min = (int *) table->extra1, 952 .max = (int *) table->extra2, 953 }; 954 return do_proc_dointvec(table, write, buffer, lenp, ppos, 955 do_proc_dointvec_minmax_conv, ¶m); 956 } 957 958 /** 959 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure 960 * @min: pointer to minimum allowable value 961 * @max: pointer to maximum allowable value 962 * 963 * The do_proc_douintvec_minmax_conv_param structure provides the 964 * minimum and maximum values for doing range checking for those sysctl 965 * parameters that use the proc_douintvec_minmax() handler. 966 */ 967 struct do_proc_douintvec_minmax_conv_param { 968 unsigned int *min; 969 unsigned int *max; 970 }; 971 972 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, 973 unsigned int *valp, 974 int write, void *data) 975 { 976 int ret; 977 unsigned int tmp; 978 struct do_proc_douintvec_minmax_conv_param *param = data; 979 /* write via temporary local uint for bounds-checking */ 980 unsigned int *up = write ? &tmp : valp; 981 982 ret = do_proc_douintvec_conv(lvalp, up, write, data); 983 if (ret) 984 return ret; 985 986 if (write) { 987 if ((param->min && *param->min > tmp) || 988 (param->max && *param->max < tmp)) 989 return -ERANGE; 990 991 *valp = tmp; 992 } 993 994 return 0; 995 } 996 997 /** 998 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values 999 * @table: the sysctl table 1000 * @write: %TRUE if this is a write to the sysctl file 1001 * @buffer: the user buffer 1002 * @lenp: the size of the user buffer 1003 * @ppos: file position 1004 * 1005 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 1006 * values from/to the user buffer, treated as an ASCII string. Negative 1007 * strings are not allowed. 1008 * 1009 * This routine will ensure the values are within the range specified by 1010 * table->extra1 (min) and table->extra2 (max). There is a final sanity 1011 * check for UINT_MAX to avoid having to support wrap around uses from 1012 * userspace. 1013 * 1014 * Returns 0 on success or -ERANGE on write when the range check fails. 1015 */ 1016 int proc_douintvec_minmax(struct ctl_table *table, int write, 1017 void *buffer, size_t *lenp, loff_t *ppos) 1018 { 1019 struct do_proc_douintvec_minmax_conv_param param = { 1020 .min = (unsigned int *) table->extra1, 1021 .max = (unsigned int *) table->extra2, 1022 }; 1023 return do_proc_douintvec(table, write, buffer, lenp, ppos, 1024 do_proc_douintvec_minmax_conv, ¶m); 1025 } 1026 1027 /** 1028 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values 1029 * @table: the sysctl table 1030 * @write: %TRUE if this is a write to the sysctl file 1031 * @buffer: the user buffer 1032 * @lenp: the size of the user buffer 1033 * @ppos: file position 1034 * 1035 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars 1036 * values from/to the user buffer, treated as an ASCII string. Negative 1037 * strings are not allowed. 1038 * 1039 * This routine will ensure the values are within the range specified by 1040 * table->extra1 (min) and table->extra2 (max). 1041 * 1042 * Returns 0 on success or an error on write when the range check fails. 1043 */ 1044 int proc_dou8vec_minmax(struct ctl_table *table, int write, 1045 void *buffer, size_t *lenp, loff_t *ppos) 1046 { 1047 struct ctl_table tmp; 1048 unsigned int min = 0, max = 255U, val; 1049 u8 *data = table->data; 1050 struct do_proc_douintvec_minmax_conv_param param = { 1051 .min = &min, 1052 .max = &max, 1053 }; 1054 int res; 1055 1056 /* Do not support arrays yet. */ 1057 if (table->maxlen != sizeof(u8)) 1058 return -EINVAL; 1059 1060 if (table->extra1) { 1061 min = *(unsigned int *) table->extra1; 1062 if (min > 255U) 1063 return -EINVAL; 1064 } 1065 if (table->extra2) { 1066 max = *(unsigned int *) table->extra2; 1067 if (max > 255U) 1068 return -EINVAL; 1069 } 1070 1071 tmp = *table; 1072 1073 tmp.maxlen = sizeof(val); 1074 tmp.data = &val; 1075 val = *data; 1076 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos, 1077 do_proc_douintvec_minmax_conv, ¶m); 1078 if (res) 1079 return res; 1080 if (write) 1081 *data = val; 1082 return 0; 1083 } 1084 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax); 1085 1086 #ifdef CONFIG_MAGIC_SYSRQ 1087 static int sysrq_sysctl_handler(struct ctl_table *table, int write, 1088 void *buffer, size_t *lenp, loff_t *ppos) 1089 { 1090 int tmp, ret; 1091 1092 tmp = sysrq_mask(); 1093 1094 ret = __do_proc_dointvec(&tmp, table, write, buffer, 1095 lenp, ppos, NULL, NULL); 1096 if (ret || !write) 1097 return ret; 1098 1099 if (write) 1100 sysrq_toggle_support(tmp); 1101 1102 return 0; 1103 } 1104 #endif 1105 1106 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, 1107 int write, void *buffer, size_t *lenp, loff_t *ppos, 1108 unsigned long convmul, unsigned long convdiv) 1109 { 1110 unsigned long *i, *min, *max; 1111 int vleft, first = 1, err = 0; 1112 size_t left; 1113 char *p; 1114 1115 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 1116 *lenp = 0; 1117 return 0; 1118 } 1119 1120 i = (unsigned long *) data; 1121 min = (unsigned long *) table->extra1; 1122 max = (unsigned long *) table->extra2; 1123 vleft = table->maxlen / sizeof(unsigned long); 1124 left = *lenp; 1125 1126 if (write) { 1127 if (proc_first_pos_non_zero_ignore(ppos, table)) 1128 goto out; 1129 1130 if (left > PAGE_SIZE - 1) 1131 left = PAGE_SIZE - 1; 1132 p = buffer; 1133 } 1134 1135 for (; left && vleft--; i++, first = 0) { 1136 unsigned long val; 1137 1138 if (write) { 1139 bool neg; 1140 1141 left -= proc_skip_spaces(&p); 1142 if (!left) 1143 break; 1144 1145 err = proc_get_long(&p, &left, &val, &neg, 1146 proc_wspace_sep, 1147 sizeof(proc_wspace_sep), NULL); 1148 if (err) 1149 break; 1150 if (neg) 1151 continue; 1152 val = convmul * val / convdiv; 1153 if ((min && val < *min) || (max && val > *max)) { 1154 err = -EINVAL; 1155 break; 1156 } 1157 *i = val; 1158 } else { 1159 val = convdiv * (*i) / convmul; 1160 if (!first) 1161 proc_put_char(&buffer, &left, '\t'); 1162 proc_put_long(&buffer, &left, val, false); 1163 } 1164 } 1165 1166 if (!write && !first && left && !err) 1167 proc_put_char(&buffer, &left, '\n'); 1168 if (write && !err) 1169 left -= proc_skip_spaces(&p); 1170 if (write && first) 1171 return err ? : -EINVAL; 1172 *lenp -= left; 1173 out: 1174 *ppos += *lenp; 1175 return err; 1176 } 1177 1178 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 1179 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, 1180 unsigned long convdiv) 1181 { 1182 return __do_proc_doulongvec_minmax(table->data, table, write, 1183 buffer, lenp, ppos, convmul, convdiv); 1184 } 1185 1186 /** 1187 * proc_doulongvec_minmax - read a vector of long integers with min/max values 1188 * @table: the sysctl table 1189 * @write: %TRUE if this is a write to the sysctl file 1190 * @buffer: the user buffer 1191 * @lenp: the size of the user buffer 1192 * @ppos: file position 1193 * 1194 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1195 * values from/to the user buffer, treated as an ASCII string. 1196 * 1197 * This routine will ensure the values are within the range specified by 1198 * table->extra1 (min) and table->extra2 (max). 1199 * 1200 * Returns 0 on success. 1201 */ 1202 int proc_doulongvec_minmax(struct ctl_table *table, int write, 1203 void *buffer, size_t *lenp, loff_t *ppos) 1204 { 1205 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 1206 } 1207 1208 /** 1209 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 1210 * @table: the sysctl table 1211 * @write: %TRUE if this is a write to the sysctl file 1212 * @buffer: the user buffer 1213 * @lenp: the size of the user buffer 1214 * @ppos: file position 1215 * 1216 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1217 * values from/to the user buffer, treated as an ASCII string. The values 1218 * are treated as milliseconds, and converted to jiffies when they are stored. 1219 * 1220 * This routine will ensure the values are within the range specified by 1221 * table->extra1 (min) and table->extra2 (max). 1222 * 1223 * Returns 0 on success. 1224 */ 1225 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 1226 void *buffer, size_t *lenp, loff_t *ppos) 1227 { 1228 return do_proc_doulongvec_minmax(table, write, buffer, 1229 lenp, ppos, HZ, 1000l); 1230 } 1231 1232 1233 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 1234 int *valp, 1235 int write, void *data) 1236 { 1237 if (write) { 1238 if (*lvalp > INT_MAX / HZ) 1239 return 1; 1240 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 1241 } else { 1242 int val = *valp; 1243 unsigned long lval; 1244 if (val < 0) { 1245 *negp = true; 1246 lval = -(unsigned long)val; 1247 } else { 1248 *negp = false; 1249 lval = (unsigned long)val; 1250 } 1251 *lvalp = lval / HZ; 1252 } 1253 return 0; 1254 } 1255 1256 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 1257 int *valp, 1258 int write, void *data) 1259 { 1260 if (write) { 1261 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 1262 return 1; 1263 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 1264 } else { 1265 int val = *valp; 1266 unsigned long lval; 1267 if (val < 0) { 1268 *negp = true; 1269 lval = -(unsigned long)val; 1270 } else { 1271 *negp = false; 1272 lval = (unsigned long)val; 1273 } 1274 *lvalp = jiffies_to_clock_t(lval); 1275 } 1276 return 0; 1277 } 1278 1279 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 1280 int *valp, 1281 int write, void *data) 1282 { 1283 if (write) { 1284 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 1285 1286 if (jif > INT_MAX) 1287 return 1; 1288 *valp = (int)jif; 1289 } else { 1290 int val = *valp; 1291 unsigned long lval; 1292 if (val < 0) { 1293 *negp = true; 1294 lval = -(unsigned long)val; 1295 } else { 1296 *negp = false; 1297 lval = (unsigned long)val; 1298 } 1299 *lvalp = jiffies_to_msecs(lval); 1300 } 1301 return 0; 1302 } 1303 1304 /** 1305 * proc_dointvec_jiffies - read a vector of integers as seconds 1306 * @table: the sysctl table 1307 * @write: %TRUE if this is a write to the sysctl file 1308 * @buffer: the user buffer 1309 * @lenp: the size of the user buffer 1310 * @ppos: file position 1311 * 1312 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1313 * values from/to the user buffer, treated as an ASCII string. 1314 * The values read are assumed to be in seconds, and are converted into 1315 * jiffies. 1316 * 1317 * Returns 0 on success. 1318 */ 1319 int proc_dointvec_jiffies(struct ctl_table *table, int write, 1320 void *buffer, size_t *lenp, loff_t *ppos) 1321 { 1322 return do_proc_dointvec(table,write,buffer,lenp,ppos, 1323 do_proc_dointvec_jiffies_conv,NULL); 1324 } 1325 1326 /** 1327 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 1328 * @table: the sysctl table 1329 * @write: %TRUE if this is a write to the sysctl file 1330 * @buffer: the user buffer 1331 * @lenp: the size of the user buffer 1332 * @ppos: pointer to the file position 1333 * 1334 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1335 * values from/to the user buffer, treated as an ASCII string. 1336 * The values read are assumed to be in 1/USER_HZ seconds, and 1337 * are converted into jiffies. 1338 * 1339 * Returns 0 on success. 1340 */ 1341 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 1342 void *buffer, size_t *lenp, loff_t *ppos) 1343 { 1344 return do_proc_dointvec(table,write,buffer,lenp,ppos, 1345 do_proc_dointvec_userhz_jiffies_conv,NULL); 1346 } 1347 1348 /** 1349 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 1350 * @table: the sysctl table 1351 * @write: %TRUE if this is a write to the sysctl file 1352 * @buffer: the user buffer 1353 * @lenp: the size of the user buffer 1354 * @ppos: file position 1355 * @ppos: the current position in the file 1356 * 1357 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1358 * values from/to the user buffer, treated as an ASCII string. 1359 * The values read are assumed to be in 1/1000 seconds, and 1360 * are converted into jiffies. 1361 * 1362 * Returns 0 on success. 1363 */ 1364 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer, 1365 size_t *lenp, loff_t *ppos) 1366 { 1367 return do_proc_dointvec(table, write, buffer, lenp, ppos, 1368 do_proc_dointvec_ms_jiffies_conv, NULL); 1369 } 1370 1371 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer, 1372 size_t *lenp, loff_t *ppos) 1373 { 1374 struct pid *new_pid; 1375 pid_t tmp; 1376 int r; 1377 1378 tmp = pid_vnr(cad_pid); 1379 1380 r = __do_proc_dointvec(&tmp, table, write, buffer, 1381 lenp, ppos, NULL, NULL); 1382 if (r || !write) 1383 return r; 1384 1385 new_pid = find_get_pid(tmp); 1386 if (!new_pid) 1387 return -ESRCH; 1388 1389 put_pid(xchg(&cad_pid, new_pid)); 1390 return 0; 1391 } 1392 1393 /** 1394 * proc_do_large_bitmap - read/write from/to a large bitmap 1395 * @table: the sysctl table 1396 * @write: %TRUE if this is a write to the sysctl file 1397 * @buffer: the user buffer 1398 * @lenp: the size of the user buffer 1399 * @ppos: file position 1400 * 1401 * The bitmap is stored at table->data and the bitmap length (in bits) 1402 * in table->maxlen. 1403 * 1404 * We use a range comma separated format (e.g. 1,3-4,10-10) so that 1405 * large bitmaps may be represented in a compact manner. Writing into 1406 * the file will clear the bitmap then update it with the given input. 1407 * 1408 * Returns 0 on success. 1409 */ 1410 int proc_do_large_bitmap(struct ctl_table *table, int write, 1411 void *buffer, size_t *lenp, loff_t *ppos) 1412 { 1413 int err = 0; 1414 size_t left = *lenp; 1415 unsigned long bitmap_len = table->maxlen; 1416 unsigned long *bitmap = *(unsigned long **) table->data; 1417 unsigned long *tmp_bitmap = NULL; 1418 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1419 1420 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { 1421 *lenp = 0; 1422 return 0; 1423 } 1424 1425 if (write) { 1426 char *p = buffer; 1427 size_t skipped = 0; 1428 1429 if (left > PAGE_SIZE - 1) { 1430 left = PAGE_SIZE - 1; 1431 /* How much of the buffer we'll skip this pass */ 1432 skipped = *lenp - left; 1433 } 1434 1435 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); 1436 if (!tmp_bitmap) 1437 return -ENOMEM; 1438 proc_skip_char(&p, &left, '\n'); 1439 while (!err && left) { 1440 unsigned long val_a, val_b; 1441 bool neg; 1442 size_t saved_left; 1443 1444 /* In case we stop parsing mid-number, we can reset */ 1445 saved_left = left; 1446 err = proc_get_long(&p, &left, &val_a, &neg, tr_a, 1447 sizeof(tr_a), &c); 1448 /* 1449 * If we consumed the entirety of a truncated buffer or 1450 * only one char is left (may be a "-"), then stop here, 1451 * reset, & come back for more. 1452 */ 1453 if ((left <= 1) && skipped) { 1454 left = saved_left; 1455 break; 1456 } 1457 1458 if (err) 1459 break; 1460 if (val_a >= bitmap_len || neg) { 1461 err = -EINVAL; 1462 break; 1463 } 1464 1465 val_b = val_a; 1466 if (left) { 1467 p++; 1468 left--; 1469 } 1470 1471 if (c == '-') { 1472 err = proc_get_long(&p, &left, &val_b, 1473 &neg, tr_b, sizeof(tr_b), 1474 &c); 1475 /* 1476 * If we consumed all of a truncated buffer or 1477 * then stop here, reset, & come back for more. 1478 */ 1479 if (!left && skipped) { 1480 left = saved_left; 1481 break; 1482 } 1483 1484 if (err) 1485 break; 1486 if (val_b >= bitmap_len || neg || 1487 val_a > val_b) { 1488 err = -EINVAL; 1489 break; 1490 } 1491 if (left) { 1492 p++; 1493 left--; 1494 } 1495 } 1496 1497 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 1498 proc_skip_char(&p, &left, '\n'); 1499 } 1500 left += skipped; 1501 } else { 1502 unsigned long bit_a, bit_b = 0; 1503 bool first = 1; 1504 1505 while (left) { 1506 bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 1507 if (bit_a >= bitmap_len) 1508 break; 1509 bit_b = find_next_zero_bit(bitmap, bitmap_len, 1510 bit_a + 1) - 1; 1511 1512 if (!first) 1513 proc_put_char(&buffer, &left, ','); 1514 proc_put_long(&buffer, &left, bit_a, false); 1515 if (bit_a != bit_b) { 1516 proc_put_char(&buffer, &left, '-'); 1517 proc_put_long(&buffer, &left, bit_b, false); 1518 } 1519 1520 first = 0; bit_b++; 1521 } 1522 proc_put_char(&buffer, &left, '\n'); 1523 } 1524 1525 if (!err) { 1526 if (write) { 1527 if (*ppos) 1528 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 1529 else 1530 bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 1531 } 1532 *lenp -= left; 1533 *ppos += *lenp; 1534 } 1535 1536 bitmap_free(tmp_bitmap); 1537 return err; 1538 } 1539 1540 #else /* CONFIG_PROC_SYSCTL */ 1541 1542 int proc_dostring(struct ctl_table *table, int write, 1543 void *buffer, size_t *lenp, loff_t *ppos) 1544 { 1545 return -ENOSYS; 1546 } 1547 1548 int proc_dobool(struct ctl_table *table, int write, 1549 void *buffer, size_t *lenp, loff_t *ppos) 1550 { 1551 return -ENOSYS; 1552 } 1553 1554 int proc_dointvec(struct ctl_table *table, int write, 1555 void *buffer, size_t *lenp, loff_t *ppos) 1556 { 1557 return -ENOSYS; 1558 } 1559 1560 int proc_douintvec(struct ctl_table *table, int write, 1561 void *buffer, size_t *lenp, loff_t *ppos) 1562 { 1563 return -ENOSYS; 1564 } 1565 1566 int proc_dointvec_minmax(struct ctl_table *table, int write, 1567 void *buffer, size_t *lenp, loff_t *ppos) 1568 { 1569 return -ENOSYS; 1570 } 1571 1572 int proc_douintvec_minmax(struct ctl_table *table, int write, 1573 void *buffer, size_t *lenp, loff_t *ppos) 1574 { 1575 return -ENOSYS; 1576 } 1577 1578 int proc_dou8vec_minmax(struct ctl_table *table, int write, 1579 void *buffer, size_t *lenp, loff_t *ppos) 1580 { 1581 return -ENOSYS; 1582 } 1583 1584 int proc_dointvec_jiffies(struct ctl_table *table, int write, 1585 void *buffer, size_t *lenp, loff_t *ppos) 1586 { 1587 return -ENOSYS; 1588 } 1589 1590 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 1591 void *buffer, size_t *lenp, loff_t *ppos) 1592 { 1593 return -ENOSYS; 1594 } 1595 1596 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 1597 void *buffer, size_t *lenp, loff_t *ppos) 1598 { 1599 return -ENOSYS; 1600 } 1601 1602 int proc_doulongvec_minmax(struct ctl_table *table, int write, 1603 void *buffer, size_t *lenp, loff_t *ppos) 1604 { 1605 return -ENOSYS; 1606 } 1607 1608 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 1609 void *buffer, size_t *lenp, loff_t *ppos) 1610 { 1611 return -ENOSYS; 1612 } 1613 1614 int proc_do_large_bitmap(struct ctl_table *table, int write, 1615 void *buffer, size_t *lenp, loff_t *ppos) 1616 { 1617 return -ENOSYS; 1618 } 1619 1620 #endif /* CONFIG_PROC_SYSCTL */ 1621 1622 #if defined(CONFIG_SYSCTL) 1623 int proc_do_static_key(struct ctl_table *table, int write, 1624 void *buffer, size_t *lenp, loff_t *ppos) 1625 { 1626 struct static_key *key = (struct static_key *)table->data; 1627 static DEFINE_MUTEX(static_key_mutex); 1628 int val, ret; 1629 struct ctl_table tmp = { 1630 .data = &val, 1631 .maxlen = sizeof(val), 1632 .mode = table->mode, 1633 .extra1 = SYSCTL_ZERO, 1634 .extra2 = SYSCTL_ONE, 1635 }; 1636 1637 if (write && !capable(CAP_SYS_ADMIN)) 1638 return -EPERM; 1639 1640 mutex_lock(&static_key_mutex); 1641 val = static_key_enabled(key); 1642 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 1643 if (write && !ret) { 1644 if (val) 1645 static_key_enable(key); 1646 else 1647 static_key_disable(key); 1648 } 1649 mutex_unlock(&static_key_mutex); 1650 return ret; 1651 } 1652 1653 static struct ctl_table kern_table[] = { 1654 { 1655 .procname = "sched_child_runs_first", 1656 .data = &sysctl_sched_child_runs_first, 1657 .maxlen = sizeof(unsigned int), 1658 .mode = 0644, 1659 .proc_handler = proc_dointvec, 1660 }, 1661 #ifdef CONFIG_SCHEDSTATS 1662 { 1663 .procname = "sched_schedstats", 1664 .data = NULL, 1665 .maxlen = sizeof(unsigned int), 1666 .mode = 0644, 1667 .proc_handler = sysctl_schedstats, 1668 .extra1 = SYSCTL_ZERO, 1669 .extra2 = SYSCTL_ONE, 1670 }, 1671 #endif /* CONFIG_SCHEDSTATS */ 1672 #ifdef CONFIG_TASK_DELAY_ACCT 1673 { 1674 .procname = "task_delayacct", 1675 .data = NULL, 1676 .maxlen = sizeof(unsigned int), 1677 .mode = 0644, 1678 .proc_handler = sysctl_delayacct, 1679 .extra1 = SYSCTL_ZERO, 1680 .extra2 = SYSCTL_ONE, 1681 }, 1682 #endif /* CONFIG_TASK_DELAY_ACCT */ 1683 #ifdef CONFIG_NUMA_BALANCING 1684 { 1685 .procname = "numa_balancing", 1686 .data = NULL, /* filled in by handler */ 1687 .maxlen = sizeof(unsigned int), 1688 .mode = 0644, 1689 .proc_handler = sysctl_numa_balancing, 1690 .extra1 = SYSCTL_ZERO, 1691 .extra2 = SYSCTL_ONE, 1692 }, 1693 #endif /* CONFIG_NUMA_BALANCING */ 1694 { 1695 .procname = "sched_rt_period_us", 1696 .data = &sysctl_sched_rt_period, 1697 .maxlen = sizeof(unsigned int), 1698 .mode = 0644, 1699 .proc_handler = sched_rt_handler, 1700 }, 1701 { 1702 .procname = "sched_rt_runtime_us", 1703 .data = &sysctl_sched_rt_runtime, 1704 .maxlen = sizeof(int), 1705 .mode = 0644, 1706 .proc_handler = sched_rt_handler, 1707 }, 1708 { 1709 .procname = "sched_deadline_period_max_us", 1710 .data = &sysctl_sched_dl_period_max, 1711 .maxlen = sizeof(unsigned int), 1712 .mode = 0644, 1713 .proc_handler = proc_dointvec, 1714 }, 1715 { 1716 .procname = "sched_deadline_period_min_us", 1717 .data = &sysctl_sched_dl_period_min, 1718 .maxlen = sizeof(unsigned int), 1719 .mode = 0644, 1720 .proc_handler = proc_dointvec, 1721 }, 1722 { 1723 .procname = "sched_rr_timeslice_ms", 1724 .data = &sysctl_sched_rr_timeslice, 1725 .maxlen = sizeof(int), 1726 .mode = 0644, 1727 .proc_handler = sched_rr_handler, 1728 }, 1729 #ifdef CONFIG_UCLAMP_TASK 1730 { 1731 .procname = "sched_util_clamp_min", 1732 .data = &sysctl_sched_uclamp_util_min, 1733 .maxlen = sizeof(unsigned int), 1734 .mode = 0644, 1735 .proc_handler = sysctl_sched_uclamp_handler, 1736 }, 1737 { 1738 .procname = "sched_util_clamp_max", 1739 .data = &sysctl_sched_uclamp_util_max, 1740 .maxlen = sizeof(unsigned int), 1741 .mode = 0644, 1742 .proc_handler = sysctl_sched_uclamp_handler, 1743 }, 1744 { 1745 .procname = "sched_util_clamp_min_rt_default", 1746 .data = &sysctl_sched_uclamp_util_min_rt_default, 1747 .maxlen = sizeof(unsigned int), 1748 .mode = 0644, 1749 .proc_handler = sysctl_sched_uclamp_handler, 1750 }, 1751 #endif 1752 #ifdef CONFIG_SCHED_AUTOGROUP 1753 { 1754 .procname = "sched_autogroup_enabled", 1755 .data = &sysctl_sched_autogroup_enabled, 1756 .maxlen = sizeof(unsigned int), 1757 .mode = 0644, 1758 .proc_handler = proc_dointvec_minmax, 1759 .extra1 = SYSCTL_ZERO, 1760 .extra2 = SYSCTL_ONE, 1761 }, 1762 #endif 1763 #ifdef CONFIG_CFS_BANDWIDTH 1764 { 1765 .procname = "sched_cfs_bandwidth_slice_us", 1766 .data = &sysctl_sched_cfs_bandwidth_slice, 1767 .maxlen = sizeof(unsigned int), 1768 .mode = 0644, 1769 .proc_handler = proc_dointvec_minmax, 1770 .extra1 = SYSCTL_ONE, 1771 }, 1772 #endif 1773 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) 1774 { 1775 .procname = "sched_energy_aware", 1776 .data = &sysctl_sched_energy_aware, 1777 .maxlen = sizeof(unsigned int), 1778 .mode = 0644, 1779 .proc_handler = sched_energy_aware_handler, 1780 .extra1 = SYSCTL_ZERO, 1781 .extra2 = SYSCTL_ONE, 1782 }, 1783 #endif 1784 #ifdef CONFIG_PROVE_LOCKING 1785 { 1786 .procname = "prove_locking", 1787 .data = &prove_locking, 1788 .maxlen = sizeof(int), 1789 .mode = 0644, 1790 .proc_handler = proc_dointvec, 1791 }, 1792 #endif 1793 #ifdef CONFIG_LOCK_STAT 1794 { 1795 .procname = "lock_stat", 1796 .data = &lock_stat, 1797 .maxlen = sizeof(int), 1798 .mode = 0644, 1799 .proc_handler = proc_dointvec, 1800 }, 1801 #endif 1802 { 1803 .procname = "panic", 1804 .data = &panic_timeout, 1805 .maxlen = sizeof(int), 1806 .mode = 0644, 1807 .proc_handler = proc_dointvec, 1808 }, 1809 #ifdef CONFIG_PROC_SYSCTL 1810 { 1811 .procname = "tainted", 1812 .maxlen = sizeof(long), 1813 .mode = 0644, 1814 .proc_handler = proc_taint, 1815 }, 1816 { 1817 .procname = "sysctl_writes_strict", 1818 .data = &sysctl_writes_strict, 1819 .maxlen = sizeof(int), 1820 .mode = 0644, 1821 .proc_handler = proc_dointvec_minmax, 1822 .extra1 = SYSCTL_NEG_ONE, 1823 .extra2 = SYSCTL_ONE, 1824 }, 1825 #endif 1826 #ifdef CONFIG_LATENCYTOP 1827 { 1828 .procname = "latencytop", 1829 .data = &latencytop_enabled, 1830 .maxlen = sizeof(int), 1831 .mode = 0644, 1832 .proc_handler = sysctl_latencytop, 1833 }, 1834 #endif 1835 #ifdef CONFIG_BLK_DEV_INITRD 1836 { 1837 .procname = "real-root-dev", 1838 .data = &real_root_dev, 1839 .maxlen = sizeof(int), 1840 .mode = 0644, 1841 .proc_handler = proc_dointvec, 1842 }, 1843 #endif 1844 { 1845 .procname = "print-fatal-signals", 1846 .data = &print_fatal_signals, 1847 .maxlen = sizeof(int), 1848 .mode = 0644, 1849 .proc_handler = proc_dointvec, 1850 }, 1851 #ifdef CONFIG_SPARC 1852 { 1853 .procname = "reboot-cmd", 1854 .data = reboot_command, 1855 .maxlen = 256, 1856 .mode = 0644, 1857 .proc_handler = proc_dostring, 1858 }, 1859 { 1860 .procname = "stop-a", 1861 .data = &stop_a_enabled, 1862 .maxlen = sizeof (int), 1863 .mode = 0644, 1864 .proc_handler = proc_dointvec, 1865 }, 1866 { 1867 .procname = "scons-poweroff", 1868 .data = &scons_pwroff, 1869 .maxlen = sizeof (int), 1870 .mode = 0644, 1871 .proc_handler = proc_dointvec, 1872 }, 1873 #endif 1874 #ifdef CONFIG_SPARC64 1875 { 1876 .procname = "tsb-ratio", 1877 .data = &sysctl_tsb_ratio, 1878 .maxlen = sizeof (int), 1879 .mode = 0644, 1880 .proc_handler = proc_dointvec, 1881 }, 1882 #endif 1883 #ifdef CONFIG_PARISC 1884 { 1885 .procname = "soft-power", 1886 .data = &pwrsw_enabled, 1887 .maxlen = sizeof (int), 1888 .mode = 0644, 1889 .proc_handler = proc_dointvec, 1890 }, 1891 #endif 1892 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW 1893 { 1894 .procname = "unaligned-trap", 1895 .data = &unaligned_enabled, 1896 .maxlen = sizeof (int), 1897 .mode = 0644, 1898 .proc_handler = proc_dointvec, 1899 }, 1900 #endif 1901 { 1902 .procname = "ctrl-alt-del", 1903 .data = &C_A_D, 1904 .maxlen = sizeof(int), 1905 .mode = 0644, 1906 .proc_handler = proc_dointvec, 1907 }, 1908 #ifdef CONFIG_FUNCTION_TRACER 1909 { 1910 .procname = "ftrace_enabled", 1911 .data = &ftrace_enabled, 1912 .maxlen = sizeof(int), 1913 .mode = 0644, 1914 .proc_handler = ftrace_enable_sysctl, 1915 }, 1916 #endif 1917 #ifdef CONFIG_STACK_TRACER 1918 { 1919 .procname = "stack_tracer_enabled", 1920 .data = &stack_tracer_enabled, 1921 .maxlen = sizeof(int), 1922 .mode = 0644, 1923 .proc_handler = stack_trace_sysctl, 1924 }, 1925 #endif 1926 #ifdef CONFIG_TRACING 1927 { 1928 .procname = "ftrace_dump_on_oops", 1929 .data = &ftrace_dump_on_oops, 1930 .maxlen = sizeof(int), 1931 .mode = 0644, 1932 .proc_handler = proc_dointvec, 1933 }, 1934 { 1935 .procname = "traceoff_on_warning", 1936 .data = &__disable_trace_on_warning, 1937 .maxlen = sizeof(__disable_trace_on_warning), 1938 .mode = 0644, 1939 .proc_handler = proc_dointvec, 1940 }, 1941 { 1942 .procname = "tracepoint_printk", 1943 .data = &tracepoint_printk, 1944 .maxlen = sizeof(tracepoint_printk), 1945 .mode = 0644, 1946 .proc_handler = tracepoint_printk_sysctl, 1947 }, 1948 #endif 1949 #ifdef CONFIG_KEXEC_CORE 1950 { 1951 .procname = "kexec_load_disabled", 1952 .data = &kexec_load_disabled, 1953 .maxlen = sizeof(int), 1954 .mode = 0644, 1955 /* only handle a transition from default "0" to "1" */ 1956 .proc_handler = proc_dointvec_minmax, 1957 .extra1 = SYSCTL_ONE, 1958 .extra2 = SYSCTL_ONE, 1959 }, 1960 #endif 1961 #ifdef CONFIG_MODULES 1962 { 1963 .procname = "modprobe", 1964 .data = &modprobe_path, 1965 .maxlen = KMOD_PATH_LEN, 1966 .mode = 0644, 1967 .proc_handler = proc_dostring, 1968 }, 1969 { 1970 .procname = "modules_disabled", 1971 .data = &modules_disabled, 1972 .maxlen = sizeof(int), 1973 .mode = 0644, 1974 /* only handle a transition from default "0" to "1" */ 1975 .proc_handler = proc_dointvec_minmax, 1976 .extra1 = SYSCTL_ONE, 1977 .extra2 = SYSCTL_ONE, 1978 }, 1979 #endif 1980 #ifdef CONFIG_UEVENT_HELPER 1981 { 1982 .procname = "hotplug", 1983 .data = &uevent_helper, 1984 .maxlen = UEVENT_HELPER_PATH_LEN, 1985 .mode = 0644, 1986 .proc_handler = proc_dostring, 1987 }, 1988 #endif 1989 #ifdef CONFIG_BSD_PROCESS_ACCT 1990 { 1991 .procname = "acct", 1992 .data = &acct_parm, 1993 .maxlen = 3*sizeof(int), 1994 .mode = 0644, 1995 .proc_handler = proc_dointvec, 1996 }, 1997 #endif 1998 #ifdef CONFIG_MAGIC_SYSRQ 1999 { 2000 .procname = "sysrq", 2001 .data = NULL, 2002 .maxlen = sizeof (int), 2003 .mode = 0644, 2004 .proc_handler = sysrq_sysctl_handler, 2005 }, 2006 #endif 2007 #ifdef CONFIG_PROC_SYSCTL 2008 { 2009 .procname = "cad_pid", 2010 .data = NULL, 2011 .maxlen = sizeof (int), 2012 .mode = 0600, 2013 .proc_handler = proc_do_cad_pid, 2014 }, 2015 #endif 2016 { 2017 .procname = "threads-max", 2018 .data = NULL, 2019 .maxlen = sizeof(int), 2020 .mode = 0644, 2021 .proc_handler = sysctl_max_threads, 2022 }, 2023 { 2024 .procname = "usermodehelper", 2025 .mode = 0555, 2026 .child = usermodehelper_table, 2027 }, 2028 { 2029 .procname = "overflowuid", 2030 .data = &overflowuid, 2031 .maxlen = sizeof(int), 2032 .mode = 0644, 2033 .proc_handler = proc_dointvec_minmax, 2034 .extra1 = SYSCTL_ZERO, 2035 .extra2 = SYSCTL_MAXOLDUID, 2036 }, 2037 { 2038 .procname = "overflowgid", 2039 .data = &overflowgid, 2040 .maxlen = sizeof(int), 2041 .mode = 0644, 2042 .proc_handler = proc_dointvec_minmax, 2043 .extra1 = SYSCTL_ZERO, 2044 .extra2 = SYSCTL_MAXOLDUID, 2045 }, 2046 #ifdef CONFIG_S390 2047 { 2048 .procname = "userprocess_debug", 2049 .data = &show_unhandled_signals, 2050 .maxlen = sizeof(int), 2051 .mode = 0644, 2052 .proc_handler = proc_dointvec, 2053 }, 2054 #endif 2055 #ifdef CONFIG_SMP 2056 { 2057 .procname = "oops_all_cpu_backtrace", 2058 .data = &sysctl_oops_all_cpu_backtrace, 2059 .maxlen = sizeof(int), 2060 .mode = 0644, 2061 .proc_handler = proc_dointvec_minmax, 2062 .extra1 = SYSCTL_ZERO, 2063 .extra2 = SYSCTL_ONE, 2064 }, 2065 #endif /* CONFIG_SMP */ 2066 { 2067 .procname = "pid_max", 2068 .data = &pid_max, 2069 .maxlen = sizeof (int), 2070 .mode = 0644, 2071 .proc_handler = proc_dointvec_minmax, 2072 .extra1 = &pid_max_min, 2073 .extra2 = &pid_max_max, 2074 }, 2075 { 2076 .procname = "panic_on_oops", 2077 .data = &panic_on_oops, 2078 .maxlen = sizeof(int), 2079 .mode = 0644, 2080 .proc_handler = proc_dointvec, 2081 }, 2082 { 2083 .procname = "panic_print", 2084 .data = &panic_print, 2085 .maxlen = sizeof(unsigned long), 2086 .mode = 0644, 2087 .proc_handler = proc_doulongvec_minmax, 2088 }, 2089 { 2090 .procname = "ngroups_max", 2091 .data = (void *)&ngroups_max, 2092 .maxlen = sizeof (int), 2093 .mode = 0444, 2094 .proc_handler = proc_dointvec, 2095 }, 2096 { 2097 .procname = "cap_last_cap", 2098 .data = (void *)&cap_last_cap, 2099 .maxlen = sizeof(int), 2100 .mode = 0444, 2101 .proc_handler = proc_dointvec, 2102 }, 2103 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 2104 { 2105 .procname = "unknown_nmi_panic", 2106 .data = &unknown_nmi_panic, 2107 .maxlen = sizeof (int), 2108 .mode = 0644, 2109 .proc_handler = proc_dointvec, 2110 }, 2111 #endif 2112 2113 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \ 2114 defined(CONFIG_DEBUG_STACKOVERFLOW) 2115 { 2116 .procname = "panic_on_stackoverflow", 2117 .data = &sysctl_panic_on_stackoverflow, 2118 .maxlen = sizeof(int), 2119 .mode = 0644, 2120 .proc_handler = proc_dointvec, 2121 }, 2122 #endif 2123 #if defined(CONFIG_X86) 2124 { 2125 .procname = "panic_on_unrecovered_nmi", 2126 .data = &panic_on_unrecovered_nmi, 2127 .maxlen = sizeof(int), 2128 .mode = 0644, 2129 .proc_handler = proc_dointvec, 2130 }, 2131 { 2132 .procname = "panic_on_io_nmi", 2133 .data = &panic_on_io_nmi, 2134 .maxlen = sizeof(int), 2135 .mode = 0644, 2136 .proc_handler = proc_dointvec, 2137 }, 2138 { 2139 .procname = "bootloader_type", 2140 .data = &bootloader_type, 2141 .maxlen = sizeof (int), 2142 .mode = 0444, 2143 .proc_handler = proc_dointvec, 2144 }, 2145 { 2146 .procname = "bootloader_version", 2147 .data = &bootloader_version, 2148 .maxlen = sizeof (int), 2149 .mode = 0444, 2150 .proc_handler = proc_dointvec, 2151 }, 2152 { 2153 .procname = "io_delay_type", 2154 .data = &io_delay_type, 2155 .maxlen = sizeof(int), 2156 .mode = 0644, 2157 .proc_handler = proc_dointvec, 2158 }, 2159 #endif 2160 #if defined(CONFIG_MMU) 2161 { 2162 .procname = "randomize_va_space", 2163 .data = &randomize_va_space, 2164 .maxlen = sizeof(int), 2165 .mode = 0644, 2166 .proc_handler = proc_dointvec, 2167 }, 2168 #endif 2169 #if defined(CONFIG_S390) && defined(CONFIG_SMP) 2170 { 2171 .procname = "spin_retry", 2172 .data = &spin_retry, 2173 .maxlen = sizeof (int), 2174 .mode = 0644, 2175 .proc_handler = proc_dointvec, 2176 }, 2177 #endif 2178 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 2179 { 2180 .procname = "acpi_video_flags", 2181 .data = &acpi_realmode_flags, 2182 .maxlen = sizeof (unsigned long), 2183 .mode = 0644, 2184 .proc_handler = proc_doulongvec_minmax, 2185 }, 2186 #endif 2187 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN 2188 { 2189 .procname = "ignore-unaligned-usertrap", 2190 .data = &no_unaligned_warning, 2191 .maxlen = sizeof (int), 2192 .mode = 0644, 2193 .proc_handler = proc_dointvec, 2194 }, 2195 #endif 2196 #ifdef CONFIG_IA64 2197 { 2198 .procname = "unaligned-dump-stack", 2199 .data = &unaligned_dump_stack, 2200 .maxlen = sizeof (int), 2201 .mode = 0644, 2202 .proc_handler = proc_dointvec, 2203 }, 2204 #endif 2205 #ifdef CONFIG_RT_MUTEXES 2206 { 2207 .procname = "max_lock_depth", 2208 .data = &max_lock_depth, 2209 .maxlen = sizeof(int), 2210 .mode = 0644, 2211 .proc_handler = proc_dointvec, 2212 }, 2213 #endif 2214 { 2215 .procname = "poweroff_cmd", 2216 .data = &poweroff_cmd, 2217 .maxlen = POWEROFF_CMD_PATH_LEN, 2218 .mode = 0644, 2219 .proc_handler = proc_dostring, 2220 }, 2221 #ifdef CONFIG_KEYS 2222 { 2223 .procname = "keys", 2224 .mode = 0555, 2225 .child = key_sysctls, 2226 }, 2227 #endif 2228 #ifdef CONFIG_PERF_EVENTS 2229 /* 2230 * User-space scripts rely on the existence of this file 2231 * as a feature check for perf_events being enabled. 2232 * 2233 * So it's an ABI, do not remove! 2234 */ 2235 { 2236 .procname = "perf_event_paranoid", 2237 .data = &sysctl_perf_event_paranoid, 2238 .maxlen = sizeof(sysctl_perf_event_paranoid), 2239 .mode = 0644, 2240 .proc_handler = proc_dointvec, 2241 }, 2242 { 2243 .procname = "perf_event_mlock_kb", 2244 .data = &sysctl_perf_event_mlock, 2245 .maxlen = sizeof(sysctl_perf_event_mlock), 2246 .mode = 0644, 2247 .proc_handler = proc_dointvec, 2248 }, 2249 { 2250 .procname = "perf_event_max_sample_rate", 2251 .data = &sysctl_perf_event_sample_rate, 2252 .maxlen = sizeof(sysctl_perf_event_sample_rate), 2253 .mode = 0644, 2254 .proc_handler = perf_proc_update_handler, 2255 .extra1 = SYSCTL_ONE, 2256 }, 2257 { 2258 .procname = "perf_cpu_time_max_percent", 2259 .data = &sysctl_perf_cpu_time_max_percent, 2260 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), 2261 .mode = 0644, 2262 .proc_handler = perf_cpu_time_max_percent_handler, 2263 .extra1 = SYSCTL_ZERO, 2264 .extra2 = SYSCTL_ONE_HUNDRED, 2265 }, 2266 { 2267 .procname = "perf_event_max_stack", 2268 .data = &sysctl_perf_event_max_stack, 2269 .maxlen = sizeof(sysctl_perf_event_max_stack), 2270 .mode = 0644, 2271 .proc_handler = perf_event_max_stack_handler, 2272 .extra1 = SYSCTL_ZERO, 2273 .extra2 = (void *)&six_hundred_forty_kb, 2274 }, 2275 { 2276 .procname = "perf_event_max_contexts_per_stack", 2277 .data = &sysctl_perf_event_max_contexts_per_stack, 2278 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), 2279 .mode = 0644, 2280 .proc_handler = perf_event_max_stack_handler, 2281 .extra1 = SYSCTL_ZERO, 2282 .extra2 = SYSCTL_ONE_THOUSAND, 2283 }, 2284 #endif 2285 { 2286 .procname = "panic_on_warn", 2287 .data = &panic_on_warn, 2288 .maxlen = sizeof(int), 2289 .mode = 0644, 2290 .proc_handler = proc_dointvec_minmax, 2291 .extra1 = SYSCTL_ZERO, 2292 .extra2 = SYSCTL_ONE, 2293 }, 2294 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 2295 { 2296 .procname = "timer_migration", 2297 .data = &sysctl_timer_migration, 2298 .maxlen = sizeof(unsigned int), 2299 .mode = 0644, 2300 .proc_handler = timer_migration_handler, 2301 .extra1 = SYSCTL_ZERO, 2302 .extra2 = SYSCTL_ONE, 2303 }, 2304 #endif 2305 #ifdef CONFIG_BPF_SYSCALL 2306 { 2307 .procname = "unprivileged_bpf_disabled", 2308 .data = &sysctl_unprivileged_bpf_disabled, 2309 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), 2310 .mode = 0644, 2311 .proc_handler = bpf_unpriv_handler, 2312 .extra1 = SYSCTL_ZERO, 2313 .extra2 = SYSCTL_TWO, 2314 }, 2315 { 2316 .procname = "bpf_stats_enabled", 2317 .data = &bpf_stats_enabled_key.key, 2318 .maxlen = sizeof(bpf_stats_enabled_key), 2319 .mode = 0644, 2320 .proc_handler = bpf_stats_handler, 2321 }, 2322 #endif 2323 #if defined(CONFIG_TREE_RCU) 2324 { 2325 .procname = "panic_on_rcu_stall", 2326 .data = &sysctl_panic_on_rcu_stall, 2327 .maxlen = sizeof(sysctl_panic_on_rcu_stall), 2328 .mode = 0644, 2329 .proc_handler = proc_dointvec_minmax, 2330 .extra1 = SYSCTL_ZERO, 2331 .extra2 = SYSCTL_ONE, 2332 }, 2333 #endif 2334 #if defined(CONFIG_TREE_RCU) 2335 { 2336 .procname = "max_rcu_stall_to_panic", 2337 .data = &sysctl_max_rcu_stall_to_panic, 2338 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic), 2339 .mode = 0644, 2340 .proc_handler = proc_dointvec_minmax, 2341 .extra1 = SYSCTL_ONE, 2342 .extra2 = SYSCTL_INT_MAX, 2343 }, 2344 #endif 2345 { } 2346 }; 2347 2348 static struct ctl_table vm_table[] = { 2349 { 2350 .procname = "overcommit_memory", 2351 .data = &sysctl_overcommit_memory, 2352 .maxlen = sizeof(sysctl_overcommit_memory), 2353 .mode = 0644, 2354 .proc_handler = overcommit_policy_handler, 2355 .extra1 = SYSCTL_ZERO, 2356 .extra2 = SYSCTL_TWO, 2357 }, 2358 { 2359 .procname = "panic_on_oom", 2360 .data = &sysctl_panic_on_oom, 2361 .maxlen = sizeof(sysctl_panic_on_oom), 2362 .mode = 0644, 2363 .proc_handler = proc_dointvec_minmax, 2364 .extra1 = SYSCTL_ZERO, 2365 .extra2 = SYSCTL_TWO, 2366 }, 2367 { 2368 .procname = "oom_kill_allocating_task", 2369 .data = &sysctl_oom_kill_allocating_task, 2370 .maxlen = sizeof(sysctl_oom_kill_allocating_task), 2371 .mode = 0644, 2372 .proc_handler = proc_dointvec, 2373 }, 2374 { 2375 .procname = "oom_dump_tasks", 2376 .data = &sysctl_oom_dump_tasks, 2377 .maxlen = sizeof(sysctl_oom_dump_tasks), 2378 .mode = 0644, 2379 .proc_handler = proc_dointvec, 2380 }, 2381 { 2382 .procname = "overcommit_ratio", 2383 .data = &sysctl_overcommit_ratio, 2384 .maxlen = sizeof(sysctl_overcommit_ratio), 2385 .mode = 0644, 2386 .proc_handler = overcommit_ratio_handler, 2387 }, 2388 { 2389 .procname = "overcommit_kbytes", 2390 .data = &sysctl_overcommit_kbytes, 2391 .maxlen = sizeof(sysctl_overcommit_kbytes), 2392 .mode = 0644, 2393 .proc_handler = overcommit_kbytes_handler, 2394 }, 2395 { 2396 .procname = "page-cluster", 2397 .data = &page_cluster, 2398 .maxlen = sizeof(int), 2399 .mode = 0644, 2400 .proc_handler = proc_dointvec_minmax, 2401 .extra1 = SYSCTL_ZERO, 2402 }, 2403 { 2404 .procname = "dirty_background_ratio", 2405 .data = &dirty_background_ratio, 2406 .maxlen = sizeof(dirty_background_ratio), 2407 .mode = 0644, 2408 .proc_handler = dirty_background_ratio_handler, 2409 .extra1 = SYSCTL_ZERO, 2410 .extra2 = SYSCTL_ONE_HUNDRED, 2411 }, 2412 { 2413 .procname = "dirty_background_bytes", 2414 .data = &dirty_background_bytes, 2415 .maxlen = sizeof(dirty_background_bytes), 2416 .mode = 0644, 2417 .proc_handler = dirty_background_bytes_handler, 2418 .extra1 = SYSCTL_LONG_ONE, 2419 }, 2420 { 2421 .procname = "dirty_ratio", 2422 .data = &vm_dirty_ratio, 2423 .maxlen = sizeof(vm_dirty_ratio), 2424 .mode = 0644, 2425 .proc_handler = dirty_ratio_handler, 2426 .extra1 = SYSCTL_ZERO, 2427 .extra2 = SYSCTL_ONE_HUNDRED, 2428 }, 2429 { 2430 .procname = "dirty_bytes", 2431 .data = &vm_dirty_bytes, 2432 .maxlen = sizeof(vm_dirty_bytes), 2433 .mode = 0644, 2434 .proc_handler = dirty_bytes_handler, 2435 .extra1 = (void *)&dirty_bytes_min, 2436 }, 2437 { 2438 .procname = "dirty_writeback_centisecs", 2439 .data = &dirty_writeback_interval, 2440 .maxlen = sizeof(dirty_writeback_interval), 2441 .mode = 0644, 2442 .proc_handler = dirty_writeback_centisecs_handler, 2443 }, 2444 { 2445 .procname = "dirty_expire_centisecs", 2446 .data = &dirty_expire_interval, 2447 .maxlen = sizeof(dirty_expire_interval), 2448 .mode = 0644, 2449 .proc_handler = proc_dointvec_minmax, 2450 .extra1 = SYSCTL_ZERO, 2451 }, 2452 { 2453 .procname = "dirtytime_expire_seconds", 2454 .data = &dirtytime_expire_interval, 2455 .maxlen = sizeof(dirtytime_expire_interval), 2456 .mode = 0644, 2457 .proc_handler = dirtytime_interval_handler, 2458 .extra1 = SYSCTL_ZERO, 2459 }, 2460 { 2461 .procname = "swappiness", 2462 .data = &vm_swappiness, 2463 .maxlen = sizeof(vm_swappiness), 2464 .mode = 0644, 2465 .proc_handler = proc_dointvec_minmax, 2466 .extra1 = SYSCTL_ZERO, 2467 .extra2 = SYSCTL_TWO_HUNDRED, 2468 }, 2469 #ifdef CONFIG_HUGETLB_PAGE 2470 { 2471 .procname = "nr_hugepages", 2472 .data = NULL, 2473 .maxlen = sizeof(unsigned long), 2474 .mode = 0644, 2475 .proc_handler = hugetlb_sysctl_handler, 2476 }, 2477 #ifdef CONFIG_NUMA 2478 { 2479 .procname = "nr_hugepages_mempolicy", 2480 .data = NULL, 2481 .maxlen = sizeof(unsigned long), 2482 .mode = 0644, 2483 .proc_handler = &hugetlb_mempolicy_sysctl_handler, 2484 }, 2485 { 2486 .procname = "numa_stat", 2487 .data = &sysctl_vm_numa_stat, 2488 .maxlen = sizeof(int), 2489 .mode = 0644, 2490 .proc_handler = sysctl_vm_numa_stat_handler, 2491 .extra1 = SYSCTL_ZERO, 2492 .extra2 = SYSCTL_ONE, 2493 }, 2494 #endif 2495 { 2496 .procname = "hugetlb_shm_group", 2497 .data = &sysctl_hugetlb_shm_group, 2498 .maxlen = sizeof(gid_t), 2499 .mode = 0644, 2500 .proc_handler = proc_dointvec, 2501 }, 2502 { 2503 .procname = "nr_overcommit_hugepages", 2504 .data = NULL, 2505 .maxlen = sizeof(unsigned long), 2506 .mode = 0644, 2507 .proc_handler = hugetlb_overcommit_handler, 2508 }, 2509 #endif 2510 { 2511 .procname = "lowmem_reserve_ratio", 2512 .data = &sysctl_lowmem_reserve_ratio, 2513 .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 2514 .mode = 0644, 2515 .proc_handler = lowmem_reserve_ratio_sysctl_handler, 2516 }, 2517 { 2518 .procname = "drop_caches", 2519 .data = &sysctl_drop_caches, 2520 .maxlen = sizeof(int), 2521 .mode = 0200, 2522 .proc_handler = drop_caches_sysctl_handler, 2523 .extra1 = SYSCTL_ONE, 2524 .extra2 = SYSCTL_FOUR, 2525 }, 2526 #ifdef CONFIG_COMPACTION 2527 { 2528 .procname = "compact_memory", 2529 .data = NULL, 2530 .maxlen = sizeof(int), 2531 .mode = 0200, 2532 .proc_handler = sysctl_compaction_handler, 2533 }, 2534 { 2535 .procname = "compaction_proactiveness", 2536 .data = &sysctl_compaction_proactiveness, 2537 .maxlen = sizeof(sysctl_compaction_proactiveness), 2538 .mode = 0644, 2539 .proc_handler = compaction_proactiveness_sysctl_handler, 2540 .extra1 = SYSCTL_ZERO, 2541 .extra2 = SYSCTL_ONE_HUNDRED, 2542 }, 2543 { 2544 .procname = "extfrag_threshold", 2545 .data = &sysctl_extfrag_threshold, 2546 .maxlen = sizeof(int), 2547 .mode = 0644, 2548 .proc_handler = proc_dointvec_minmax, 2549 .extra1 = SYSCTL_ZERO, 2550 .extra2 = (void *)&max_extfrag_threshold, 2551 }, 2552 { 2553 .procname = "compact_unevictable_allowed", 2554 .data = &sysctl_compact_unevictable_allowed, 2555 .maxlen = sizeof(int), 2556 .mode = 0644, 2557 .proc_handler = proc_dointvec_minmax_warn_RT_change, 2558 .extra1 = SYSCTL_ZERO, 2559 .extra2 = SYSCTL_ONE, 2560 }, 2561 2562 #endif /* CONFIG_COMPACTION */ 2563 { 2564 .procname = "min_free_kbytes", 2565 .data = &min_free_kbytes, 2566 .maxlen = sizeof(min_free_kbytes), 2567 .mode = 0644, 2568 .proc_handler = min_free_kbytes_sysctl_handler, 2569 .extra1 = SYSCTL_ZERO, 2570 }, 2571 { 2572 .procname = "watermark_boost_factor", 2573 .data = &watermark_boost_factor, 2574 .maxlen = sizeof(watermark_boost_factor), 2575 .mode = 0644, 2576 .proc_handler = proc_dointvec_minmax, 2577 .extra1 = SYSCTL_ZERO, 2578 }, 2579 { 2580 .procname = "watermark_scale_factor", 2581 .data = &watermark_scale_factor, 2582 .maxlen = sizeof(watermark_scale_factor), 2583 .mode = 0644, 2584 .proc_handler = watermark_scale_factor_sysctl_handler, 2585 .extra1 = SYSCTL_ONE, 2586 .extra2 = SYSCTL_THREE_THOUSAND, 2587 }, 2588 { 2589 .procname = "percpu_pagelist_high_fraction", 2590 .data = &percpu_pagelist_high_fraction, 2591 .maxlen = sizeof(percpu_pagelist_high_fraction), 2592 .mode = 0644, 2593 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler, 2594 .extra1 = SYSCTL_ZERO, 2595 }, 2596 { 2597 .procname = "page_lock_unfairness", 2598 .data = &sysctl_page_lock_unfairness, 2599 .maxlen = sizeof(sysctl_page_lock_unfairness), 2600 .mode = 0644, 2601 .proc_handler = proc_dointvec_minmax, 2602 .extra1 = SYSCTL_ZERO, 2603 }, 2604 #ifdef CONFIG_MMU 2605 { 2606 .procname = "max_map_count", 2607 .data = &sysctl_max_map_count, 2608 .maxlen = sizeof(sysctl_max_map_count), 2609 .mode = 0644, 2610 .proc_handler = proc_dointvec_minmax, 2611 .extra1 = SYSCTL_ZERO, 2612 }, 2613 #else 2614 { 2615 .procname = "nr_trim_pages", 2616 .data = &sysctl_nr_trim_pages, 2617 .maxlen = sizeof(sysctl_nr_trim_pages), 2618 .mode = 0644, 2619 .proc_handler = proc_dointvec_minmax, 2620 .extra1 = SYSCTL_ZERO, 2621 }, 2622 #endif 2623 { 2624 .procname = "laptop_mode", 2625 .data = &laptop_mode, 2626 .maxlen = sizeof(laptop_mode), 2627 .mode = 0644, 2628 .proc_handler = proc_dointvec_jiffies, 2629 }, 2630 { 2631 .procname = "vfs_cache_pressure", 2632 .data = &sysctl_vfs_cache_pressure, 2633 .maxlen = sizeof(sysctl_vfs_cache_pressure), 2634 .mode = 0644, 2635 .proc_handler = proc_dointvec_minmax, 2636 .extra1 = SYSCTL_ZERO, 2637 }, 2638 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 2639 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 2640 { 2641 .procname = "legacy_va_layout", 2642 .data = &sysctl_legacy_va_layout, 2643 .maxlen = sizeof(sysctl_legacy_va_layout), 2644 .mode = 0644, 2645 .proc_handler = proc_dointvec_minmax, 2646 .extra1 = SYSCTL_ZERO, 2647 }, 2648 #endif 2649 #ifdef CONFIG_NUMA 2650 { 2651 .procname = "zone_reclaim_mode", 2652 .data = &node_reclaim_mode, 2653 .maxlen = sizeof(node_reclaim_mode), 2654 .mode = 0644, 2655 .proc_handler = proc_dointvec_minmax, 2656 .extra1 = SYSCTL_ZERO, 2657 }, 2658 { 2659 .procname = "min_unmapped_ratio", 2660 .data = &sysctl_min_unmapped_ratio, 2661 .maxlen = sizeof(sysctl_min_unmapped_ratio), 2662 .mode = 0644, 2663 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 2664 .extra1 = SYSCTL_ZERO, 2665 .extra2 = SYSCTL_ONE_HUNDRED, 2666 }, 2667 { 2668 .procname = "min_slab_ratio", 2669 .data = &sysctl_min_slab_ratio, 2670 .maxlen = sizeof(sysctl_min_slab_ratio), 2671 .mode = 0644, 2672 .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 2673 .extra1 = SYSCTL_ZERO, 2674 .extra2 = SYSCTL_ONE_HUNDRED, 2675 }, 2676 #endif 2677 #ifdef CONFIG_SMP 2678 { 2679 .procname = "stat_interval", 2680 .data = &sysctl_stat_interval, 2681 .maxlen = sizeof(sysctl_stat_interval), 2682 .mode = 0644, 2683 .proc_handler = proc_dointvec_jiffies, 2684 }, 2685 { 2686 .procname = "stat_refresh", 2687 .data = NULL, 2688 .maxlen = 0, 2689 .mode = 0600, 2690 .proc_handler = vmstat_refresh, 2691 }, 2692 #endif 2693 #ifdef CONFIG_MMU 2694 { 2695 .procname = "mmap_min_addr", 2696 .data = &dac_mmap_min_addr, 2697 .maxlen = sizeof(unsigned long), 2698 .mode = 0644, 2699 .proc_handler = mmap_min_addr_handler, 2700 }, 2701 #endif 2702 #ifdef CONFIG_NUMA 2703 { 2704 .procname = "numa_zonelist_order", 2705 .data = &numa_zonelist_order, 2706 .maxlen = NUMA_ZONELIST_ORDER_LEN, 2707 .mode = 0644, 2708 .proc_handler = numa_zonelist_order_handler, 2709 }, 2710 #endif 2711 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 2712 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 2713 { 2714 .procname = "vdso_enabled", 2715 #ifdef CONFIG_X86_32 2716 .data = &vdso32_enabled, 2717 .maxlen = sizeof(vdso32_enabled), 2718 #else 2719 .data = &vdso_enabled, 2720 .maxlen = sizeof(vdso_enabled), 2721 #endif 2722 .mode = 0644, 2723 .proc_handler = proc_dointvec, 2724 .extra1 = SYSCTL_ZERO, 2725 }, 2726 #endif 2727 #ifdef CONFIG_HIGHMEM 2728 { 2729 .procname = "highmem_is_dirtyable", 2730 .data = &vm_highmem_is_dirtyable, 2731 .maxlen = sizeof(vm_highmem_is_dirtyable), 2732 .mode = 0644, 2733 .proc_handler = proc_dointvec_minmax, 2734 .extra1 = SYSCTL_ZERO, 2735 .extra2 = SYSCTL_ONE, 2736 }, 2737 #endif 2738 #ifdef CONFIG_MEMORY_FAILURE 2739 { 2740 .procname = "memory_failure_early_kill", 2741 .data = &sysctl_memory_failure_early_kill, 2742 .maxlen = sizeof(sysctl_memory_failure_early_kill), 2743 .mode = 0644, 2744 .proc_handler = proc_dointvec_minmax, 2745 .extra1 = SYSCTL_ZERO, 2746 .extra2 = SYSCTL_ONE, 2747 }, 2748 { 2749 .procname = "memory_failure_recovery", 2750 .data = &sysctl_memory_failure_recovery, 2751 .maxlen = sizeof(sysctl_memory_failure_recovery), 2752 .mode = 0644, 2753 .proc_handler = proc_dointvec_minmax, 2754 .extra1 = SYSCTL_ZERO, 2755 .extra2 = SYSCTL_ONE, 2756 }, 2757 #endif 2758 { 2759 .procname = "user_reserve_kbytes", 2760 .data = &sysctl_user_reserve_kbytes, 2761 .maxlen = sizeof(sysctl_user_reserve_kbytes), 2762 .mode = 0644, 2763 .proc_handler = proc_doulongvec_minmax, 2764 }, 2765 { 2766 .procname = "admin_reserve_kbytes", 2767 .data = &sysctl_admin_reserve_kbytes, 2768 .maxlen = sizeof(sysctl_admin_reserve_kbytes), 2769 .mode = 0644, 2770 .proc_handler = proc_doulongvec_minmax, 2771 }, 2772 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS 2773 { 2774 .procname = "mmap_rnd_bits", 2775 .data = &mmap_rnd_bits, 2776 .maxlen = sizeof(mmap_rnd_bits), 2777 .mode = 0600, 2778 .proc_handler = proc_dointvec_minmax, 2779 .extra1 = (void *)&mmap_rnd_bits_min, 2780 .extra2 = (void *)&mmap_rnd_bits_max, 2781 }, 2782 #endif 2783 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS 2784 { 2785 .procname = "mmap_rnd_compat_bits", 2786 .data = &mmap_rnd_compat_bits, 2787 .maxlen = sizeof(mmap_rnd_compat_bits), 2788 .mode = 0600, 2789 .proc_handler = proc_dointvec_minmax, 2790 .extra1 = (void *)&mmap_rnd_compat_bits_min, 2791 .extra2 = (void *)&mmap_rnd_compat_bits_max, 2792 }, 2793 #endif 2794 #ifdef CONFIG_USERFAULTFD 2795 { 2796 .procname = "unprivileged_userfaultfd", 2797 .data = &sysctl_unprivileged_userfaultfd, 2798 .maxlen = sizeof(sysctl_unprivileged_userfaultfd), 2799 .mode = 0644, 2800 .proc_handler = proc_dointvec_minmax, 2801 .extra1 = SYSCTL_ZERO, 2802 .extra2 = SYSCTL_ONE, 2803 }, 2804 #endif 2805 { } 2806 }; 2807 2808 static struct ctl_table debug_table[] = { 2809 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE 2810 { 2811 .procname = "exception-trace", 2812 .data = &show_unhandled_signals, 2813 .maxlen = sizeof(int), 2814 .mode = 0644, 2815 .proc_handler = proc_dointvec 2816 }, 2817 #endif 2818 { } 2819 }; 2820 2821 static struct ctl_table dev_table[] = { 2822 { } 2823 }; 2824 2825 DECLARE_SYSCTL_BASE(kernel, kern_table); 2826 DECLARE_SYSCTL_BASE(vm, vm_table); 2827 DECLARE_SYSCTL_BASE(debug, debug_table); 2828 DECLARE_SYSCTL_BASE(dev, dev_table); 2829 2830 int __init sysctl_init_bases(void) 2831 { 2832 register_sysctl_base(kernel); 2833 register_sysctl_base(vm); 2834 register_sysctl_base(debug); 2835 register_sysctl_base(dev); 2836 2837 return 0; 2838 } 2839 #endif /* CONFIG_SYSCTL */ 2840 /* 2841 * No sense putting this after each symbol definition, twice, 2842 * exception granted :-) 2843 */ 2844 EXPORT_SYMBOL(proc_dobool); 2845 EXPORT_SYMBOL(proc_dointvec); 2846 EXPORT_SYMBOL(proc_douintvec); 2847 EXPORT_SYMBOL(proc_dointvec_jiffies); 2848 EXPORT_SYMBOL(proc_dointvec_minmax); 2849 EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 2850 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 2851 EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 2852 EXPORT_SYMBOL(proc_dostring); 2853 EXPORT_SYMBOL(proc_doulongvec_minmax); 2854 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 2855 EXPORT_SYMBOL(proc_do_large_bitmap); 2856