If a signal handler is installed using the sigaction(2) SA_SIGINFO flag, then the signal-related context is accessible to the userspace via the ucontext_t object. This object contains: + the program counter register (i.e., the address of the next instruction in the main program that should be executed when the signal handler returns);
+ architecture-specific register state required for resuming the interrupted program;
+ the thread's current signal mask;
+ the thread's alternate signal stack settings.
Therefore, the signal handler can alter the PC and PSTATE. If Morello is supported, ensure that PC's LSB is cleared and PSTATE.C64 is set if the PC was set using C64 ISA.
Cc: Harry Ramsey harry.ramsey@arm.com Signed-off-by: Tudor Cretu tudor.cretu@arm.com ---
Many thanks to Harry (CC'ed) for finding an use case where sigreturn didn't behave as expected. Tested with Musl signal tests. Unfortunetaly, these is no LTP test that touches this functionality.
Review branch: https://git.morello-project.org/tudcre01/linux/-/commits/sigreturn_fix_v1
--- arch/arm64/kernel/signal.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 1dd040c72630..e2527df334a9 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -669,6 +669,9 @@ COMPAT_SYSCALL_DEFINE0(rt_sigreturn) if (restore_altstack(&frame->uc.uc_stack)) goto badframe;
+ if (system_supports_morello()) + morello_setup_signal_return(regs); + #if defined(CONFIG_CHERI_PURECAP_UABI) && !defined(SIGNAL_COMPAT64) return regs->cregs[0]; #else