summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2020-08-18 17:19:29 +0000
committerMichael Ellerman <mpe@ellerman.id.au>2020-12-04 01:01:13 +1100
commitad65f4909fd3736d84533784cd9ab76905536b34 (patch)
tree3ef6c71cf62b0414e8317c9139894da307cab0a2 /arch/powerpc/kernel
parent8d33001dd650b88e915a1a13e2ca807350e374df (diff)
downloadlinux-stable-ad65f4909fd3736d84533784cd9ab76905536b34.tar.gz
linux-stable-ad65f4909fd3736d84533784cd9ab76905536b34.tar.bz2
linux-stable-ad65f4909fd3736d84533784cd9ab76905536b34.zip
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: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/a27797f781aa00da96f8284c898173d18e952361.1597770847.git.christophe.leroy@csgroup.eu
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/signal_32.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index d8c3843102df..fc8ba4b29edf 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -840,35 +840,35 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
tm_mctx = &frame->mctx_transact;
#endif
- if (!access_ok(frame, sizeof(*frame)))
+ if (!user_write_access_begin(frame, sizeof(*frame)))
goto badframe;
sc = (struct sigcontext __user *) &frame->sctx;
#if _NSIG != 64
#error "Please adjust handle_signal()"
#endif
- if (__put_user(to_user_ptr(ksig->ka.sa.sa_handler), &sc->handler)
- || __put_user(oldset->sig[0], &sc->oldmask)
+ unsafe_put_user(to_user_ptr(ksig->ka.sa.sa_handler), &sc->handler, failed);
+ unsafe_put_user(oldset->sig[0], &sc->oldmask, failed);
#ifdef CONFIG_PPC64
- || __put_user((oldset->sig[0] >> 32), &sc->_unused[3])
+ unsafe_put_user((oldset->sig[0] >> 32), &sc->_unused[3], failed);
#else
- || __put_user(oldset->sig[1], &sc->_unused[3])
+ unsafe_put_user(oldset->sig[1], &sc->_unused[3], failed);
#endif
- || __put_user(to_user_ptr(mctx), &sc->regs)
- || __put_user(ksig->sig, &sc->signal))
- goto badframe;
+ unsafe_put_user(to_user_ptr(mctx), &sc->regs, failed);
+ unsafe_put_user(ksig->sig, &sc->signal, failed);
if (vdso32_sigtramp && tsk->mm->context.vdso_base) {
tramp = tsk->mm->context.vdso_base + vdso32_sigtramp;
} else {
tramp = (unsigned long)mctx->mc_pad;
/* Set up the sigreturn trampoline: li r0,sigret; sc */
- if (__put_user(PPC_INST_ADDI + __NR_sigreturn, &mctx->mc_pad[0]))
- goto badframe;
- if (__put_user(PPC_INST_SC, &mctx->mc_pad[1]))
- goto badframe;
- flush_icache_range(tramp, tramp + 2 * sizeof(unsigned long));
+ unsafe_put_user(PPC_INST_ADDI + __NR_sigreturn, &mctx->mc_pad[0], failed);
+ unsafe_put_user(PPC_INST_SC, &mctx->mc_pad[1], failed);
}
+ 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
if (MSR_TM_ACTIVE(msr)) {
@@ -901,6 +901,9 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
regs->msr &= ~MSR_LE;
return 0;
+failed:
+ user_write_access_end();
+
badframe:
signal_fault(tsk, regs, "handle_signal32", frame);