mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
openrisc: Union fpcsr and oldmask in sigcontext to unbreak userspace ABI
With commit27267655c5
("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:27267655c5
("openrisc: Support floating point user api") Reported-by: Szabolcs Nagy <nsz@port70.net> Closes: https://lore.kernel.org/openrisc/20230626213840.GA1236108@port70.net/ Signed-off-by: Stafford Horne <shorne@gmail.com>
This commit is contained in:
parent
45a3e24f65
commit
dceaafd668
@ -28,8 +28,10 @@
|
||||
|
||||
struct sigcontext {
|
||||
struct user_regs_struct regs; /* needs to be first */
|
||||
struct __or1k_fpu_state fpu;
|
||||
unsigned long oldmask;
|
||||
union {
|
||||
unsigned long fpcsr;
|
||||
unsigned long oldmask; /* unused */
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* __ASM_OPENRISC_SIGCONTEXT_H */
|
||||
|
@ -50,7 +50,7 @@ static int restore_sigcontext(struct pt_regs *regs,
|
||||
err |= __copy_from_user(regs, sc->regs.gpr, 32 * sizeof(unsigned long));
|
||||
err |= __copy_from_user(®s->pc, &sc->regs.pc, sizeof(unsigned long));
|
||||
err |= __copy_from_user(®s->sr, &sc->regs.sr, sizeof(unsigned long));
|
||||
err |= __copy_from_user(®s->fpcsr, &sc->fpu.fpcsr, sizeof(unsigned long));
|
||||
err |= __copy_from_user(®s->fpcsr, &sc->fpcsr, sizeof(unsigned long));
|
||||
|
||||
/* make sure the SM-bit is cleared so user-mode cannot fool us */
|
||||
regs->sr &= ~SPR_SR_SM;
|
||||
@ -113,7 +113,7 @@ static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
||||
err |= __copy_to_user(sc->regs.gpr, regs, 32 * sizeof(unsigned long));
|
||||
err |= __copy_to_user(&sc->regs.pc, ®s->pc, sizeof(unsigned long));
|
||||
err |= __copy_to_user(&sc->regs.sr, ®s->sr, sizeof(unsigned long));
|
||||
err |= __copy_to_user(&sc->fpu.fpcsr, ®s->fpcsr, sizeof(unsigned long));
|
||||
err |= __copy_to_user(&sc->fpcsr, ®s->fpcsr, sizeof(unsigned long));
|
||||
|
||||
return err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user