Commit ad65f490 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/signal32: Switch handle_signal32() to user_access_begin() logic

Replace the access_ok() by user_access_begin() and change all user
accesses to unsafe_ version.

Move flush_icache_range() outside the user access block.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/a27797f781aa00da96f8284c898173d18e952361.1597770847.git.christophe.leroy@csgroup.eu
parent 8d33001d
...@@ -840,35 +840,35 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -840,35 +840,35 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
tm_mctx = &frame->mctx_transact; tm_mctx = &frame->mctx_transact;
#endif #endif
if (!access_ok(frame, sizeof(*frame))) if (!user_write_access_begin(frame, sizeof(*frame)))
goto badframe; goto badframe;
sc = (struct sigcontext __user *) &frame->sctx; sc = (struct sigcontext __user *) &frame->sctx;
#if _NSIG != 64 #if _NSIG != 64
#error "Please adjust handle_signal()" #error "Please adjust handle_signal()"
#endif #endif
if (__put_user(to_user_ptr(ksig->ka.sa.sa_handler), &sc->handler) unsafe_put_user(to_user_ptr(ksig->ka.sa.sa_handler), &sc->handler, failed);
|| __put_user(oldset->sig[0], &sc->oldmask) unsafe_put_user(oldset->sig[0], &sc->oldmask, failed);
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
|| __put_user((oldset->sig[0] >> 32), &sc->_unused[3]) unsafe_put_user((oldset->sig[0] >> 32), &sc->_unused[3], failed);
#else #else
|| __put_user(oldset->sig[1], &sc->_unused[3]) unsafe_put_user(oldset->sig[1], &sc->_unused[3], failed);
#endif #endif
|| __put_user(to_user_ptr(mctx), &sc->regs) unsafe_put_user(to_user_ptr(mctx), &sc->regs, failed);
|| __put_user(ksig->sig, &sc->signal)) unsafe_put_user(ksig->sig, &sc->signal, failed);
goto badframe;
if (vdso32_sigtramp && tsk->mm->context.vdso_base) { if (vdso32_sigtramp && tsk->mm->context.vdso_base) {
tramp = tsk->mm->context.vdso_base + vdso32_sigtramp; tramp = tsk->mm->context.vdso_base + vdso32_sigtramp;
} else { } else {
tramp = (unsigned long)mctx->mc_pad; tramp = (unsigned long)mctx->mc_pad;
/* Set up the sigreturn trampoline: li r0,sigret; sc */ /* Set up the sigreturn trampoline: li r0,sigret; sc */
if (__put_user(PPC_INST_ADDI + __NR_sigreturn, &mctx->mc_pad[0])) unsafe_put_user(PPC_INST_ADDI + __NR_sigreturn, &mctx->mc_pad[0], failed);
goto badframe; unsafe_put_user(PPC_INST_SC, &mctx->mc_pad[1], failed);
if (__put_user(PPC_INST_SC, &mctx->mc_pad[1]))
goto badframe;
flush_icache_range(tramp, tramp + 2 * sizeof(unsigned long));
} }
user_write_access_end();
if (tramp == (unsigned long)mctx->mc_pad)
flush_icache_range(tramp, tramp + 2 * sizeof(unsigned long));
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
if (MSR_TM_ACTIVE(msr)) { if (MSR_TM_ACTIVE(msr)) {
...@@ -901,6 +901,9 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -901,6 +901,9 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
regs->msr &= ~MSR_LE; regs->msr &= ~MSR_LE;
return 0; return 0;
failed:
user_write_access_end();
badframe: badframe:
signal_fault(tsk, regs, "handle_signal32", frame); signal_fault(tsk, regs, "handle_signal32", frame);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment