NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-mips/59343: compat_sigsetjmp.S: missing RESTORE_GP64



>Number:         59343
>Category:       port-mips
>Synopsis:       compat_sigsetjmp.S: missing RESTORE_GP64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-mips-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 23 02:30:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, 8, 7, 6, ...
>Organization:
The CompatBSD Mipsglobalization
>Environment:
>Description:
The compat13 sigsetjmp function uses SAVE_GP and SAVE_GP64 to save gp on ABIs where gp is callee-saves (n32, n64), so it can restore gp when it returns.  Except it doesn't actually restore gp -- it does a tail call to _setjmp or setjmp, but doesn't return gp before (or after, making it a non-tail call).

     61 LEAF(sigsetjmp)
     62 	SETUP_GP
     63 	SETUP_GP64(t0, sigsetjmp)
     64 	INT_S	a1, _SC_MASK13(a0)		# save "savemask"
     65 	bne	a1, 0x0, 1f			# do saving of signal mask?
     66 	PTR_LA	t9, _C_LABEL(_setjmp)
     67 	jr	t9
     68 
     69 1:	PTR_LA	t9, _C_LABEL(setjmp)
     70 	jr	t9
     71 END(sigsetjmp)

https://nxr.netbsd.org/xref/src/lib/libc/compat/arch/mips/gen/compat_sigsetjmp.S?r=1.3#61

It's OK for longjmp to not restore gp -- it doesn't return.  But setjmp definitely does return.
>How-To-Repeat:
run a binary that uses compat13 sigsetjmp and siglongjmp
>Fix:
RESTORE_GP64



Home | Main Index | Thread Index | Old Index