Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250701160041.GB1827@brightrain.aerifal.cx>
Date: Tue, 1 Jul 2025 12:00:41 -0400
From: Rich Felker <dalias@...c.org>
To: Alex Rønne Petersen <alex@...xrp.com>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH v2] clone: clear the frame pointer in the child
 process on relevant ports

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.

This should be checked on other archs too.

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.