![]() |
|
Message-Id: <89f9c556-a5c2-4d81-99fd-b6cc8d9957d2@app.fastmail.com> Date: Tue, 01 Jul 2025 18:14:28 +0200 From: Alex Rønne Petersen <alex@...xrp.com> To: "Rich Felker" <dalias@...c.org> Cc: musl@...ts.openwall.com Subject: Re: [PATCH v2] clone: clear the frame pointer in the child process on relevant ports On Tue, Jul 1, 2025, at 18:00, Rich Felker wrote: > On Thu, Dec 12, 2024 at 05:56:04PM +0100, Alex Rønne Petersen wrote: >> This just mirrors what is done in the start code for the affected ports, as well >> as what is already done for the three x86 ports. >> >> Clearing the frame pointer helps protect FP-based unwinders which have no way of >> knowing that the FP register should be considered undefined in the child process >> portion of clone(). In practice, we found this change to be necessary when >> running the Zig standard library tests under qemu-aarch64_be with musl linked. >> >> This version of the patch omits the branch inversion on x86 and powerpc from the >> previous version, per the discussion there. >> --- >> src/thread/aarch64/clone.s | 3 ++- >> src/thread/arm/clone.s | 3 ++- >> src/thread/loongarch64/clone.s | 1 + >> src/thread/m68k/clone.s | 3 ++- >> src/thread/microblaze/clone.s | 3 ++- >> src/thread/mips/clone.s | 3 ++- >> src/thread/mips64/clone.s | 3 ++- >> src/thread/mipsn32/clone.s | 3 ++- >> src/thread/or1k/clone.s | 3 ++- >> 9 files changed, 17 insertions(+), 8 deletions(-) >> >> diff --git a/src/thread/aarch64/clone.s b/src/thread/aarch64/clone.s >> index e3c83395..9ac272bd 100644 >> --- a/src/thread/aarch64/clone.s >> +++ b/src/thread/aarch64/clone.s >> @@ -24,7 +24,8 @@ __clone: >> // parent >> ret >> // child >> -1: ldp x1,x0,[sp],#16 >> +1: mov fp, 0 >> + ldp x1,x0,[sp],#16 > > The alias fp does not seem to be supported across all assemblers. I'm > committing a fix that changes this to use the real name x29 unless > there's any objection and proposed correction. That seems fine. > This should be checked on other archs too. * arm: fp -> r11 * loongarch: $fp -> $r22 * m68k: %fp -> %a6 * mips: $fp -> $30 I'm not sure for which it's actually necessary, but I see no particular harm in just making the changes anyway, just in case.
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.