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/slab.h> 25 #include <linux/sysctl.h> 26 #include <linux/bitmap.h> 27 #include <linux/signal.h> 28 #include <linux/panic.h> 29 #include <linux/printk.h> 30 #include <linux/proc_fs.h> 31 #include <linux/security.h> 32 #include <linux/ctype.h> 33 #include <linux/kmemleak.h> 34 #include <linux/filter.h> 35 #include <linux/fs.h> 36 #include <linux/init.h> 37 #include <linux/kernel.h> 38 #include <linux/kobject.h> 39 #include <linux/net.h> 40 #include <linux/sysrq.h> 41 #include <linux/highuid.h> 42 #include <linux/writeback.h> 43 #include <linux/ratelimit.h> 44 #include <linux/hugetlb.h> 45 #include <linux/initrd.h> 46 #include <linux/key.h> 47 #include <linux/times.h> 48 #include <linux/limits.h> 49 #include <linux/dcache.h> 50 #include <linux/syscalls.h> 51 #include <linux/nfs_fs.h> 52 #include <linux/acpi.h> 53 #include <linux/reboot.h> 54 #include <linux/ftrace.h> 55 #include <linux/perf_event.h> 56 #include <linux/oom.h> 57 #include <linux/kmod.h> 58 #include <linux/capability.h> 59 #include <linux/binfmts.h> 60 #include <linux/sched/sysctl.h> 61 #include <linux/mount.h> 62 #include <linux/userfaultfd_k.h> 63 #include <linux/pid.h> 64 65 #include "../lib/kstrtox.h" 66 67 #include <linux/uaccess.h> 68 #include <asm/processor.h> 69 70 #ifdef CONFIG_X86 71 #include <asm/nmi.h> 72 #include <asm/stacktrace.h> 73 #include <asm/io.h> 74 #endif 75 #ifdef CONFIG_SPARC 76 #include <asm/setup.h> 77 #endif 78 #ifdef CONFIG_RT_MUTEXES 79 #include <linux/rtmutex.h> 80 #endif 81 82 /* shared constants to be used in various sysctls */ 83 const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 }; 84 EXPORT_SYMBOL(sysctl_vals); 85 86 const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX }; 87 EXPORT_SYMBOL_GPL(sysctl_long_vals); 88 89 #if defined(CONFIG_SYSCTL) 90 91 /* Constants used for minimum and maximum */ 92 93 #ifdef CONFIG_PERF_EVENTS 94 static const int six_hundred_forty_kb = 640 * 1024; 95 #endif 96 97 98 static const int ngroups_max = NGROUPS_MAX; 99 static const int cap_last_cap = CAP_LAST_CAP; 100 101 #ifdef CONFIG_PROC_SYSCTL 102 103 /** 104 * enum sysctl_writes_mode - supported sysctl write modes 105 * 106 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value 107 * to be written, and multiple writes on the same sysctl file descriptor 108 * will rewrite the sysctl value, regardless of file position. No warning 109 * is issued when the initial position is not 0. 110 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is 111 * not 0. 112 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at 113 * file position 0 and the value must be fully contained in the buffer 114 * sent to the write syscall. If dealing with strings respect the file 115 * position, but restrict this to the max length of the buffer, anything 116 * passed the max length will be ignored. Multiple writes will append 117 * to the buffer. 118 * 119 * These write modes control how current file position affects the behavior of 120 * updating sysctl values through the proc interface on each write. 121 */ 122 enum sysctl_writes_mode { 123 SYSCTL_WRITES_LEGACY = -1, 124 SYSCTL_WRITES_WARN = 0, 125 SYSCTL_WRITES_STRICT = 1, 126 }; 127 128 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; 129 #endif /* CONFIG_PROC_SYSCTL */ 130 131 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 132 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 133 int sysctl_legacy_va_layout; 134 #endif 135 136 #endif /* CONFIG_SYSCTL */ 137 138 /* 139 * /proc/sys support 140 */ 141 142 #ifdef CONFIG_PROC_SYSCTL 143 144 static int _proc_do_string(char *data, int maxlen, int write, 145 char *buffer, size_t *lenp, loff_t *ppos) 146 { 147 size_t len; 148 char c, *p; 149 150 if (!data || !maxlen || !*lenp) { 151 *lenp = 0; 152 return 0; 153 } 154 155 if (write) { 156 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { 157 /* Only continue writes not past the end of buffer. */ 158 len = strlen(data); 159 if (len > maxlen - 1) 160 len = maxlen - 1; 161 162 if (*ppos > len) 163 return 0; 164 len = *ppos; 165 } else { 166 /* Start writing from beginning of buffer. */ 167 len = 0; 168 } 169 170 *ppos += *lenp; 171 p = buffer; 172 while ((p - buffer) < *lenp && len < maxlen - 1) { 173 c = *(p++); 174 if (c == 0 || c == '\n') 175 break; 176 data[len++] = c; 177 } 178 data[len] = 0; 179 } else { 180 len = strlen(data); 181 if (len > maxlen) 182 len = maxlen; 183 184 if (*ppos > len) { 185 *lenp = 0; 186 return 0; 187 } 188 189 data += *ppos; 190 len -= *ppos; 191 192 if (len > *lenp) 193 len = *lenp; 194 if (len) 195 memcpy(buffer, data, len); 196 if (len < *lenp) { 197 buffer[len] = '\n'; 198 len++; 199 } 200 *lenp = len; 201 *ppos += len; 202 } 203 return 0; 204 } 205 206 static void warn_sysctl_write(const struct ctl_table *table) 207 { 208 pr_warn_once("%s wrote to %s when file position was not 0!\n" 209 "This will not be supported in the future. To silence this\n" 210 "warning, set kernel.sysctl_writes_strict = -1\n", 211 current->comm, table->procname); 212 } 213 214 /** 215 * proc_first_pos_non_zero_ignore - check if first position is allowed 216 * @ppos: file position 217 * @table: the sysctl table 218 * 219 * Returns true if the first position is non-zero and the sysctl_writes_strict 220 * mode indicates this is not allowed for numeric input types. String proc 221 * handlers can ignore the return value. 222 */ 223 static bool proc_first_pos_non_zero_ignore(loff_t *ppos, 224 const struct ctl_table *table) 225 { 226 if (!*ppos) 227 return false; 228 229 switch (sysctl_writes_strict) { 230 case SYSCTL_WRITES_STRICT: 231 return true; 232 case SYSCTL_WRITES_WARN: 233 warn_sysctl_write(table); 234 return false; 235 default: 236 return false; 237 } 238 } 239 240 /** 241 * proc_dostring - read a string sysctl 242 * @table: the sysctl table 243 * @write: %TRUE if this is a write to the sysctl file 244 * @buffer: the user buffer 245 * @lenp: the size of the user buffer 246 * @ppos: file position 247 * 248 * Reads/writes a string from/to the user buffer. If the kernel 249 * buffer provided is not large enough to hold the string, the 250 * string is truncated. The copied string is %NULL-terminated. 251 * If the string is being read by the user process, it is copied 252 * and a newline '\n' is added. It is truncated if the buffer is 253 * not large enough. 254 * 255 * Returns 0 on success. 256 */ 257 int proc_dostring(const struct ctl_table *table, int write, 258 void *buffer, size_t *lenp, loff_t *ppos) 259 { 260 if (write) 261 proc_first_pos_non_zero_ignore(ppos, table); 262 263 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, 264 ppos); 265 } 266 267 static void proc_skip_spaces(char **buf, size_t *size) 268 { 269 while (*size) { 270 if (!isspace(**buf)) 271 break; 272 (*size)--; 273 (*buf)++; 274 } 275 } 276 277 static void proc_skip_char(char **buf, size_t *size, const char v) 278 { 279 while (*size) { 280 if (**buf != v) 281 break; 282 (*size)--; 283 (*buf)++; 284 } 285 } 286 287 /** 288 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only 289 * fail on overflow 290 * 291 * @cp: kernel buffer containing the string to parse 292 * @endp: pointer to store the trailing characters 293 * @base: the base to use 294 * @res: where the parsed integer will be stored 295 * 296 * In case of success 0 is returned and @res will contain the parsed integer, 297 * @endp will hold any trailing characters. 298 * This function will fail the parse on overflow. If there wasn't an overflow 299 * the function will defer the decision what characters count as invalid to the 300 * caller. 301 */ 302 static int strtoul_lenient(const char *cp, char **endp, unsigned int base, 303 unsigned long *res) 304 { 305 unsigned long long result; 306 unsigned int rv; 307 308 cp = _parse_integer_fixup_radix(cp, &base); 309 rv = _parse_integer(cp, base, &result); 310 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) 311 return -ERANGE; 312 313 cp += rv; 314 315 if (endp) 316 *endp = (char *)cp; 317 318 *res = (unsigned long)result; 319 return 0; 320 } 321 322 #define TMPBUFLEN 22 323 /** 324 * proc_get_long - reads an ASCII formatted integer from a user buffer 325 * 326 * @buf: a kernel buffer 327 * @size: size of the kernel buffer 328 * @val: this is where the number will be stored 329 * @neg: set to %TRUE if number is negative 330 * @perm_tr: a vector which contains the allowed trailers 331 * @perm_tr_len: size of the perm_tr vector 332 * @tr: pointer to store the trailer character 333 * 334 * In case of success %0 is returned and @buf and @size are updated with 335 * the amount of bytes read. If @tr is non-NULL and a trailing 336 * character exists (size is non-zero after returning from this 337 * function), @tr is updated with the trailing character. 338 */ 339 static int proc_get_long(char **buf, size_t *size, 340 unsigned long *val, bool *neg, 341 const char *perm_tr, unsigned perm_tr_len, char *tr) 342 { 343 char *p, tmp[TMPBUFLEN]; 344 ssize_t len = *size; 345 346 if (len <= 0) 347 return -EINVAL; 348 349 if (len > TMPBUFLEN - 1) 350 len = TMPBUFLEN - 1; 351 352 memcpy(tmp, *buf, len); 353 354 tmp[len] = 0; 355 p = tmp; 356 if (*p == '-' && *size > 1) { 357 *neg = true; 358 p++; 359 } else 360 *neg = false; 361 if (!isdigit(*p)) 362 return -EINVAL; 363 364 if (strtoul_lenient(p, &p, 0, val)) 365 return -EINVAL; 366 367 len = p - tmp; 368 369 /* We don't know if the next char is whitespace thus we may accept 370 * invalid integers (e.g. 1234...a) or two integers instead of one 371 * (e.g. 123...1). So lets not allow such large numbers. */ 372 if (len == TMPBUFLEN - 1) 373 return -EINVAL; 374 375 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 376 return -EINVAL; 377 378 if (tr && (len < *size)) 379 *tr = *p; 380 381 *buf += len; 382 *size -= len; 383 384 return 0; 385 } 386 387 /** 388 * proc_put_long - converts an integer to a decimal ASCII formatted string 389 * 390 * @buf: the user buffer 391 * @size: the size of the user buffer 392 * @val: the integer to be converted 393 * @neg: sign of the number, %TRUE for negative 394 * 395 * In case of success @buf and @size are updated with the amount of bytes 396 * written. 397 */ 398 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg) 399 { 400 int len; 401 char tmp[TMPBUFLEN], *p = tmp; 402 403 sprintf(p, "%s%lu", neg ? "-" : "", val); 404 len = strlen(tmp); 405 if (len > *size) 406 len = *size; 407 memcpy(*buf, tmp, len); 408 *size -= len; 409 *buf += len; 410 } 411 #undef TMPBUFLEN 412 413 static void proc_put_char(void **buf, size_t *size, char c) 414 { 415 if (*size) { 416 char **buffer = (char **)buf; 417 **buffer = c; 418 419 (*size)--; 420 (*buffer)++; 421 *buf = *buffer; 422 } 423 } 424 425 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 426 int *valp, 427 int write, void *data) 428 { 429 if (write) { 430 if (*negp) { 431 if (*lvalp > (unsigned long) INT_MAX + 1) 432 return -EINVAL; 433 WRITE_ONCE(*valp, -*lvalp); 434 } else { 435 if (*lvalp > (unsigned long) INT_MAX) 436 return -EINVAL; 437 WRITE_ONCE(*valp, *lvalp); 438 } 439 } else { 440 int val = READ_ONCE(*valp); 441 if (val < 0) { 442 *negp = true; 443 *lvalp = -(unsigned long)val; 444 } else { 445 *negp = false; 446 *lvalp = (unsigned long)val; 447 } 448 } 449 return 0; 450 } 451 452 static int do_proc_douintvec_conv(unsigned long *lvalp, 453 unsigned int *valp, 454 int write, void *data) 455 { 456 if (write) { 457 if (*lvalp > UINT_MAX) 458 return -EINVAL; 459 WRITE_ONCE(*valp, *lvalp); 460 } else { 461 unsigned int val = READ_ONCE(*valp); 462 *lvalp = (unsigned long)val; 463 } 464 return 0; 465 } 466 467 static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 468 469 static int __do_proc_dointvec(void *tbl_data, const struct ctl_table *table, 470 int write, void *buffer, 471 size_t *lenp, loff_t *ppos, 472 int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 473 int write, void *data), 474 void *data) 475 { 476 int *i, vleft, first = 1, err = 0; 477 size_t left; 478 char *p; 479 480 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 481 *lenp = 0; 482 return 0; 483 } 484 485 i = (int *) tbl_data; 486 vleft = table->maxlen / sizeof(*i); 487 left = *lenp; 488 489 if (!conv) 490 conv = do_proc_dointvec_conv; 491 492 if (write) { 493 if (proc_first_pos_non_zero_ignore(ppos, table)) 494 goto out; 495 496 if (left > PAGE_SIZE - 1) 497 left = PAGE_SIZE - 1; 498 p = buffer; 499 } 500 501 for (; left && vleft--; i++, first=0) { 502 unsigned long lval; 503 bool neg; 504 505 if (write) { 506 proc_skip_spaces(&p, &left); 507 508 if (!left) 509 break; 510 err = proc_get_long(&p, &left, &lval, &neg, 511 proc_wspace_sep, 512 sizeof(proc_wspace_sep), NULL); 513 if (err) 514 break; 515 if (conv(&neg, &lval, i, 1, data)) { 516 err = -EINVAL; 517 break; 518 } 519 } else { 520 if (conv(&neg, &lval, i, 0, data)) { 521 err = -EINVAL; 522 break; 523 } 524 if (!first) 525 proc_put_char(&buffer, &left, '\t'); 526 proc_put_long(&buffer, &left, lval, neg); 527 } 528 } 529 530 if (!write && !first && left && !err) 531 proc_put_char(&buffer, &left, '\n'); 532 if (write && !err && left) 533 proc_skip_spaces(&p, &left); 534 if (write && first) 535 return err ? : -EINVAL; 536 *lenp -= left; 537 out: 538 *ppos += *lenp; 539 return err; 540 } 541 542 static int do_proc_dointvec(const struct ctl_table *table, int write, 543 void *buffer, size_t *lenp, loff_t *ppos, 544 int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 545 int write, void *data), 546 void *data) 547 { 548 return __do_proc_dointvec(table->data, table, write, 549 buffer, lenp, ppos, conv, data); 550 } 551 552 static int do_proc_douintvec_w(unsigned int *tbl_data, 553 const struct ctl_table *table, 554 void *buffer, 555 size_t *lenp, loff_t *ppos, 556 int (*conv)(unsigned long *lvalp, 557 unsigned int *valp, 558 int write, void *data), 559 void *data) 560 { 561 unsigned long lval; 562 int err = 0; 563 size_t left; 564 bool neg; 565 char *p = buffer; 566 567 left = *lenp; 568 569 if (proc_first_pos_non_zero_ignore(ppos, table)) 570 goto bail_early; 571 572 if (left > PAGE_SIZE - 1) 573 left = PAGE_SIZE - 1; 574 575 proc_skip_spaces(&p, &left); 576 if (!left) { 577 err = -EINVAL; 578 goto out_free; 579 } 580 581 err = proc_get_long(&p, &left, &lval, &neg, 582 proc_wspace_sep, 583 sizeof(proc_wspace_sep), NULL); 584 if (err || neg) { 585 err = -EINVAL; 586 goto out_free; 587 } 588 589 if (conv(&lval, tbl_data, 1, data)) { 590 err = -EINVAL; 591 goto out_free; 592 } 593 594 if (!err && left) 595 proc_skip_spaces(&p, &left); 596 597 out_free: 598 if (err) 599 return -EINVAL; 600 601 return 0; 602 603 /* This is in keeping with old __do_proc_dointvec() */ 604 bail_early: 605 *ppos += *lenp; 606 return err; 607 } 608 609 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer, 610 size_t *lenp, loff_t *ppos, 611 int (*conv)(unsigned long *lvalp, 612 unsigned int *valp, 613 int write, void *data), 614 void *data) 615 { 616 unsigned long lval; 617 int err = 0; 618 size_t left; 619 620 left = *lenp; 621 622 if (conv(&lval, tbl_data, 0, data)) { 623 err = -EINVAL; 624 goto out; 625 } 626 627 proc_put_long(&buffer, &left, lval, false); 628 if (!left) 629 goto out; 630 631 proc_put_char(&buffer, &left, '\n'); 632 633 out: 634 *lenp -= left; 635 *ppos += *lenp; 636 637 return err; 638 } 639 640 static int __do_proc_douintvec(void *tbl_data, const struct ctl_table *table, 641 int write, void *buffer, 642 size_t *lenp, loff_t *ppos, 643 int (*conv)(unsigned long *lvalp, 644 unsigned int *valp, 645 int write, void *data), 646 void *data) 647 { 648 unsigned int *i, vleft; 649 650 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 651 *lenp = 0; 652 return 0; 653 } 654 655 i = (unsigned int *) tbl_data; 656 vleft = table->maxlen / sizeof(*i); 657 658 /* 659 * Arrays are not supported, keep this simple. *Do not* add 660 * support for them. 661 */ 662 if (vleft != 1) { 663 *lenp = 0; 664 return -EINVAL; 665 } 666 667 if (!conv) 668 conv = do_proc_douintvec_conv; 669 670 if (write) 671 return do_proc_douintvec_w(i, table, buffer, lenp, ppos, 672 conv, data); 673 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); 674 } 675 676 int do_proc_douintvec(const struct ctl_table *table, int write, 677 void *buffer, size_t *lenp, loff_t *ppos, 678 int (*conv)(unsigned long *lvalp, 679 unsigned int *valp, 680 int write, void *data), 681 void *data) 682 { 683 return __do_proc_douintvec(table->data, table, write, 684 buffer, lenp, ppos, conv, data); 685 } 686 687 /** 688 * proc_dobool - read/write a bool 689 * @table: the sysctl table 690 * @write: %TRUE if this is a write to the sysctl file 691 * @buffer: the user buffer 692 * @lenp: the size of the user buffer 693 * @ppos: file position 694 * 695 * Reads/writes one integer value from/to the user buffer, 696 * treated as an ASCII string. 697 * 698 * table->data must point to a bool variable and table->maxlen must 699 * be sizeof(bool). 700 * 701 * Returns 0 on success. 702 */ 703 int proc_dobool(const struct ctl_table *table, int write, void *buffer, 704 size_t *lenp, loff_t *ppos) 705 { 706 struct ctl_table tmp; 707 bool *data = table->data; 708 int res, val; 709 710 /* Do not support arrays yet. */ 711 if (table->maxlen != sizeof(bool)) 712 return -EINVAL; 713 714 tmp = *table; 715 tmp.maxlen = sizeof(val); 716 tmp.data = &val; 717 718 val = READ_ONCE(*data); 719 res = proc_dointvec(&tmp, write, buffer, lenp, ppos); 720 if (res) 721 return res; 722 if (write) 723 WRITE_ONCE(*data, val); 724 return 0; 725 } 726 727 /** 728 * proc_dointvec - read a vector of integers 729 * @table: the sysctl table 730 * @write: %TRUE if this is a write to the sysctl file 731 * @buffer: the user buffer 732 * @lenp: the size of the user buffer 733 * @ppos: file position 734 * 735 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 736 * values from/to the user buffer, treated as an ASCII string. 737 * 738 * Returns 0 on success. 739 */ 740 int proc_dointvec(const struct ctl_table *table, int write, void *buffer, 741 size_t *lenp, loff_t *ppos) 742 { 743 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 744 } 745 746 /** 747 * proc_douintvec - read a vector of unsigned integers 748 * @table: the sysctl table 749 * @write: %TRUE if this is a write to the sysctl file 750 * @buffer: the user buffer 751 * @lenp: the size of the user buffer 752 * @ppos: file position 753 * 754 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 755 * values from/to the user buffer, treated as an ASCII string. 756 * 757 * Returns 0 on success. 758 */ 759 int proc_douintvec(const struct ctl_table *table, int write, void *buffer, 760 size_t *lenp, loff_t *ppos) 761 { 762 return do_proc_douintvec(table, write, buffer, lenp, ppos, 763 do_proc_douintvec_conv, NULL); 764 } 765 766 /* 767 * Taint values can only be increased 768 * This means we can safely use a temporary. 769 */ 770 static int proc_taint(const struct ctl_table *table, int write, 771 void *buffer, size_t *lenp, loff_t *ppos) 772 { 773 struct ctl_table t; 774 unsigned long tmptaint = get_taint(); 775 int err; 776 777 if (write && !capable(CAP_SYS_ADMIN)) 778 return -EPERM; 779 780 t = *table; 781 t.data = &tmptaint; 782 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 783 if (err < 0) 784 return err; 785 786 if (write) { 787 int i; 788 789 /* 790 * If we are relying on panic_on_taint not producing 791 * false positives due to userspace input, bail out 792 * before setting the requested taint flags. 793 */ 794 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint)) 795 return -EINVAL; 796 797 /* 798 * Poor man's atomic or. Not worth adding a primitive 799 * to everyone's atomic.h for this 800 */ 801 for (i = 0; i < TAINT_FLAGS_COUNT; i++) 802 if ((1UL << i) & tmptaint) 803 add_taint(i, LOCKDEP_STILL_OK); 804 } 805 806 return err; 807 } 808 809 /** 810 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure 811 * @min: pointer to minimum allowable value 812 * @max: pointer to maximum allowable value 813 * 814 * The do_proc_dointvec_minmax_conv_param structure provides the 815 * minimum and maximum values for doing range checking for those sysctl 816 * parameters that use the proc_dointvec_minmax() handler. 817 */ 818 struct do_proc_dointvec_minmax_conv_param { 819 int *min; 820 int *max; 821 }; 822 823 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 824 int *valp, 825 int write, void *data) 826 { 827 int tmp, ret; 828 struct do_proc_dointvec_minmax_conv_param *param = data; 829 /* 830 * If writing, first do so via a temporary local int so we can 831 * bounds-check it before touching *valp. 832 */ 833 int *ip = write ? &tmp : valp; 834 835 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); 836 if (ret) 837 return ret; 838 839 if (write) { 840 if ((param->min && *param->min > tmp) || 841 (param->max && *param->max < tmp)) 842 return -EINVAL; 843 WRITE_ONCE(*valp, tmp); 844 } 845 846 return 0; 847 } 848 849 /** 850 * proc_dointvec_minmax - read a vector of integers with min/max values 851 * @table: the sysctl table 852 * @write: %TRUE if this is a write to the sysctl file 853 * @buffer: the user buffer 854 * @lenp: the size of the user buffer 855 * @ppos: file position 856 * 857 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 858 * values from/to the user buffer, treated as an ASCII string. 859 * 860 * This routine will ensure the values are within the range specified by 861 * table->extra1 (min) and table->extra2 (max). 862 * 863 * Returns 0 on success or -EINVAL on write when the range check fails. 864 */ 865 int proc_dointvec_minmax(const struct ctl_table *table, int write, 866 void *buffer, size_t *lenp, loff_t *ppos) 867 { 868 struct do_proc_dointvec_minmax_conv_param param = { 869 .min = (int *) table->extra1, 870 .max = (int *) table->extra2, 871 }; 872 return do_proc_dointvec(table, write, buffer, lenp, ppos, 873 do_proc_dointvec_minmax_conv, ¶m); 874 } 875 876 /** 877 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure 878 * @min: pointer to minimum allowable value 879 * @max: pointer to maximum allowable value 880 * 881 * The do_proc_douintvec_minmax_conv_param structure provides the 882 * minimum and maximum values for doing range checking for those sysctl 883 * parameters that use the proc_douintvec_minmax() handler. 884 */ 885 struct do_proc_douintvec_minmax_conv_param { 886 unsigned int *min; 887 unsigned int *max; 888 }; 889 890 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, 891 unsigned int *valp, 892 int write, void *data) 893 { 894 int ret; 895 unsigned int tmp; 896 struct do_proc_douintvec_minmax_conv_param *param = data; 897 /* write via temporary local uint for bounds-checking */ 898 unsigned int *up = write ? &tmp : valp; 899 900 ret = do_proc_douintvec_conv(lvalp, up, write, data); 901 if (ret) 902 return ret; 903 904 if (write) { 905 if ((param->min && *param->min > tmp) || 906 (param->max && *param->max < tmp)) 907 return -ERANGE; 908 909 WRITE_ONCE(*valp, tmp); 910 } 911 912 return 0; 913 } 914 915 /** 916 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values 917 * @table: the sysctl table 918 * @write: %TRUE if this is a write to the sysctl file 919 * @buffer: the user buffer 920 * @lenp: the size of the user buffer 921 * @ppos: file position 922 * 923 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 924 * values from/to the user buffer, treated as an ASCII string. Negative 925 * strings are not allowed. 926 * 927 * This routine will ensure the values are within the range specified by 928 * table->extra1 (min) and table->extra2 (max). There is a final sanity 929 * check for UINT_MAX to avoid having to support wrap around uses from 930 * userspace. 931 * 932 * Returns 0 on success or -ERANGE on write when the range check fails. 933 */ 934 int proc_douintvec_minmax(const struct ctl_table *table, int write, 935 void *buffer, size_t *lenp, loff_t *ppos) 936 { 937 struct do_proc_douintvec_minmax_conv_param param = { 938 .min = (unsigned int *) table->extra1, 939 .max = (unsigned int *) table->extra2, 940 }; 941 return do_proc_douintvec(table, write, buffer, lenp, ppos, 942 do_proc_douintvec_minmax_conv, ¶m); 943 } 944 945 /** 946 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values 947 * @table: the sysctl table 948 * @write: %TRUE if this is a write to the sysctl file 949 * @buffer: the user buffer 950 * @lenp: the size of the user buffer 951 * @ppos: file position 952 * 953 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars 954 * values from/to the user buffer, treated as an ASCII string. Negative 955 * strings are not allowed. 956 * 957 * This routine will ensure the values are within the range specified by 958 * table->extra1 (min) and table->extra2 (max). 959 * 960 * Returns 0 on success or an error on write when the range check fails. 961 */ 962 int proc_dou8vec_minmax(const struct ctl_table *table, int write, 963 void *buffer, size_t *lenp, loff_t *ppos) 964 { 965 struct ctl_table tmp; 966 unsigned int min = 0, max = 255U, val; 967 u8 *data = table->data; 968 struct do_proc_douintvec_minmax_conv_param param = { 969 .min = &min, 970 .max = &max, 971 }; 972 int res; 973 974 /* Do not support arrays yet. */ 975 if (table->maxlen != sizeof(u8)) 976 return -EINVAL; 977 978 if (table->extra1) 979 min = *(unsigned int *) table->extra1; 980 if (table->extra2) 981 max = *(unsigned int *) table->extra2; 982 983 tmp = *table; 984 985 tmp.maxlen = sizeof(val); 986 tmp.data = &val; 987 val = READ_ONCE(*data); 988 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos, 989 do_proc_douintvec_minmax_conv, ¶m); 990 if (res) 991 return res; 992 if (write) 993 WRITE_ONCE(*data, val); 994 return 0; 995 } 996 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax); 997 998 #ifdef CONFIG_MAGIC_SYSRQ 999 static int sysrq_sysctl_handler(const struct ctl_table *table, int write, 1000 void *buffer, size_t *lenp, loff_t *ppos) 1001 { 1002 int tmp, ret; 1003 1004 tmp = sysrq_mask(); 1005 1006 ret = __do_proc_dointvec(&tmp, table, write, buffer, 1007 lenp, ppos, NULL, NULL); 1008 if (ret || !write) 1009 return ret; 1010 1011 if (write) 1012 sysrq_toggle_support(tmp); 1013 1014 return 0; 1015 } 1016 #endif 1017 1018 static int __do_proc_doulongvec_minmax(void *data, 1019 const struct ctl_table *table, int write, 1020 void *buffer, size_t *lenp, loff_t *ppos, 1021 unsigned long convmul, unsigned long convdiv) 1022 { 1023 unsigned long *i, *min, *max; 1024 int vleft, first = 1, err = 0; 1025 size_t left; 1026 char *p; 1027 1028 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 1029 *lenp = 0; 1030 return 0; 1031 } 1032 1033 i = data; 1034 min = table->extra1; 1035 max = table->extra2; 1036 vleft = table->maxlen / sizeof(unsigned long); 1037 left = *lenp; 1038 1039 if (write) { 1040 if (proc_first_pos_non_zero_ignore(ppos, table)) 1041 goto out; 1042 1043 if (left > PAGE_SIZE - 1) 1044 left = PAGE_SIZE - 1; 1045 p = buffer; 1046 } 1047 1048 for (; left && vleft--; i++, first = 0) { 1049 unsigned long val; 1050 1051 if (write) { 1052 bool neg; 1053 1054 proc_skip_spaces(&p, &left); 1055 if (!left) 1056 break; 1057 1058 err = proc_get_long(&p, &left, &val, &neg, 1059 proc_wspace_sep, 1060 sizeof(proc_wspace_sep), NULL); 1061 if (err || neg) { 1062 err = -EINVAL; 1063 break; 1064 } 1065 1066 val = convmul * val / convdiv; 1067 if ((min && val < *min) || (max && val > *max)) { 1068 err = -EINVAL; 1069 break; 1070 } 1071 WRITE_ONCE(*i, val); 1072 } else { 1073 val = convdiv * READ_ONCE(*i) / convmul; 1074 if (!first) 1075 proc_put_char(&buffer, &left, '\t'); 1076 proc_put_long(&buffer, &left, val, false); 1077 } 1078 } 1079 1080 if (!write && !first && left && !err) 1081 proc_put_char(&buffer, &left, '\n'); 1082 if (write && !err) 1083 proc_skip_spaces(&p, &left); 1084 if (write && first) 1085 return err ? : -EINVAL; 1086 *lenp -= left; 1087 out: 1088 *ppos += *lenp; 1089 return err; 1090 } 1091 1092 static int do_proc_doulongvec_minmax(const struct ctl_table *table, int write, 1093 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, 1094 unsigned long convdiv) 1095 { 1096 return __do_proc_doulongvec_minmax(table->data, table, write, 1097 buffer, lenp, ppos, convmul, convdiv); 1098 } 1099 1100 /** 1101 * proc_doulongvec_minmax - read a vector of long integers with min/max values 1102 * @table: the sysctl table 1103 * @write: %TRUE if this is a write to the sysctl file 1104 * @buffer: the user buffer 1105 * @lenp: the size of the user buffer 1106 * @ppos: file position 1107 * 1108 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1109 * values from/to the user buffer, treated as an ASCII string. 1110 * 1111 * This routine will ensure the values are within the range specified by 1112 * table->extra1 (min) and table->extra2 (max). 1113 * 1114 * Returns 0 on success. 1115 */ 1116 int proc_doulongvec_minmax(const struct ctl_table *table, int write, 1117 void *buffer, size_t *lenp, loff_t *ppos) 1118 { 1119 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 1120 } 1121 1122 /** 1123 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 1124 * @table: the sysctl table 1125 * @write: %TRUE if this is a write to the sysctl file 1126 * @buffer: the user buffer 1127 * @lenp: the size of the user buffer 1128 * @ppos: file position 1129 * 1130 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1131 * values from/to the user buffer, treated as an ASCII string. The values 1132 * are treated as milliseconds, and converted to jiffies when they are stored. 1133 * 1134 * This routine will ensure the values are within the range specified by 1135 * table->extra1 (min) and table->extra2 (max). 1136 * 1137 * Returns 0 on success. 1138 */ 1139 int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int write, 1140 void *buffer, size_t *lenp, loff_t *ppos) 1141 { 1142 return do_proc_doulongvec_minmax(table, write, buffer, 1143 lenp, ppos, HZ, 1000l); 1144 } 1145 1146 1147 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 1148 int *valp, 1149 int write, void *data) 1150 { 1151 if (write) { 1152 if (*lvalp > INT_MAX / HZ) 1153 return 1; 1154 if (*negp) 1155 WRITE_ONCE(*valp, -*lvalp * HZ); 1156 else 1157 WRITE_ONCE(*valp, *lvalp * HZ); 1158 } else { 1159 int val = READ_ONCE(*valp); 1160 unsigned long lval; 1161 if (val < 0) { 1162 *negp = true; 1163 lval = -(unsigned long)val; 1164 } else { 1165 *negp = false; 1166 lval = (unsigned long)val; 1167 } 1168 *lvalp = lval / HZ; 1169 } 1170 return 0; 1171 } 1172 1173 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 1174 int *valp, 1175 int write, void *data) 1176 { 1177 if (write) { 1178 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 1179 return 1; 1180 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 1181 } else { 1182 int val = *valp; 1183 unsigned long lval; 1184 if (val < 0) { 1185 *negp = true; 1186 lval = -(unsigned long)val; 1187 } else { 1188 *negp = false; 1189 lval = (unsigned long)val; 1190 } 1191 *lvalp = jiffies_to_clock_t(lval); 1192 } 1193 return 0; 1194 } 1195 1196 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 1197 int *valp, 1198 int write, void *data) 1199 { 1200 if (write) { 1201 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 1202 1203 if (jif > INT_MAX) 1204 return 1; 1205 WRITE_ONCE(*valp, (int)jif); 1206 } else { 1207 int val = READ_ONCE(*valp); 1208 unsigned long lval; 1209 if (val < 0) { 1210 *negp = true; 1211 lval = -(unsigned long)val; 1212 } else { 1213 *negp = false; 1214 lval = (unsigned long)val; 1215 } 1216 *lvalp = jiffies_to_msecs(lval); 1217 } 1218 return 0; 1219 } 1220 1221 static int do_proc_dointvec_ms_jiffies_minmax_conv(bool *negp, unsigned long *lvalp, 1222 int *valp, int write, void *data) 1223 { 1224 int tmp, ret; 1225 struct do_proc_dointvec_minmax_conv_param *param = data; 1226 /* 1227 * If writing, first do so via a temporary local int so we can 1228 * bounds-check it before touching *valp. 1229 */ 1230 int *ip = write ? &tmp : valp; 1231 1232 ret = do_proc_dointvec_ms_jiffies_conv(negp, lvalp, ip, write, data); 1233 if (ret) 1234 return ret; 1235 1236 if (write) { 1237 if ((param->min && *param->min > tmp) || 1238 (param->max && *param->max < tmp)) 1239 return -EINVAL; 1240 *valp = tmp; 1241 } 1242 return 0; 1243 } 1244 1245 /** 1246 * proc_dointvec_jiffies - read a vector of integers as seconds 1247 * @table: the sysctl table 1248 * @write: %TRUE if this is a write to the sysctl file 1249 * @buffer: the user buffer 1250 * @lenp: the size of the user buffer 1251 * @ppos: file position 1252 * 1253 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1254 * values from/to the user buffer, treated as an ASCII string. 1255 * The values read are assumed to be in seconds, and are converted into 1256 * jiffies. 1257 * 1258 * Returns 0 on success. 1259 */ 1260 int proc_dointvec_jiffies(const struct ctl_table *table, int write, 1261 void *buffer, size_t *lenp, loff_t *ppos) 1262 { 1263 return do_proc_dointvec(table,write,buffer,lenp,ppos, 1264 do_proc_dointvec_jiffies_conv,NULL); 1265 } 1266 1267 int proc_dointvec_ms_jiffies_minmax(const struct ctl_table *table, int write, 1268 void *buffer, size_t *lenp, loff_t *ppos) 1269 { 1270 struct do_proc_dointvec_minmax_conv_param param = { 1271 .min = (int *) table->extra1, 1272 .max = (int *) table->extra2, 1273 }; 1274 return do_proc_dointvec(table, write, buffer, lenp, ppos, 1275 do_proc_dointvec_ms_jiffies_minmax_conv, ¶m); 1276 } 1277 1278 /** 1279 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 1280 * @table: the sysctl table 1281 * @write: %TRUE if this is a write to the sysctl file 1282 * @buffer: the user buffer 1283 * @lenp: the size of the user buffer 1284 * @ppos: pointer to the file position 1285 * 1286 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1287 * values from/to the user buffer, treated as an ASCII string. 1288 * The values read are assumed to be in 1/USER_HZ seconds, and 1289 * are converted into jiffies. 1290 * 1291 * Returns 0 on success. 1292 */ 1293 int proc_dointvec_userhz_jiffies(const struct ctl_table *table, int write, 1294 void *buffer, size_t *lenp, loff_t *ppos) 1295 { 1296 return do_proc_dointvec(table, write, buffer, lenp, ppos, 1297 do_proc_dointvec_userhz_jiffies_conv, NULL); 1298 } 1299 1300 /** 1301 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 1302 * @table: the sysctl table 1303 * @write: %TRUE if this is a write to the sysctl file 1304 * @buffer: the user buffer 1305 * @lenp: the size of the user buffer 1306 * @ppos: the current position in the file 1307 * 1308 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1309 * values from/to the user buffer, treated as an ASCII string. 1310 * The values read are assumed to be in 1/1000 seconds, and 1311 * are converted into jiffies. 1312 * 1313 * Returns 0 on success. 1314 */ 1315 int proc_dointvec_ms_jiffies(const struct ctl_table *table, int write, void *buffer, 1316 size_t *lenp, loff_t *ppos) 1317 { 1318 return do_proc_dointvec(table, write, buffer, lenp, ppos, 1319 do_proc_dointvec_ms_jiffies_conv, NULL); 1320 } 1321 1322 static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer, 1323 size_t *lenp, loff_t *ppos) 1324 { 1325 struct pid *new_pid; 1326 pid_t tmp; 1327 int r; 1328 1329 tmp = pid_vnr(cad_pid); 1330 1331 r = __do_proc_dointvec(&tmp, table, write, buffer, 1332 lenp, ppos, NULL, NULL); 1333 if (r || !write) 1334 return r; 1335 1336 new_pid = find_get_pid(tmp); 1337 if (!new_pid) 1338 return -ESRCH; 1339 1340 put_pid(xchg(&cad_pid, new_pid)); 1341 return 0; 1342 } 1343 1344 /** 1345 * proc_do_large_bitmap - read/write from/to a large bitmap 1346 * @table: the sysctl table 1347 * @write: %TRUE if this is a write to the sysctl file 1348 * @buffer: the user buffer 1349 * @lenp: the size of the user buffer 1350 * @ppos: file position 1351 * 1352 * The bitmap is stored at table->data and the bitmap length (in bits) 1353 * in table->maxlen. 1354 * 1355 * We use a range comma separated format (e.g. 1,3-4,10-10) so that 1356 * large bitmaps may be represented in a compact manner. Writing into 1357 * the file will clear the bitmap then update it with the given input. 1358 * 1359 * Returns 0 on success. 1360 */ 1361 int proc_do_large_bitmap(const struct ctl_table *table, int write, 1362 void *buffer, size_t *lenp, loff_t *ppos) 1363 { 1364 int err = 0; 1365 size_t left = *lenp; 1366 unsigned long bitmap_len = table->maxlen; 1367 unsigned long *bitmap = *(unsigned long **) table->data; 1368 unsigned long *tmp_bitmap = NULL; 1369 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1370 1371 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { 1372 *lenp = 0; 1373 return 0; 1374 } 1375 1376 if (write) { 1377 char *p = buffer; 1378 size_t skipped = 0; 1379 1380 if (left > PAGE_SIZE - 1) { 1381 left = PAGE_SIZE - 1; 1382 /* How much of the buffer we'll skip this pass */ 1383 skipped = *lenp - left; 1384 } 1385 1386 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); 1387 if (!tmp_bitmap) 1388 return -ENOMEM; 1389 proc_skip_char(&p, &left, '\n'); 1390 while (!err && left) { 1391 unsigned long val_a, val_b; 1392 bool neg; 1393 size_t saved_left; 1394 1395 /* In case we stop parsing mid-number, we can reset */ 1396 saved_left = left; 1397 err = proc_get_long(&p, &left, &val_a, &neg, tr_a, 1398 sizeof(tr_a), &c); 1399 /* 1400 * If we consumed the entirety of a truncated buffer or 1401 * only one char is left (may be a "-"), then stop here, 1402 * reset, & come back for more. 1403 */ 1404 if ((left <= 1) && skipped) { 1405 left = saved_left; 1406 break; 1407 } 1408 1409 if (err) 1410 break; 1411 if (val_a >= bitmap_len || neg) { 1412 err = -EINVAL; 1413 break; 1414 } 1415 1416 val_b = val_a; 1417 if (left) { 1418 p++; 1419 left--; 1420 } 1421 1422 if (c == '-') { 1423 err = proc_get_long(&p, &left, &val_b, 1424 &neg, tr_b, sizeof(tr_b), 1425 &c); 1426 /* 1427 * If we consumed all of a truncated buffer or 1428 * then stop here, reset, & come back for more. 1429 */ 1430 if (!left && skipped) { 1431 left = saved_left; 1432 break; 1433 } 1434 1435 if (err) 1436 break; 1437 if (val_b >= bitmap_len || neg || 1438 val_a > val_b) { 1439 err = -EINVAL; 1440 break; 1441 } 1442 if (left) { 1443 p++; 1444 left--; 1445 } 1446 } 1447 1448 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 1449 proc_skip_char(&p, &left, '\n'); 1450 } 1451 left += skipped; 1452 } else { 1453 unsigned long bit_a, bit_b = 0; 1454 bool first = 1; 1455 1456 while (left) { 1457 bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 1458 if (bit_a >= bitmap_len) 1459 break; 1460 bit_b = find_next_zero_bit(bitmap, bitmap_len, 1461 bit_a + 1) - 1; 1462 1463 if (!first) 1464 proc_put_char(&buffer, &left, ','); 1465 proc_put_long(&buffer, &left, bit_a, false); 1466 if (bit_a != bit_b) { 1467 proc_put_char(&buffer, &left, '-'); 1468 proc_put_long(&buffer, &left, bit_b, false); 1469 } 1470 1471 first = 0; bit_b++; 1472 } 1473 proc_put_char(&buffer, &left, '\n'); 1474 } 1475 1476 if (!err) { 1477 if (write) { 1478 if (*ppos) 1479 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 1480 else 1481 bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 1482 } 1483 *lenp -= left; 1484 *ppos += *lenp; 1485 } 1486 1487 bitmap_free(tmp_bitmap); 1488 return err; 1489 } 1490 1491 #else /* CONFIG_PROC_SYSCTL */ 1492 1493 int proc_dostring(const struct ctl_table *table, int write, 1494 void *buffer, size_t *lenp, loff_t *ppos) 1495 { 1496 return -ENOSYS; 1497 } 1498 1499 int proc_dobool(const struct ctl_table *table, int write, 1500 void *buffer, size_t *lenp, loff_t *ppos) 1501 { 1502 return -ENOSYS; 1503 } 1504 1505 int proc_dointvec(const struct ctl_table *table, int write, 1506 void *buffer, size_t *lenp, loff_t *ppos) 1507 { 1508 return -ENOSYS; 1509 } 1510 1511 int proc_douintvec(const struct ctl_table *table, int write, 1512 void *buffer, size_t *lenp, loff_t *ppos) 1513 { 1514 return -ENOSYS; 1515 } 1516 1517 int proc_dointvec_minmax(const struct ctl_table *table, int write, 1518 void *buffer, size_t *lenp, loff_t *ppos) 1519 { 1520 return -ENOSYS; 1521 } 1522 1523 int proc_douintvec_minmax(const struct ctl_table *table, int write, 1524 void *buffer, size_t *lenp, loff_t *ppos) 1525 { 1526 return -ENOSYS; 1527 } 1528 1529 int proc_dou8vec_minmax(const struct ctl_table *table, int write, 1530 void *buffer, size_t *lenp, loff_t *ppos) 1531 { 1532 return -ENOSYS; 1533 } 1534 1535 int proc_dointvec_jiffies(const struct ctl_table *table, int write, 1536 void *buffer, size_t *lenp, loff_t *ppos) 1537 { 1538 return -ENOSYS; 1539 } 1540 1541 int proc_dointvec_ms_jiffies_minmax(const struct ctl_table *table, int write, 1542 void *buffer, size_t *lenp, loff_t *ppos) 1543 { 1544 return -ENOSYS; 1545 } 1546 1547 int proc_dointvec_userhz_jiffies(const struct ctl_table *table, int write, 1548 void *buffer, size_t *lenp, loff_t *ppos) 1549 { 1550 return -ENOSYS; 1551 } 1552 1553 int proc_dointvec_ms_jiffies(const struct ctl_table *table, int write, 1554 void *buffer, size_t *lenp, loff_t *ppos) 1555 { 1556 return -ENOSYS; 1557 } 1558 1559 int proc_doulongvec_minmax(const struct ctl_table *table, int write, 1560 void *buffer, size_t *lenp, loff_t *ppos) 1561 { 1562 return -ENOSYS; 1563 } 1564 1565 int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int write, 1566 void *buffer, size_t *lenp, loff_t *ppos) 1567 { 1568 return -ENOSYS; 1569 } 1570 1571 int proc_do_large_bitmap(const struct ctl_table *table, int write, 1572 void *buffer, size_t *lenp, loff_t *ppos) 1573 { 1574 return -ENOSYS; 1575 } 1576 1577 #endif /* CONFIG_PROC_SYSCTL */ 1578 1579 #if defined(CONFIG_SYSCTL) 1580 int proc_do_static_key(const struct ctl_table *table, int write, 1581 void *buffer, size_t *lenp, loff_t *ppos) 1582 { 1583 struct static_key *key = (struct static_key *)table->data; 1584 static DEFINE_MUTEX(static_key_mutex); 1585 int val, ret; 1586 struct ctl_table tmp = { 1587 .data = &val, 1588 .maxlen = sizeof(val), 1589 .mode = table->mode, 1590 .extra1 = SYSCTL_ZERO, 1591 .extra2 = SYSCTL_ONE, 1592 }; 1593 1594 if (write && !capable(CAP_SYS_ADMIN)) 1595 return -EPERM; 1596 1597 mutex_lock(&static_key_mutex); 1598 val = static_key_enabled(key); 1599 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 1600 if (write && !ret) { 1601 if (val) 1602 static_key_enable(key); 1603 else 1604 static_key_disable(key); 1605 } 1606 mutex_unlock(&static_key_mutex); 1607 return ret; 1608 } 1609 1610 static const struct ctl_table kern_table[] = { 1611 { 1612 .procname = "panic", 1613 .data = &panic_timeout, 1614 .maxlen = sizeof(int), 1615 .mode = 0644, 1616 .proc_handler = proc_dointvec, 1617 }, 1618 #ifdef CONFIG_PROC_SYSCTL 1619 { 1620 .procname = "tainted", 1621 .maxlen = sizeof(long), 1622 .mode = 0644, 1623 .proc_handler = proc_taint, 1624 }, 1625 { 1626 .procname = "sysctl_writes_strict", 1627 .data = &sysctl_writes_strict, 1628 .maxlen = sizeof(int), 1629 .mode = 0644, 1630 .proc_handler = proc_dointvec_minmax, 1631 .extra1 = SYSCTL_NEG_ONE, 1632 .extra2 = SYSCTL_ONE, 1633 }, 1634 #endif 1635 { 1636 .procname = "print-fatal-signals", 1637 .data = &print_fatal_signals, 1638 .maxlen = sizeof(int), 1639 .mode = 0644, 1640 .proc_handler = proc_dointvec, 1641 }, 1642 #ifdef CONFIG_SPARC 1643 { 1644 .procname = "reboot-cmd", 1645 .data = reboot_command, 1646 .maxlen = 256, 1647 .mode = 0644, 1648 .proc_handler = proc_dostring, 1649 }, 1650 { 1651 .procname = "stop-a", 1652 .data = &stop_a_enabled, 1653 .maxlen = sizeof (int), 1654 .mode = 0644, 1655 .proc_handler = proc_dointvec, 1656 }, 1657 { 1658 .procname = "scons-poweroff", 1659 .data = &scons_pwroff, 1660 .maxlen = sizeof (int), 1661 .mode = 0644, 1662 .proc_handler = proc_dointvec, 1663 }, 1664 #endif 1665 #ifdef CONFIG_SPARC64 1666 { 1667 .procname = "tsb-ratio", 1668 .data = &sysctl_tsb_ratio, 1669 .maxlen = sizeof (int), 1670 .mode = 0644, 1671 .proc_handler = proc_dointvec, 1672 }, 1673 #endif 1674 #ifdef CONFIG_PARISC 1675 { 1676 .procname = "soft-power", 1677 .data = &pwrsw_enabled, 1678 .maxlen = sizeof (int), 1679 .mode = 0644, 1680 .proc_handler = proc_dointvec, 1681 }, 1682 #endif 1683 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW 1684 { 1685 .procname = "unaligned-trap", 1686 .data = &unaligned_enabled, 1687 .maxlen = sizeof (int), 1688 .mode = 0644, 1689 .proc_handler = proc_dointvec, 1690 }, 1691 #endif 1692 #ifdef CONFIG_STACK_TRACER 1693 { 1694 .procname = "stack_tracer_enabled", 1695 .data = &stack_tracer_enabled, 1696 .maxlen = sizeof(int), 1697 .mode = 0644, 1698 .proc_handler = stack_trace_sysctl, 1699 }, 1700 #endif 1701 #ifdef CONFIG_TRACING 1702 { 1703 .procname = "ftrace_dump_on_oops", 1704 .data = &ftrace_dump_on_oops, 1705 .maxlen = MAX_TRACER_SIZE, 1706 .mode = 0644, 1707 .proc_handler = proc_dostring, 1708 }, 1709 { 1710 .procname = "traceoff_on_warning", 1711 .data = &__disable_trace_on_warning, 1712 .maxlen = sizeof(__disable_trace_on_warning), 1713 .mode = 0644, 1714 .proc_handler = proc_dointvec, 1715 }, 1716 { 1717 .procname = "tracepoint_printk", 1718 .data = &tracepoint_printk, 1719 .maxlen = sizeof(tracepoint_printk), 1720 .mode = 0644, 1721 .proc_handler = tracepoint_printk_sysctl, 1722 }, 1723 #endif 1724 #ifdef CONFIG_MODULES 1725 { 1726 .procname = "modprobe", 1727 .data = &modprobe_path, 1728 .maxlen = KMOD_PATH_LEN, 1729 .mode = 0644, 1730 .proc_handler = proc_dostring, 1731 }, 1732 { 1733 .procname = "modules_disabled", 1734 .data = &modules_disabled, 1735 .maxlen = sizeof(int), 1736 .mode = 0644, 1737 /* only handle a transition from default "0" to "1" */ 1738 .proc_handler = proc_dointvec_minmax, 1739 .extra1 = SYSCTL_ONE, 1740 .extra2 = SYSCTL_ONE, 1741 }, 1742 #endif 1743 #ifdef CONFIG_UEVENT_HELPER 1744 { 1745 .procname = "hotplug", 1746 .data = &uevent_helper, 1747 .maxlen = UEVENT_HELPER_PATH_LEN, 1748 .mode = 0644, 1749 .proc_handler = proc_dostring, 1750 }, 1751 #endif 1752 #ifdef CONFIG_MAGIC_SYSRQ 1753 { 1754 .procname = "sysrq", 1755 .data = NULL, 1756 .maxlen = sizeof (int), 1757 .mode = 0644, 1758 .proc_handler = sysrq_sysctl_handler, 1759 }, 1760 #endif 1761 #ifdef CONFIG_PROC_SYSCTL 1762 { 1763 .procname = "cad_pid", 1764 .data = NULL, 1765 .maxlen = sizeof (int), 1766 .mode = 0600, 1767 .proc_handler = proc_do_cad_pid, 1768 }, 1769 #endif 1770 { 1771 .procname = "threads-max", 1772 .data = NULL, 1773 .maxlen = sizeof(int), 1774 .mode = 0644, 1775 .proc_handler = sysctl_max_threads, 1776 }, 1777 { 1778 .procname = "overflowuid", 1779 .data = &overflowuid, 1780 .maxlen = sizeof(int), 1781 .mode = 0644, 1782 .proc_handler = proc_dointvec_minmax, 1783 .extra1 = SYSCTL_ZERO, 1784 .extra2 = SYSCTL_MAXOLDUID, 1785 }, 1786 { 1787 .procname = "overflowgid", 1788 .data = &overflowgid, 1789 .maxlen = sizeof(int), 1790 .mode = 0644, 1791 .proc_handler = proc_dointvec_minmax, 1792 .extra1 = SYSCTL_ZERO, 1793 .extra2 = SYSCTL_MAXOLDUID, 1794 }, 1795 #ifdef CONFIG_S390 1796 { 1797 .procname = "userprocess_debug", 1798 .data = &show_unhandled_signals, 1799 .maxlen = sizeof(int), 1800 .mode = 0644, 1801 .proc_handler = proc_dointvec, 1802 }, 1803 #endif 1804 { 1805 .procname = "panic_on_oops", 1806 .data = &panic_on_oops, 1807 .maxlen = sizeof(int), 1808 .mode = 0644, 1809 .proc_handler = proc_dointvec, 1810 }, 1811 { 1812 .procname = "panic_print", 1813 .data = &panic_print, 1814 .maxlen = sizeof(unsigned long), 1815 .mode = 0644, 1816 .proc_handler = proc_doulongvec_minmax, 1817 }, 1818 { 1819 .procname = "ngroups_max", 1820 .data = (void *)&ngroups_max, 1821 .maxlen = sizeof (int), 1822 .mode = 0444, 1823 .proc_handler = proc_dointvec, 1824 }, 1825 { 1826 .procname = "cap_last_cap", 1827 .data = (void *)&cap_last_cap, 1828 .maxlen = sizeof(int), 1829 .mode = 0444, 1830 .proc_handler = proc_dointvec, 1831 }, 1832 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 1833 { 1834 .procname = "unknown_nmi_panic", 1835 .data = &unknown_nmi_panic, 1836 .maxlen = sizeof (int), 1837 .mode = 0644, 1838 .proc_handler = proc_dointvec, 1839 }, 1840 #endif 1841 1842 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \ 1843 defined(CONFIG_DEBUG_STACKOVERFLOW) 1844 { 1845 .procname = "panic_on_stackoverflow", 1846 .data = &sysctl_panic_on_stackoverflow, 1847 .maxlen = sizeof(int), 1848 .mode = 0644, 1849 .proc_handler = proc_dointvec, 1850 }, 1851 #endif 1852 #if defined(CONFIG_X86) 1853 { 1854 .procname = "panic_on_unrecovered_nmi", 1855 .data = &panic_on_unrecovered_nmi, 1856 .maxlen = sizeof(int), 1857 .mode = 0644, 1858 .proc_handler = proc_dointvec, 1859 }, 1860 { 1861 .procname = "panic_on_io_nmi", 1862 .data = &panic_on_io_nmi, 1863 .maxlen = sizeof(int), 1864 .mode = 0644, 1865 .proc_handler = proc_dointvec, 1866 }, 1867 { 1868 .procname = "bootloader_type", 1869 .data = &bootloader_type, 1870 .maxlen = sizeof (int), 1871 .mode = 0444, 1872 .proc_handler = proc_dointvec, 1873 }, 1874 { 1875 .procname = "bootloader_version", 1876 .data = &bootloader_version, 1877 .maxlen = sizeof (int), 1878 .mode = 0444, 1879 .proc_handler = proc_dointvec, 1880 }, 1881 { 1882 .procname = "io_delay_type", 1883 .data = &io_delay_type, 1884 .maxlen = sizeof(int), 1885 .mode = 0644, 1886 .proc_handler = proc_dointvec, 1887 }, 1888 #endif 1889 #if defined(CONFIG_MMU) 1890 { 1891 .procname = "randomize_va_space", 1892 .data = &randomize_va_space, 1893 .maxlen = sizeof(int), 1894 .mode = 0644, 1895 .proc_handler = proc_dointvec, 1896 }, 1897 #endif 1898 #if defined(CONFIG_S390) && defined(CONFIG_SMP) 1899 { 1900 .procname = "spin_retry", 1901 .data = &spin_retry, 1902 .maxlen = sizeof (int), 1903 .mode = 0644, 1904 .proc_handler = proc_dointvec, 1905 }, 1906 #endif 1907 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 1908 { 1909 .procname = "acpi_video_flags", 1910 .data = &acpi_realmode_flags, 1911 .maxlen = sizeof (unsigned long), 1912 .mode = 0644, 1913 .proc_handler = proc_doulongvec_minmax, 1914 }, 1915 #endif 1916 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN 1917 { 1918 .procname = "ignore-unaligned-usertrap", 1919 .data = &no_unaligned_warning, 1920 .maxlen = sizeof (int), 1921 .mode = 0644, 1922 .proc_handler = proc_dointvec, 1923 }, 1924 #endif 1925 #ifdef CONFIG_RT_MUTEXES 1926 { 1927 .procname = "max_lock_depth", 1928 .data = &max_lock_depth, 1929 .maxlen = sizeof(int), 1930 .mode = 0644, 1931 .proc_handler = proc_dointvec, 1932 }, 1933 #endif 1934 #ifdef CONFIG_PERF_EVENTS 1935 /* 1936 * User-space scripts rely on the existence of this file 1937 * as a feature check for perf_events being enabled. 1938 * 1939 * So it's an ABI, do not remove! 1940 */ 1941 { 1942 .procname = "perf_event_paranoid", 1943 .data = &sysctl_perf_event_paranoid, 1944 .maxlen = sizeof(sysctl_perf_event_paranoid), 1945 .mode = 0644, 1946 .proc_handler = proc_dointvec, 1947 }, 1948 { 1949 .procname = "perf_event_mlock_kb", 1950 .data = &sysctl_perf_event_mlock, 1951 .maxlen = sizeof(sysctl_perf_event_mlock), 1952 .mode = 0644, 1953 .proc_handler = proc_dointvec, 1954 }, 1955 { 1956 .procname = "perf_event_max_sample_rate", 1957 .data = &sysctl_perf_event_sample_rate, 1958 .maxlen = sizeof(sysctl_perf_event_sample_rate), 1959 .mode = 0644, 1960 .proc_handler = perf_event_max_sample_rate_handler, 1961 .extra1 = SYSCTL_ONE, 1962 }, 1963 { 1964 .procname = "perf_cpu_time_max_percent", 1965 .data = &sysctl_perf_cpu_time_max_percent, 1966 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), 1967 .mode = 0644, 1968 .proc_handler = perf_cpu_time_max_percent_handler, 1969 .extra1 = SYSCTL_ZERO, 1970 .extra2 = SYSCTL_ONE_HUNDRED, 1971 }, 1972 { 1973 .procname = "perf_event_max_stack", 1974 .data = &sysctl_perf_event_max_stack, 1975 .maxlen = sizeof(sysctl_perf_event_max_stack), 1976 .mode = 0644, 1977 .proc_handler = perf_event_max_stack_handler, 1978 .extra1 = SYSCTL_ZERO, 1979 .extra2 = (void *)&six_hundred_forty_kb, 1980 }, 1981 { 1982 .procname = "perf_event_max_contexts_per_stack", 1983 .data = &sysctl_perf_event_max_contexts_per_stack, 1984 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), 1985 .mode = 0644, 1986 .proc_handler = perf_event_max_stack_handler, 1987 .extra1 = SYSCTL_ZERO, 1988 .extra2 = SYSCTL_ONE_THOUSAND, 1989 }, 1990 #endif 1991 { 1992 .procname = "panic_on_warn", 1993 .data = &panic_on_warn, 1994 .maxlen = sizeof(int), 1995 .mode = 0644, 1996 .proc_handler = proc_dointvec_minmax, 1997 .extra1 = SYSCTL_ZERO, 1998 .extra2 = SYSCTL_ONE, 1999 }, 2000 #ifdef CONFIG_TREE_RCU 2001 { 2002 .procname = "panic_on_rcu_stall", 2003 .data = &sysctl_panic_on_rcu_stall, 2004 .maxlen = sizeof(sysctl_panic_on_rcu_stall), 2005 .mode = 0644, 2006 .proc_handler = proc_dointvec_minmax, 2007 .extra1 = SYSCTL_ZERO, 2008 .extra2 = SYSCTL_ONE, 2009 }, 2010 { 2011 .procname = "max_rcu_stall_to_panic", 2012 .data = &sysctl_max_rcu_stall_to_panic, 2013 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic), 2014 .mode = 0644, 2015 .proc_handler = proc_dointvec_minmax, 2016 .extra1 = SYSCTL_ONE, 2017 .extra2 = SYSCTL_INT_MAX, 2018 }, 2019 #endif 2020 }; 2021 2022 static const struct ctl_table vm_table[] = { 2023 { 2024 .procname = "overcommit_memory", 2025 .data = &sysctl_overcommit_memory, 2026 .maxlen = sizeof(sysctl_overcommit_memory), 2027 .mode = 0644, 2028 .proc_handler = overcommit_policy_handler, 2029 .extra1 = SYSCTL_ZERO, 2030 .extra2 = SYSCTL_TWO, 2031 }, 2032 { 2033 .procname = "overcommit_ratio", 2034 .data = &sysctl_overcommit_ratio, 2035 .maxlen = sizeof(sysctl_overcommit_ratio), 2036 .mode = 0644, 2037 .proc_handler = overcommit_ratio_handler, 2038 }, 2039 { 2040 .procname = "overcommit_kbytes", 2041 .data = &sysctl_overcommit_kbytes, 2042 .maxlen = sizeof(sysctl_overcommit_kbytes), 2043 .mode = 0644, 2044 .proc_handler = overcommit_kbytes_handler, 2045 }, 2046 { 2047 .procname = "dirtytime_expire_seconds", 2048 .data = &dirtytime_expire_interval, 2049 .maxlen = sizeof(dirtytime_expire_interval), 2050 .mode = 0644, 2051 .proc_handler = dirtytime_interval_handler, 2052 .extra1 = SYSCTL_ZERO, 2053 }, 2054 { 2055 .procname = "drop_caches", 2056 .data = &sysctl_drop_caches, 2057 .maxlen = sizeof(int), 2058 .mode = 0200, 2059 .proc_handler = drop_caches_sysctl_handler, 2060 .extra1 = SYSCTL_ONE, 2061 .extra2 = SYSCTL_FOUR, 2062 }, 2063 #ifdef CONFIG_MMU 2064 { 2065 .procname = "max_map_count", 2066 .data = &sysctl_max_map_count, 2067 .maxlen = sizeof(sysctl_max_map_count), 2068 .mode = 0644, 2069 .proc_handler = proc_dointvec_minmax, 2070 .extra1 = SYSCTL_ZERO, 2071 }, 2072 #else 2073 { 2074 .procname = "nr_trim_pages", 2075 .data = &sysctl_nr_trim_pages, 2076 .maxlen = sizeof(sysctl_nr_trim_pages), 2077 .mode = 0644, 2078 .proc_handler = proc_dointvec_minmax, 2079 .extra1 = SYSCTL_ZERO, 2080 }, 2081 #endif 2082 { 2083 .procname = "vfs_cache_pressure", 2084 .data = &sysctl_vfs_cache_pressure, 2085 .maxlen = sizeof(sysctl_vfs_cache_pressure), 2086 .mode = 0644, 2087 .proc_handler = proc_dointvec_minmax, 2088 .extra1 = SYSCTL_ZERO, 2089 }, 2090 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 2091 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 2092 { 2093 .procname = "legacy_va_layout", 2094 .data = &sysctl_legacy_va_layout, 2095 .maxlen = sizeof(sysctl_legacy_va_layout), 2096 .mode = 0644, 2097 .proc_handler = proc_dointvec_minmax, 2098 .extra1 = SYSCTL_ZERO, 2099 }, 2100 #endif 2101 #ifdef CONFIG_MMU 2102 { 2103 .procname = "mmap_min_addr", 2104 .data = &dac_mmap_min_addr, 2105 .maxlen = sizeof(unsigned long), 2106 .mode = 0644, 2107 .proc_handler = mmap_min_addr_handler, 2108 }, 2109 #endif 2110 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 2111 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 2112 { 2113 .procname = "vdso_enabled", 2114 #ifdef CONFIG_X86_32 2115 .data = &vdso32_enabled, 2116 .maxlen = sizeof(vdso32_enabled), 2117 #else 2118 .data = &vdso_enabled, 2119 .maxlen = sizeof(vdso_enabled), 2120 #endif 2121 .mode = 0644, 2122 .proc_handler = proc_dointvec, 2123 .extra1 = SYSCTL_ZERO, 2124 }, 2125 #endif 2126 { 2127 .procname = "user_reserve_kbytes", 2128 .data = &sysctl_user_reserve_kbytes, 2129 .maxlen = sizeof(sysctl_user_reserve_kbytes), 2130 .mode = 0644, 2131 .proc_handler = proc_doulongvec_minmax, 2132 }, 2133 { 2134 .procname = "admin_reserve_kbytes", 2135 .data = &sysctl_admin_reserve_kbytes, 2136 .maxlen = sizeof(sysctl_admin_reserve_kbytes), 2137 .mode = 0644, 2138 .proc_handler = proc_doulongvec_minmax, 2139 }, 2140 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS 2141 { 2142 .procname = "mmap_rnd_bits", 2143 .data = &mmap_rnd_bits, 2144 .maxlen = sizeof(mmap_rnd_bits), 2145 .mode = 0600, 2146 .proc_handler = proc_dointvec_minmax, 2147 .extra1 = (void *)&mmap_rnd_bits_min, 2148 .extra2 = (void *)&mmap_rnd_bits_max, 2149 }, 2150 #endif 2151 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS 2152 { 2153 .procname = "mmap_rnd_compat_bits", 2154 .data = &mmap_rnd_compat_bits, 2155 .maxlen = sizeof(mmap_rnd_compat_bits), 2156 .mode = 0600, 2157 .proc_handler = proc_dointvec_minmax, 2158 .extra1 = (void *)&mmap_rnd_compat_bits_min, 2159 .extra2 = (void *)&mmap_rnd_compat_bits_max, 2160 }, 2161 #endif 2162 }; 2163 2164 int __init sysctl_init_bases(void) 2165 { 2166 register_sysctl_init("kernel", kern_table); 2167 register_sysctl_init("vm", vm_table); 2168 2169 return 0; 2170 } 2171 #endif /* CONFIG_SYSCTL */ 2172 /* 2173 * No sense putting this after each symbol definition, twice, 2174 * exception granted :-) 2175 */ 2176 EXPORT_SYMBOL(proc_dobool); 2177 EXPORT_SYMBOL(proc_dointvec); 2178 EXPORT_SYMBOL(proc_douintvec); 2179 EXPORT_SYMBOL(proc_dointvec_jiffies); 2180 EXPORT_SYMBOL(proc_dointvec_minmax); 2181 EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 2182 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 2183 EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 2184 EXPORT_SYMBOL(proc_dostring); 2185 EXPORT_SYMBOL(proc_doulongvec_minmax); 2186 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 2187 EXPORT_SYMBOL(proc_do_large_bitmap); 2188