Skip to content

Commit dceaafd

Browse files
committed
openrisc: Union fpcsr and oldmask in sigcontext to unbreak userspace ABI
With commit 2726765 ("openrisc: Support floating point user api") I added an entry to the struct sigcontext which caused an unwanted change to the userspace ABI. To fix this we use the previously unused oldmask field space for the floating point fpcsr state. We do this with a union to restore the ABI back to the pre kernel v6.4 ABI and keep API compatibility. This does mean if there is some code somewhere that is setting oldmask in an OpenRISC specific userspace sighandler it would end up setting the floating point register status, but I think it's unlikely as oldmask was never functional before. Fixes: 2726765 ("openrisc: Support floating point user api") Reported-by: Szabolcs Nagy <[email protected]> Closes: https://lore.kernel.org/openrisc/[email protected]/ Signed-off-by: Stafford Horne <[email protected]>
1 parent 45a3e24 commit dceaafd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

arch/openrisc/include/uapi/asm/sigcontext.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828

2929
struct sigcontext {
3030
struct user_regs_struct regs; /* needs to be first */
31-
struct __or1k_fpu_state fpu;
32-
unsigned long oldmask;
31+
union {
32+
unsigned long fpcsr;
33+
unsigned long oldmask; /* unused */
34+
};
3335
};
3436

3537
#endif /* __ASM_OPENRISC_SIGCONTEXT_H */

arch/openrisc/kernel/signal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static int restore_sigcontext(struct pt_regs *regs,
5050
err |= __copy_from_user(regs, sc->regs.gpr, 32 * sizeof(unsigned long));
5151
err |= __copy_from_user(&regs->pc, &sc->regs.pc, sizeof(unsigned long));
5252
err |= __copy_from_user(&regs->sr, &sc->regs.sr, sizeof(unsigned long));
53-
err |= __copy_from_user(&regs->fpcsr, &sc->fpu.fpcsr, sizeof(unsigned long));
53+
err |= __copy_from_user(&regs->fpcsr, &sc->fpcsr, sizeof(unsigned long));
5454

5555
/* make sure the SM-bit is cleared so user-mode cannot fool us */
5656
regs->sr &= ~SPR_SR_SM;
@@ -113,7 +113,7 @@ static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
113113
err |= __copy_to_user(sc->regs.gpr, regs, 32 * sizeof(unsigned long));
114114
err |= __copy_to_user(&sc->regs.pc, &regs->pc, sizeof(unsigned long));
115115
err |= __copy_to_user(&sc->regs.sr, &regs->sr, sizeof(unsigned long));
116-
err |= __copy_to_user(&sc->fpu.fpcsr, &regs->fpcsr, sizeof(unsigned long));
116+
err |= __copy_to_user(&sc->fpcsr, &regs->fpcsr, sizeof(unsigned long));
117117

118118
return err;
119119
}

0 commit comments

Comments
 (0)