From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14163 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: How to get base address of heap arenas Date: Thu, 30 May 2019 10:01:53 -0400 Message-ID: <20190530140153.GN23599@brightrain.aerifal.cx> References: <20190530132723.GT16415@port70.net> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="248518"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14179-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 30 16:02:09 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hWLdB-0012MY-EG for gllmg-musl@m.gmane.org; Thu, 30 May 2019 16:02:09 +0200 Original-Received: (qmail 14222 invoked by uid 550); 30 May 2019 14:02:07 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14203 invoked from network); 30 May 2019 14:02:06 -0000 Content-Disposition: inline In-Reply-To: <20190530132723.GT16415@port70.net> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14163 Archived-At: On Thu, May 30, 2019 at 03:27:24PM +0200, Szabolcs Nagy wrote: > * sva sva [2019-05-30 08:59:46 -0400]: > > I am writing a heap walk program in C and would like to know if there is > > anything like the concept of arenas in musl. Basically, I need to have a > > pointer to the base address of all my allocated heaps. Unfortunately > > inspecting the musl code I found none. > > there is no such concept as "heap arena" visible to user > code, so almost surely you don't "need a pointer to the > base address" of it. > > try to describe what exactly you want to do (not in terms > of libc internals, but in terms that make sense for user > code) > > (do you want to get all memory mappings? -> try /proc/self/maps) > (do you want to track malloc behaviour? -> try malloc interposition) > (etc) To further clarify, the current allocator implementation has no global view of "the heap". It sees only free chunks and the headers or footers of the immediately adjacent-in-address-space allocated chunks. It's likely that the future replacement will have global tracking that further helps ensure integrity against heap corruption attacks, but it won't be a public API or something necessarily stable between versions. If you want a debugging malloc, you need to interpose one; for the past few releases, musl has supported malloc interposition. Rich