Bug 31325 - mips: clone3 is wrong for o32
Summary: mips: clone3 is wrong for o32
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.39
: P2 normal
Target Milestone: 2.40
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-01 17:40 UTC by Adhemerval Zanella
Modified: 2024-06-15 13:37 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adhemerval Zanella 2024-02-01 17:40:10 UTC
The mips clone3 (sysdeps/unix/sysv/linux/mips/clone3.S) does not take in consideration that the cprestore might generate the gp save on the stack (so clone3 must allocate some space before issuing the syscall) and $8 is not guarantee by the kABI to be preserved after the syscall.
Comment 1 Andreas K. Huettel 2024-06-15 13:37:45 UTC
commit bbd248ac0d75efdef8fe61ea69b1fb25fb95b6e7
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Feb 1 14:29:53 2024 -0300

    mips: FIx clone3 implementation (BZ 31325)
    
    For o32 we need to setup a minimal stack frame to allow cprestore
    on __thread_start_clone3 (which instruct the linker to save the
    gp for PIC).  Also, there is no guarantee by kABI that $8 will be
    preserved after syscall execution, so we need to save it on the
    provided stack.
    
    Checked on mipsel-linux-gnu.
    
    Reported-by: Khem Raj <raj.khem@gmail.com>
    Tested-by: Khem Raj <raj.khem@gmail.com>