powerpc: use probe_user_read() and probe_user_write()
Instead of opencoding, use probe_user_read() to failessly read a user location and probe_user_write() for writing to user. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/e041f5eedb23f09ab553be8a91c3de2087147320.1579800517.git.christophe.leroy@c-s.fr
This commit is contained in:

committed by
Michael Ellerman

parent
1e3531982e
commit
def0bfdbd6
@@ -28,15 +28,12 @@ static unsigned int user_getsp32(unsigned int sp, int is_first)
|
||||
unsigned int stack_frame[2];
|
||||
void __user *p = compat_ptr(sp);
|
||||
|
||||
if (!access_ok(p, sizeof(stack_frame)))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* The most likely reason for this is that we returned -EFAULT,
|
||||
* which means that we've done all that we can do from
|
||||
* interrupt context.
|
||||
*/
|
||||
if (__copy_from_user_inatomic(stack_frame, p, sizeof(stack_frame)))
|
||||
if (probe_user_read(stack_frame, (void __user *)p, sizeof(stack_frame)))
|
||||
return 0;
|
||||
|
||||
if (!is_first)
|
||||
@@ -54,11 +51,7 @@ static unsigned long user_getsp64(unsigned long sp, int is_first)
|
||||
{
|
||||
unsigned long stack_frame[3];
|
||||
|
||||
if (!access_ok((void __user *)sp, sizeof(stack_frame)))
|
||||
return 0;
|
||||
|
||||
if (__copy_from_user_inatomic(stack_frame, (void __user *)sp,
|
||||
sizeof(stack_frame)))
|
||||
if (probe_user_read(stack_frame, (void __user *)sp, sizeof(stack_frame)))
|
||||
return 0;
|
||||
|
||||
if (!is_first)
|
||||
@@ -103,7 +96,6 @@ void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth)
|
||||
first_frame = 0;
|
||||
}
|
||||
} else {
|
||||
pagefault_disable();
|
||||
#ifdef CONFIG_PPC64
|
||||
if (!is_32bit_task()) {
|
||||
while (depth--) {
|
||||
@@ -112,7 +104,6 @@ void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth)
|
||||
break;
|
||||
first_frame = 0;
|
||||
}
|
||||
pagefault_enable();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -123,6 +114,5 @@ void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth)
|
||||
break;
|
||||
first_frame = 0;
|
||||
}
|
||||
pagefault_enable();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user