powerpc: Use trap metadata to prevent double restart rather than zeroing trap
It's not very nice to zero trap for this, because then system calls no longer have trap_is_syscall(regs) invariant, and we can't distinguish between sc and scv system calls (in a later patch). Take one last unused bit from the low bits of the pt_regs.trap word for this instead. There is not a really good reason why it should be in trap as opposed to another field, but trap has some concept of flags and it exists. Ideally I think we would move trap to 2-byte field and have 2 more bytes available independently. Add a selftests case for this, which can be seen to fail if trap_norestart() is changed to return false. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> [mpe: Make them static inlines] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200507121332.2233629-4-mpe@ellerman.id.au
This commit is contained in:

committed by
Michael Ellerman

parent
912237ea16
commit
4e0e45b07d
@@ -350,8 +350,8 @@ static long restore_sigcontext(struct task_struct *tsk, sigset_t *set, int sig,
|
||||
err |= __get_user(regs->link, &sc->gp_regs[PT_LNK]);
|
||||
err |= __get_user(regs->xer, &sc->gp_regs[PT_XER]);
|
||||
err |= __get_user(regs->ccr, &sc->gp_regs[PT_CCR]);
|
||||
/* skip SOFTE */
|
||||
regs->trap = 0;
|
||||
/* Don't allow userspace to set SOFTE */
|
||||
set_trap_norestart(regs);
|
||||
err |= __get_user(regs->dar, &sc->gp_regs[PT_DAR]);
|
||||
err |= __get_user(regs->dsisr, &sc->gp_regs[PT_DSISR]);
|
||||
err |= __get_user(regs->result, &sc->gp_regs[PT_RESULT]);
|
||||
@@ -472,10 +472,8 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,
|
||||
&sc->gp_regs[PT_XER]);
|
||||
err |= __get_user(tsk->thread.ckpt_regs.ccr,
|
||||
&sc->gp_regs[PT_CCR]);
|
||||
|
||||
/* Don't allow userspace to set the trap value */
|
||||
regs->trap = 0;
|
||||
|
||||
/* Don't allow userspace to set SOFTE */
|
||||
set_trap_norestart(regs);
|
||||
/* These regs are not checkpointed; they can go in 'regs'. */
|
||||
err |= __get_user(regs->dar, &sc->gp_regs[PT_DAR]);
|
||||
err |= __get_user(regs->dsisr, &sc->gp_regs[PT_DSISR]);
|
||||
|
Reference in New Issue
Block a user