|
|
Message-ID: <20250808024428.GR1827@brightrain.aerifal.cx> Date: Thu, 7 Aug 2025 22:44:28 -0400 From: Rich Felker <dalias@...c.org> To: Thorsten Glaser <tg@...lvis.org> Cc: musl@...ts.openwall.com, David Edelsohn <dje.gcc@...il.com>, Sertonix <sertonix@...teo.net> Subject: Re: ctr registry after syscall on powerpc On Fri, Aug 08, 2025 at 02:32:16AM +0200, Thorsten Glaser wrote: > On Thu, 7 Aug 2025, Rich Felker wrote: > > >> > The relevant code from src/malloc/mallocng/malloc.c: > >> > > >> > size_t pagesize = PGSZ; // stored into ctr registry > >> > ... > >> > ctx.brk = brk(0); // mess up ctr registry > >> > ... > >> > ctx.brk += -ctx.brk & (pagesize-1); // try to read back ctr > >> > registry > > >It's not across a[n exteral] call. It's just across an (inlineable) > >syscall. So apparently this is a bug in our syscall asm constraints. > > Is brk() an inlineable syscall that frees GCC from having to save > registers it can clobber? > > Hm, perhaps if it can “see” the entire implementation, but that may > be surprising to users. But… I mean, it’s not static inline or a > macro, is it? > > (Just adding that clobber is ofc good.) In this particular code it is. There is no functional brk() in musl. It's not a supported programming model for various reasons that mostly amount to it being catastrophically-breaking if called in a program that uses malloc, but "uses malloc" is not really a defined concept since various libc interfaces may use malloc internally. The brk() used internally in mallocng is a macro defined in the host-environment-glue include file glue.h, and it expands to essentially __syscall(SYS_brk,p) where __syscall is a macro expanding to a call to the __syscall1 static inline function whose body is an asm statement. For a non-libc-internal use of mallocng you'd generally define it to just be always-failing unless the system has a brk you can safely use. 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.