mirror of https://gitee.com/openkylin/linux.git
powerpc/signal32: Perform access_ok() inside restore_user_regs()
In preparation of using user_access_begin/end in restore_user_regs(), move the access_ok() inside the function. It makes no difference as the behaviour on a failed access_ok() is the same as on failed restore_user_regs(). Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/c106eb2f37c3040f1fd38b40e50c670feb7cb835.1616151715.git.christophe.leroy@csgroup.eu
This commit is contained in:
parent
ca9e1605cd
commit
362471b319
|
@ -492,6 +492,8 @@ static long restore_user_regs(struct pt_regs *regs,
|
||||||
int i;
|
int i;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!access_ok(sr, sizeof(*sr)))
|
||||||
|
return 1;
|
||||||
/*
|
/*
|
||||||
* restore general registers but not including MSR or SOFTE. Also
|
* restore general registers but not including MSR or SOFTE. Also
|
||||||
* take care of keeping r2 (TLS) intact if not a signal
|
* take care of keeping r2 (TLS) intact if not a signal
|
||||||
|
@ -963,13 +965,10 @@ static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int
|
||||||
if (__get_user(cmcp, &ucp->uc_regs))
|
if (__get_user(cmcp, &ucp->uc_regs))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
mcp = (struct mcontext __user *)(u64)cmcp;
|
mcp = (struct mcontext __user *)(u64)cmcp;
|
||||||
/* no need to check access_ok(mcp), since mcp < 4GB */
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (__get_user(mcp, &ucp->uc_regs))
|
if (__get_user(mcp, &ucp->uc_regs))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (!access_ok(mcp, sizeof(*mcp)))
|
|
||||||
return -EFAULT;
|
|
||||||
#endif
|
#endif
|
||||||
set_current_blocked(&set);
|
set_current_blocked(&set);
|
||||||
if (restore_user_regs(regs, mcp, sig))
|
if (restore_user_regs(regs, mcp, sig))
|
||||||
|
@ -1362,8 +1361,7 @@ SYSCALL_DEFINE0(sigreturn)
|
||||||
} else {
|
} else {
|
||||||
sr = (struct mcontext __user *)from_user_ptr(sigctx.regs);
|
sr = (struct mcontext __user *)from_user_ptr(sigctx.regs);
|
||||||
addr = sr;
|
addr = sr;
|
||||||
if (!access_ok(sr, sizeof(*sr))
|
if (restore_user_regs(regs, sr, 1))
|
||||||
|| restore_user_regs(regs, sr, 1))
|
|
||||||
goto badframe;
|
goto badframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue