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