Date: Tue, 20 Sep 2022 08:16:41 -0400 From: Rich Felker <dalias@...c.org> To: baiyang <baiyang@...il.com> Cc: musl <musl@...ts.openwall.com> Subject: Re: Re: The heap memory performance (malloc/free/realloc) is significantly degraded in musl 1.2 (compared to 1.1) On Tue, Sep 20, 2022 at 01:56:12PM +0800, baiyang wrote: > > // This multi-threaded access to the pagemap is safe for fairly > > // subtle reasons. We basically assume that when an object X is > > // allocated by thread A and deallocated by thread B, there must > > // have been appropriate synchronization in the handoff of object > > // X from thread A to thread B. > > Thanks for your information. > I feel this assumption is very reasonable: you can't have one thread > doing "free(p)" while another thread is accessing the block pointed > to by p without any synchronization mechanism at the same time. That's a correct assumption given that the program's behavior is defined. The problem is that once you assume that, you've completely lost control over what happens when the program's behavior is undefined due to memory lifetime bugs in the application (UAF/DF/etc) and an allocator that does this will necessarily allow bugs in the lifetimes of objects that aren't inherently exploitable on the application level (don't contain pointers that will be written through that might clobber other application state, etc.) to be used to gain control over the allocator state and eventually gain control over the flow of execution through manipulating other allocated objects that are attack vectors. A hardened allocator like mallocng or hardened_malloc does not make assumptions about the validity of data reachable for clobbering through application bugs that haven't already yielded a high level of control to the attacker. Instead, the metadata assumed to be valid is at "secret locations" outside the area where application data is stored that are intended not to be determinable without already having some strong level of control over execution flow. And on top of that, it's cross-validated as much as possible. We also do validation where we can of the "in-band" data that is easily reachable by overflows in application buffers, etc. This both blocks a lot of potential exploits, and catches application bugs that could be exploitable before they turn into exploits, by having them crash on developers'/packagers' systems before they're deployed and getting the root cause investigated and fixed. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.