summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/malloc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Delete casts to off_t and size_t that are implied by assignmentsguenther2016-09-211-7/+7
| | | | | | | or prototypes. Ditto for some of the char* and void* casts too. verified no change to instructions on ILP32 (i386) and LP64 (amd64) ok natano@ abluhm@ deraadt@ millert@
* move page junking tp unmap(), right before we stick the region in the cache;otto2016-09-181-6/+6
| | | | ok tedu@
* Less lock contention by using more pools for mult-threaded programs.otto2016-09-011-85/+178
| | | | tested by many (thanks!) ok tedu, guenther@
* black magic for sparc page size can gotedu2016-09-011-4/+2
|
* wrterror() is fatal, delete dead code; ok tom@ natano@ tedu@otto2016-08-171-61/+22
|
* J/j is a three valued option, document and fix code to actuall support thatotto2016-07-061-3/+5
| | | | | with a little help from jmc@ for the man page bits ok jca@ and a reluctant tedu@
* adapt S option: add C, rm F (not relevant with 0 cache and disablesotto2016-06-301-3/+3
| | | | chunk rnd), rm P: is default
* Back out previous; otto saw a potential race that could lead to atb2016-06-281-32/+23
| | | | | | double unmap and I experienced a much more unstable firefox. discussed with otto on icb
* defer munmap to after unlocking malloc. this can (unfortunately) be antedu2016-06-271-23/+32
| | | | | | | expensive syscall, and we don't want to tie up other threads. there's no need to hold the lock, so defer it to afterwards. from Michael McConville ok deraadt
* two times a define to an inline function, from Michael McConville; ok djm@otto2016-04-121-10/+19
|
* tweak MALLOC_STATS printing (switched off by default), prodded byotto2016-04-091-14/+14
| | | | Michael McConville
* redundant memset(3), from Michael McConville, ok armani@otto2016-04-091-2/+1
|
* properly guard to macrosmmcc2016-03-171-5/+5
| | | | ok otto@
* small step towards multiple pools: move two globls into the struct dir_infootto2016-03-141-112/+126
| | | | ok @stefan armani@
* environ and __progname are not declared in a public header; declare themguenther2016-03-131-3/+1
| | | | | | in libc's hidden/stdlib.h instead of in each .c file that needs one ok deraadt@ gsoares@ mpi@
* refactor option letter parsing into a subfunction, to increase clarityderaadt2016-02-251-93/+102
| | | | | about which options are turned on/off by 's' and 'S' ok tedu
* Don't crash dumping malloc stats if malloc_init hasn't been called, noted byotto2016-01-261-1/+3
| | | | David CARLIER
* Long ago, malloc internally had two kinds of failures, warnings and errors.tedu2016-01-061-8/+4
| | | | | | | | The 'A' option elevated warnings to errors, and has been the default for some time. Then warnings were effectively eliminated in favor of everything being an error, but then the 'a' flag turned real errors into warnings! Remove the 'a' option entirely. You shouldn't have used it anyway. ok tb tdeval
* another case where bad things would happen after wrterrortedu2015-12-301-2/+4
|
* if somebody makes the mistake of disabling abort, don't deref null intedu2015-12-301-2/+4
| | | | validate_junk. from Michal Mazurek
* Integrate two patches originally from Daniel Micay.tedu2015-12-091-8/+76
| | | | | | | | | | | | 1. Optionally add random "canaries" to the end of an allocation. This requires increasing the internal size of the allocation slightly, which probably results in a large effective increase with current power of two sizing. Therefore, this option is only enabled via 'C'. 2. When writing junk (0xdf) to freed chunks (current default behavior), check that the junk is still intact when finally freeing the delayed chunk to catch some potential use after free. This should be pretty cheap so there's no option to control it separately. ok deraadt tb
* For now, permit overriding of the malloc family, to make emacs happyguenther2015-09-131-6/+6
|
* Wrap <stdlib.h> so that calls go direct and the symbols not in theguenther2015-09-131-1/+8
| | | | | | C standard are all weak. Apply __{BEGIN,END}_HIDDEN_DECLS to gdtoa{,imp}.h, hiding the arch-specific __strtorx, __ULtox_D2A, __strtorQ, __ULtoQ_D2A symbols.
* improve realloc. when expanding a region, actually use the free page cachetedu2015-04-061-7/+16
| | | | | instead of simply zapping it. this can save many syscalls in a program that repeatedly grows and shrinks a buffer, as observed in the wild.
* Move to the <limits.h> universe.deraadt2015-01-161-2/+2
| | | | review by millert, binary checking process with doug, concept with guenther
* rename kern enter/exit macros to malloc enter/leave to better reflecttedu2015-01-051-7/+7
| | | | what's going on.
* a small tweak to improve malloc in multithreaded programs. we don't needtedu2014-08-181-7/+21
| | | | | | | to hold the malloc lock across mmap syscalls in all cases. dropping it allows another thread to access the existing chunk cache if necessary. could be improved to be a bit more aggressive, but i've been testing this simple diff for some time now with good results.
* reduce obvious dependency on global g_pool by moving to local aliasestedu2014-07-091-42/+48
| | | | ok otto
* extra evil spaces snuck in over the last whilederaadt2014-06-271-20/+20
|
* Move to a smaller rbytes buffer and skip a random part. Not tootto2014-06-271-3/+4
| | | | | | improve the random stream itself (it doesn't), but to introduce noise in the arc4random calling pattern. Thanks to matthew@ who pointed out bias in a previous diff, ok deraadt@ matthew@
* move random bytes buffer to be part of mmaped pages; ok tedu@otto2014-06-021-21/+18
|
* move all stats collecting under MALLOC_STATS; ok krw@otto2014-05-261-28/+33
|
* fix MALLOC_STATS (not compiled in by default); ok tedu@otto2014-05-211-18/+19
|
* factor out a bit of the chunk index code and use it to make sure that atedu2014-05-181-14/+33
| | | | | freed chunk is actually freeable immediately. catch more errors. hints/ok otto
* change to having four freelists per size, to reduce another source oftedu2014-05-121-16/+20
| | | | | deterministic behavior. four selected because it's more than three, less than five. i.e., no particular reason.
* fix MALLOC_STATS code that was broken in rev 1.159, not compiled in by defaultotto2014-05-101-2/+2
|
* move reallocarray() to a seperate file so that -portable applicationsderaadt2014-05-081-12/+1
| | | | | can avoid reinventing the wheel ok guenther schwarze
* comment style fixhalex2014-05-071-2/+3
| | | | ok crickets@
* nibbles aren't enough random, use bytes. does a better job of pickingtedu2014-05-011-14/+14
| | | | | a free chunk at random and may allow to increase delayed chunk array. ok otto
* remove Z option and default to something halfway to J.tedu2014-04-231-32/+22
| | | | | | | we always junk small chunks now, and the first part of pages, but only after free. J still does the old thing. j disables everything. Consider experimental as we evaluate performance in the real world. ok otto
* explain a bit more what's going on for stupid me.espie2014-04-231-1/+4
| | | | okay otto@
* Better, cleaner hash function that computes the same on be and le archs.otto2014-04-231-10/+8
| | | | Should improve sparc64 and other be archs. ok matthew@ miod@
* change mallocarray to reallocarray. useful in a few more situations.tedu2014-04-221-3/+3
| | | | | malloc can, as always, be emulated via realloc(NULL). ok deraadt
* Introducing: void *mallocarray(size_t nmemb, size_t size);deraadt2014-04-211-1/+12
| | | | | Like calloc(), except without the cleared-memory gaurantee ok beck guenther, discussed for more than a year...
* print pid in error messages; ok reyk@otto2014-04-141-14/+18
|
* Update Copyright notice; ok otto@ beck@ deraadt@.schwarze2014-04-031-2/+4
| | | | | This is merely a by-product of figuring out the amount of phk@ code contained herein; i'm not planning to hack on this file.
* Poul-Henning Kamp informed me he is allright with this licensing change.beck2014-03-251-11/+4
|
* avoid arithetic on void *deraadt2013-11-121-4/+4
| | | | ok guenther otto
* Fix bug in random offset introduced in rev 1.143; random range wasotto2012-12-221-3/+3
| | | | expanded, but not enough due to precedence error. Spotted by Thorsten Glaser.
* Add a new malloc option 'U' => "Free unmap" that does the guarding/djm2012-11-021-15/+24
| | | | | | | | | | | | unmapping of freed allocations without disabling chunk randomisation like the "Freeguard" ('F') option does. Make security 'S' option use 'U' and not 'F'. Rationale: guarding with no chunk randomisation is great for debugging use-after-free, but chunk randomisation offers better defence against "heap feng shui" style attacks that depend on carefully constructing a particular heap layout so we should leave this enabled when requesting security options.