lkml.org 
[lkml]   [2020]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 19/22] x86: __setup_rt_frame(): consolidate uaccess areas
Date
From: Al Viro <viro@zeniv.linux.org.uk>

reorder copy_siginfo_to_user() calls a bit

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
arch/x86/kernel/signal.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 02b81784acc7..66bcb5539ae7 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -351,7 +351,6 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
{
struct rt_sigframe __user *frame;
void __user *restorer;
- int err = 0;
void __user *fpstate = NULL;

frame = get_sigframe(&ksig->ka, regs, sizeof(*frame), &fpstate);
@@ -389,11 +388,11 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
if (setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
regs, set->sig[0]))
goto Efault;
+ unsafe_put_user(*(__u64 *)set,
+ (__u64 __user *)&frame->uc.uc_sigmask, Efault);
user_access_end();

- err |= copy_siginfo_to_user(&frame->info, &ksig->info);
- err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
- if (err)
+ if (copy_siginfo_to_user(&frame->info, &ksig->info))
return -EFAULT;

/* Set up registers for signal handler */
@@ -435,23 +434,14 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
struct rt_sigframe __user *frame;
void __user *fp = NULL;
unsigned long uc_flags;
- int err = 0;

/* x86-64 should always use SA_RESTORER. */
if (!(ksig->ka.sa.sa_flags & SA_RESTORER))
return -EFAULT;

frame = get_sigframe(&ksig->ka, regs, sizeof(struct rt_sigframe), &fp);
-
- if (!access_ok(frame, sizeof(*frame)))
- return -EFAULT;
-
- if (ksig->ka.sa.sa_flags & SA_SIGINFO) {
- if (copy_siginfo_to_user(&frame->info, &ksig->info))
- return -EFAULT;
- }
-
uc_flags = frame_uc_flags(regs);
+
if (!user_access_begin(frame, sizeof(*frame)))
return -EFAULT;

@@ -465,11 +455,13 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
unsafe_put_user(ksig->ka.sa.sa_restorer, &frame->pretcode, Efault);
if (setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]))
goto Efault;
+ unsafe_put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0], Efault);
user_access_end();
- err |= __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);

- if (err)
- return -EFAULT;
+ if (ksig->ka.sa.sa_flags & SA_SIGINFO) {
+ if (copy_siginfo_to_user(&frame->info, &ksig->info))
+ return -EFAULT;
+ }

/* Set up registers for signal handler */
regs->di = sig;
--
2.11.0
\
 
 \ /
  Last update: 2020-03-23 19:40    [W:0.136 / U:5.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site