diff options
author | schwarze <> | 2014-12-06 18:54:55 +0000 |
---|---|---|
committer | schwarze <> | 2014-12-06 18:54:55 +0000 |
commit | 6023656d8c45eb723b7d115cebbb798c866abf5f (patch) | |
tree | 3aee91df6b5a17ef10fb591347976ad5ba0195b4 /src | |
parent | 46001da00a8d87e0879c23fd670ef1ad33a614e3 (diff) | |
download | openbsd-6023656d8c45eb723b7d115cebbb798c866abf5f.tar.gz openbsd-6023656d8c45eb723b7d115cebbb798c866abf5f.tar.bz2 openbsd-6023656d8c45eb723b7d115cebbb798c866abf5f.zip |
malloc(3) is in the "comp" install set, malloc.conf(5) in "man",
breaking the hardlink between file system entries, confusing apropos(1).
Split malloc.conf(5) out of malloc(3) as suggested by deraadt@.
Feedback and OK jmc@, OK deraadt@ tedu@ jasper@.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/stdlib/Makefile.inc | 4 | ||||
-rw-r--r-- | src/lib/libc/stdlib/malloc.3 | 134 |
2 files changed, 10 insertions, 128 deletions
diff --git a/src/lib/libc/stdlib/Makefile.inc b/src/lib/libc/stdlib/Makefile.inc index 0c0b1499f8..e95ff11ed6 100644 --- a/src/lib/libc/stdlib/Makefile.inc +++ b/src/lib/libc/stdlib/Makefile.inc | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile.inc,v 1.54 2014/08/15 04:14:36 guenther Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.55 2014/12/06 18:54:55 schwarze Exp $ |
2 | 2 | ||
3 | # stdlib sources | 3 | # stdlib sources |
4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/stdlib ${LIBCSRCDIR}/stdlib | 4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/stdlib ${LIBCSRCDIR}/stdlib |
@@ -40,7 +40,7 @@ MLINKS+=insque.3 remque.3 | |||
40 | MLINKS+=labs.3 llabs.3 | 40 | MLINKS+=labs.3 llabs.3 |
41 | MLINKS+=lsearch.3 lfind.3 | 41 | MLINKS+=lsearch.3 lfind.3 |
42 | MLINKS+=malloc.3 free.3 malloc.3 realloc.3 malloc.3 calloc.3 | 42 | MLINKS+=malloc.3 free.3 malloc.3 realloc.3 malloc.3 calloc.3 |
43 | MLINKS+=malloc.3 reallocarray.3 malloc.3 cfree.3 malloc.3 malloc.conf.5 | 43 | MLINKS+=malloc.3 reallocarray.3 malloc.3 cfree.3 |
44 | MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 | 44 | MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 |
45 | MLINKS+=radixsort.3 sradixsort.3 | 45 | MLINKS+=radixsort.3 sradixsort.3 |
46 | MLINKS+=rand.3 srand.3 rand.3 rand_r.3 | 46 | MLINKS+=rand.3 srand.3 rand.3 rand_r.3 |
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3 index 3ce9d2e28c..153fd54dbd 100644 --- a/src/lib/libc/stdlib/malloc.3 +++ b/src/lib/libc/stdlib/malloc.3 | |||
@@ -30,9 +30,9 @@ | |||
30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
31 | .\" SUCH DAMAGE. | 31 | .\" SUCH DAMAGE. |
32 | .\" | 32 | .\" |
33 | .\" $OpenBSD: malloc.3,v 1.85 2014/10/30 21:47:47 deraadt Exp $ | 33 | .\" $OpenBSD: malloc.3,v 1.86 2014/12/06 18:54:55 schwarze Exp $ |
34 | .\" | 34 | .\" |
35 | .Dd $Mdocdate: October 30 2014 $ | 35 | .Dd $Mdocdate: December 6 2014 $ |
36 | .Dt MALLOC 3 | 36 | .Dt MALLOC 3 |
37 | .Os | 37 | .Os |
38 | .Sh NAME | 38 | .Sh NAME |
@@ -285,14 +285,15 @@ Use the following: | |||
285 | newp = realloc(p, newsize); | 285 | newp = realloc(p, newsize); |
286 | .Ed | 286 | .Ed |
287 | .Sh ENVIRONMENT | 287 | .Sh ENVIRONMENT |
288 | .Bl -tag -width Ev | 288 | .Bl -tag -width "/etc/malloc.conf" |
289 | .It Ev MALLOC_OPTIONS | 289 | .It Ev MALLOC_OPTIONS |
290 | See below. | 290 | String of flags documented in |
291 | .Xr malloc.conf 5 . | ||
291 | .El | 292 | .El |
292 | .Sh FILES | 293 | .Sh FILES |
293 | .Bl -tag -width "/etc/malloc.conf" | 294 | .Bl -tag -width "/etc/malloc.conf" |
294 | .It Pa /etc/malloc.conf | 295 | .It Pa /etc/malloc.conf |
295 | symbolic link to filename containing option flags | 296 | Symbolic link to filename containing option flags. |
296 | .El | 297 | .El |
297 | .Sh EXAMPLES | 298 | .Sh EXAMPLES |
298 | If | 299 | If |
@@ -420,126 +421,6 @@ An inconsistent guard size was detected. | |||
420 | detected an internal error; | 421 | detected an internal error; |
421 | consult sources and/or wizards. | 422 | consult sources and/or wizards. |
422 | .El | 423 | .El |
423 | .Sh MALLOC_OPTIONS | ||
424 | Malloc will first look for a symbolic link called | ||
425 | .Pa /etc/malloc.conf | ||
426 | and next check the environment for a variable called | ||
427 | .Ev MALLOC_OPTIONS | ||
428 | and finally for the global variable | ||
429 | .Va malloc_options | ||
430 | and scan them for flags in that order. | ||
431 | Flags are single letters, uppercase means on, lowercase means off. | ||
432 | .Bl -tag -width indent | ||
433 | .It Cm A | ||
434 | .Dq Abort . | ||
435 | .Fn malloc | ||
436 | will coredump the process, rather than tolerate internal | ||
437 | inconsistencies or incorrect usage. | ||
438 | This is the default and a very handy debugging aid, | ||
439 | since the core file represents the time of failure, | ||
440 | rather than when the bogus pointer was used. | ||
441 | .It Cm D | ||
442 | .Dq Dump . | ||
443 | .Fn malloc | ||
444 | will dump statistics to the file | ||
445 | .Pa ./malloc.out , | ||
446 | if it already exists, | ||
447 | at exit. | ||
448 | This option requires the library to have been compiled with -DMALLOC_STATS in | ||
449 | order to have any effect. | ||
450 | .It Cm F | ||
451 | .Dq Freeguard . | ||
452 | Enable use after free detection. | ||
453 | Unused pages on the freelist are read and write protected to | ||
454 | cause a segmentation fault upon access. | ||
455 | This will also switch off the delayed freeing of chunks, | ||
456 | reducing random behaviour but detecting double | ||
457 | .Fn free | ||
458 | calls as early as possible. | ||
459 | This option is intended for debugging rather than improved security | ||
460 | (use the | ||
461 | .Cm U | ||
462 | option for security). | ||
463 | .It Cm G | ||
464 | .Dq Guard . | ||
465 | Enable guard pages. | ||
466 | Each page size or larger allocation is followed by a guard page that will | ||
467 | cause a segmentation fault upon any access. | ||
468 | .It Cm H | ||
469 | .Dq Hint . | ||
470 | Pass a hint to the kernel about pages we don't use. | ||
471 | If the machine is paging a lot this may help a bit. | ||
472 | .It Cm J | ||
473 | .Dq Junk . | ||
474 | Fill some junk into the area allocated. | ||
475 | Currently junk is bytes of 0xd0 when allocating; this is pronounced | ||
476 | .Dq Duh . | ||
477 | \&:-) | ||
478 | Freed chunks are filled with 0xdf. | ||
479 | .It Cm j | ||
480 | .Dq Don't Junk . | ||
481 | By default, small chunks are always junked, and the first part of pages | ||
482 | is junked after free. | ||
483 | This option ensures that no junking is performed. | ||
484 | .It Cm P | ||
485 | .Dq Move allocations within a page. | ||
486 | Allocations larger than half a page but smaller than a page | ||
487 | are aligned to the end of a page to catch buffer overruns in more | ||
488 | cases. | ||
489 | This is the default. | ||
490 | .It Cm R | ||
491 | .Dq realloc . | ||
492 | Always reallocate when | ||
493 | .Fn realloc | ||
494 | is called, even if the initial allocation was big enough. | ||
495 | This can substantially aid in compacting memory. | ||
496 | .\".Pp | ||
497 | .\".It Cm U | ||
498 | .\".Dq utrace . | ||
499 | .\"Generate entries for | ||
500 | .\".Xr ktrace 1 | ||
501 | .\"for all operations. | ||
502 | .\"Consult the source for this one. | ||
503 | .It Cm S | ||
504 | Enable all options suitable for security auditing. | ||
505 | .It Cm U | ||
506 | .Dq Free unmap . | ||
507 | Enable use after free protection for larger allocations. | ||
508 | Unused pages on the freelist are read and write protected to | ||
509 | cause a segmentation fault upon access. | ||
510 | .It Cm X | ||
511 | .Dq xmalloc . | ||
512 | Rather than return failure, | ||
513 | .Xr abort 3 | ||
514 | the program with a diagnostic message on stderr. | ||
515 | It is the intention that this option be set at compile time by | ||
516 | including in the source: | ||
517 | .Bd -literal -offset indent | ||
518 | extern char *malloc_options; | ||
519 | malloc_options = "X"; | ||
520 | .Ed | ||
521 | .Pp | ||
522 | Note that this will cause code that is supposed to handle | ||
523 | out-of-memory conditions gracefully to abort instead. | ||
524 | .It Cm < | ||
525 | .Dq Half the cache size . | ||
526 | Decrease the size of the free page cache by a factor of two. | ||
527 | .It Cm > | ||
528 | .Dq Double the cache size . | ||
529 | Increase the size of the free page cache by a factor of two. | ||
530 | .El | ||
531 | .Pp | ||
532 | So to set a systemwide reduction of the cache to a quarter of the | ||
533 | default size and use guard pages: | ||
534 | .Dl # ln -s 'G<<' /etc/malloc.conf | ||
535 | .Pp | ||
536 | The flags are mostly for testing and debugging. | ||
537 | If a program changes behavior if any of these options (except | ||
538 | .Cm X ) | ||
539 | are used, | ||
540 | it is buggy. | ||
541 | .Pp | ||
542 | The default number of free pages cached is 64. | ||
543 | .Sh SEE ALSO | 424 | .Sh SEE ALSO |
544 | .Xr brk 2 , | 425 | .Xr brk 2 , |
545 | .Xr mmap 2 , | 426 | .Xr mmap 2 , |
@@ -547,7 +428,8 @@ The default number of free pages cached is 64. | |||
547 | .Xr alloca 3 , | 428 | .Xr alloca 3 , |
548 | .Xr getpagesize 3 , | 429 | .Xr getpagesize 3 , |
549 | .Xr posix_memalign 3 , | 430 | .Xr posix_memalign 3 , |
550 | .Xr sysconf 3 | 431 | .Xr sysconf 3 , |
432 | .Xr malloc.conf 5 | ||
551 | .Sh STANDARDS | 433 | .Sh STANDARDS |
552 | The | 434 | The |
553 | .Fn malloc , | 435 | .Fn malloc , |