Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4005519ybb; Mon, 23 Mar 2020 11:40:51 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsB+VnGOTAmpYOc3mh8bDkqcCAH4aewK7XZvpMOSFgrA+rKSD9yPWWKqvHZGvMZPa/6wtV4 X-Received: by 2002:a05:6830:1bc9:: with SMTP id v9mr18455188ota.319.1584988850977; Mon, 23 Mar 2020 11:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584988850; cv=none; d=google.com; s=arc-20160816; b=GJrvkckphukne9PhMQMmmBzbuwoNrxL5bvsn56zkT0s1vxAxyrsEldFJNNRTHIfWs2 ZLzhcaHL7y88crtHFP4tv4m4hCKWezL7LREg0tJiZNzZoY09Woc1wzHvCh3IDwDKtPsg 1TL0/rd3J7ow9JVQFgrBIHQlViqwbaqHwhfBafdWS/bNuTyADDGsW9crfNnrIHcZW+nD LlkofZ8jMQXbia+lj9yB7QYoiIcNfaC6J0VoP1OB+6RGXwzwourAczsU9nGh1vX39/cG w5y7LDjSUIP/taNk+7JGI17/y65IzoWcfyF/9t3247UaVLyvAkqMjCMbYlQleyfAZvJb +dpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xvM2UXLGE6VBVJB2wNu5X+ex1ok7XJwvjzU6Td7moDI=; b=jngN7Pm3kvlPflS4fYkdHidjHSZ7kp+MTRNz6CFVh0gdSQJlcC6XoncVcgGwxiEo4f N/I74krv+tJi9KPA80tltOIA+wIrc+Semlyv28pXv2v5pU0v7tj2NCv1Wu/Yr4lXTmMi yWTrSs8kLuP7jLgbODUfh4ulR6oB3YMc+jJyg8eiz9wOTdO5mg+X2QjKKZJOc7FKZO51 o+QPmNFW0fVnj4JdNesS0k5BOXLF61IvtVaeLm+2pbgaw5+lHVVOElF0HApvDu9SANG3 qtYAxch0FoIfuFpZHqWmkYC3qk4Z3hp8EfeFfp8GGWAq3e6oq0AbIJs8goot4Iyarpui nBVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j78si7604731oih.19.2020.03.23.11.40.38; Mon, 23 Mar 2020 11:40:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727940AbgCWSiv (ORCPT + 99 others); Mon, 23 Mar 2020 14:38:51 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:46776 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727697AbgCWSiZ (ORCPT ); Mon, 23 Mar 2020 14:38:25 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jGRxv-00137D-EW; Mon, 23 Mar 2020 18:38:23 +0000 From: Al Viro To: Linus Torvalds Cc: Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC][PATCH 19/22] x86: __setup_rt_frame(): consolidate uaccess areas Date: Mon, 23 Mar 2020 18:38:16 +0000 Message-Id: <20200323183819.250124-19-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200323183819.250124-1-viro@ZenIV.linux.org.uk> References: <20200323183620.GD23230@ZenIV.linux.org.uk> <20200323183819.250124-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro reorder copy_siginfo_to_user() calls a bit Signed-off-by: Al Viro --- 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