Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/signal32: Use fault_in_pages_readable() to prefault user context

Use fault_in_pages_readable() to prefault user context
instead of open coding

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Christophe Leroy and committed by
Michael Ellerman
56b04d56 d04f11d2

+5 -8
+5 -8
arch/powerpc/kernel/signal_32.c
··· 25 25 #include <linux/errno.h> 26 26 #include <linux/elf.h> 27 27 #include <linux/ptrace.h> 28 + #include <linux/pagemap.h> 28 29 #include <linux/ratelimit.h> 29 30 #include <linux/syscalls.h> 30 31 #ifdef CONFIG_PPC64 ··· 1050 1049 #endif 1051 1050 { 1052 1051 struct pt_regs *regs = current_pt_regs(); 1053 - unsigned char tmp __maybe_unused; 1054 1052 int ctx_has_vsx_region = 0; 1055 1053 1056 1054 #ifdef CONFIG_PPC64 ··· 1113 1113 } 1114 1114 if (new_ctx == NULL) 1115 1115 return 0; 1116 - if (!access_ok(VERIFY_READ, new_ctx, ctx_size) 1117 - || __get_user(tmp, (u8 __user *) new_ctx) 1118 - || __get_user(tmp, (u8 __user *) new_ctx + ctx_size - 1)) 1116 + if (!access_ok(VERIFY_READ, new_ctx, ctx_size) || 1117 + fault_in_pages_readable((u8 __user *)new_ctx, ctx_size)) 1119 1118 return -EFAULT; 1120 1119 1121 1120 /* ··· 1241 1242 struct pt_regs *regs = current_pt_regs(); 1242 1243 struct sig_dbg_op op; 1243 1244 int i; 1244 - unsigned char tmp __maybe_unused; 1245 1245 unsigned long new_msr = regs->msr; 1246 1246 #ifdef CONFIG_PPC_ADV_DEBUG_REGS 1247 1247 unsigned long new_dbcr0 = current->thread.debug.dbcr0; ··· 1296 1298 current->thread.debug.dbcr0 = new_dbcr0; 1297 1299 #endif 1298 1300 1299 - if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx)) 1300 - || __get_user(tmp, (u8 __user *) ctx) 1301 - || __get_user(tmp, (u8 __user *) (ctx + 1) - 1)) 1301 + if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx)) || 1302 + fault_in_pages_readable((u8 __user *)ctx, sizeof(*ctx))) 1302 1303 return -EFAULT; 1303 1304 1304 1305 /*