[PATCH 3/7] powerpc/signal64: Access function descriptor with user access block

From: Christophe Leroy
Date: Tue Jun 15 2021 - 02:41:35 EST


Access the function descriptor of the handler within a
user access block.

Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
---
arch/powerpc/kernel/signal_64.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 8b2eb758131c..9ca97b4366df 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -936,8 +936,18 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set,
func_descr_t __user *funct_desc_ptr =
(func_descr_t __user *) ksig->ka.sa.sa_handler;

- err |= get_user(regs->ctr, &funct_desc_ptr->entry);
- err |= get_user(regs->gpr[2], &funct_desc_ptr->toc);
+ if (user_read_access_begin(funct_desc_ptr, sizeof(func_descr_t))) {
+ unsafe_get_user(regs->ctr, &funct_desc_ptr->entry, bad_funct_desc_block);
+ unsafe_get_user(regs->gpr[2], &funct_desc_ptr->toc, bad_funct_desc_block);
+ } else {
+ goto bad_funct_desc;
+bad_funct_desc_block:
+ user_read_access_end();
+bad_funct_desc:
+ signal_fault(current, regs, __func__, funct_desc_ptr);
+ return 1;
+ }
+ user_read_access_end();
}

/* enter the signal handler in native-endian mode */
--
2.25.0