Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2013279ybb; Thu, 26 Mar 2020 19:34:54 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsb38vILwzd3vbtg92q8vlVxF/pRi47uCy/Icckckq2cR4kLsZ/Z5N5BcwFKTupStzeCojh X-Received: by 2002:a05:6830:1046:: with SMTP id b6mr8043732otp.229.1585276494110; Thu, 26 Mar 2020 19:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585276494; cv=none; d=google.com; s=arc-20160816; b=Ii/s/DFE9OfiZAiZy26pVgHACn5ynLO7VheGBtdvDh+fUl6KBOTIAcgsG80u29D5Lc lWyQJDUVuwyCDzyiWZa6My11gSmurX3vw9eS3MqPLjRAfmcMeS3VTYeONsKRa2p/Q1zk o7QTw7J7rZ9FT2HpKynKjMN2m+xq9PK4QcvzIZJIaQyz48M4Mkb9cILSDMIPYy10j3KS eaSO/DPbgfUn/4/2ycOY8qRWic/mtNS0EurWb9U8A9FAe3lYB97+TNWtCAB192sIMW28 HG/QF0L2cCTqmDACRN4Bn9pJMw9jGj1CbsxTe7z1BcChaCq5oBOZOeGJzoJB14jFrQ2t y4Aw== 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=YdxmV8So4XgUSqH5AS6VpUJjwfIiCfepLBFZkXw4QF4=; b=rYJQTS+EyKiAd8q7HRHapLt9TMicrKm2XkY9TQU85H+SvMOVoCl5njXgs0VzMVAaky jrpe+NKXG3h2JjbXNxq3H4oSuv+hWTTXYyxmQaIQVb/0a+jZCvxhI4bPgCzthV3liJfC aljHfKYYylSPfFP+bjLilz5tJSkfEP4X+ZRFHh2kZXV73x0nZdAI7qxtYJEsNUWZNb/b cKB3V7fco/+eZFaJOj0UmClh3GvgOaIugOYO6vI4xFSdNjByMH8y+7xdEyNMvoGIYjAW SiTzkeGLlWWVttXwY7KDVYExp4E+6Vdy2d4/PdcWkv7F8fvF0S5H1j0QZFS5xh5Hgmlg nz8A== 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 t193si1830998oih.61.2020.03.26.19.34.42; Thu, 26 Mar 2020 19:34:54 -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 S1727793AbgC0Cct (ORCPT + 99 others); Thu, 26 Mar 2020 22:32:49 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:48048 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727873AbgC0CcL (ORCPT ); Thu, 26 Mar 2020 22:32:11 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHen0-003hS5-U2; Fri, 27 Mar 2020 02:32:06 +0000 From: Al Viro To: Linus Torvalds Cc: Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC][PATCH v2 14/22] x86: ia32_setup_frame(): consolidate uaccess areas Date: Fri, 27 Mar 2020 02:31:57 +0000 Message-Id: <20200327023205.881896-14-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200327023205.881896-1-viro@ZenIV.linux.org.uk> References: <20200327023007.GS23230@ZenIV.linux.org.uk> <20200327023205.881896-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 Currently we have user_access block, followed by __put_user(), deciding what the restorer will be and finally a put_user_try block. Moving the calculation of restorer first allows the rest (actual copyout work) to coalesce into a single user_access block. Signed-off-by: Al Viro --- arch/x86/ia32/ia32_signal.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index 799ca5b31b87..7018c2c325a1 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c @@ -236,7 +236,6 @@ int ia32_setup_frame(int sig, struct ksignal *ksig, { struct sigframe_ia32 __user *frame; void __user *restorer; - int err = 0; void __user *fp = NULL; /* copy_to_user optimizes that into a single 8 byte store */ @@ -252,21 +251,6 @@ int ia32_setup_frame(int sig, struct ksignal *ksig, frame = get_sigframe(ksig, regs, sizeof(*frame), &fp); - if (!access_ok(frame, sizeof(*frame))) - return -EFAULT; - - if (__put_user(sig, &frame->sig)) - return -EFAULT; - - if (!user_access_begin(&frame->sc, sizeof(struct sigcontext_32))) - return -EFAULT; - - unsafe_put_sigcontext32(&frame->sc, fp, regs, set, Efault); - user_access_end(); - - if (__put_user(set->sig[1], &frame->extramask[0])) - return -EFAULT; - if (ksig->ka.sa.sa_flags & SA_RESTORER) { restorer = ksig->ka.sa.sa_restorer; } else { @@ -278,19 +262,20 @@ int ia32_setup_frame(int sig, struct ksignal *ksig, restorer = &frame->retcode; } - put_user_try { - put_user_ex(ptr_to_compat(restorer), &frame->pretcode); - - /* - * These are actually not used anymore, but left because some - * gdb versions depend on them as a marker. - */ - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode); - } put_user_catch(err); - - if (err) + if (!user_access_begin(frame, sizeof(*frame))) return -EFAULT; + unsafe_put_user(sig, &frame->sig, Efault); + unsafe_put_sigcontext32(&frame->sc, fp, regs, set, Efault); + unsafe_put_user(set->sig[1], &frame->extramask[0], Efault); + unsafe_put_user(ptr_to_compat(restorer), &frame->pretcode, Efault); + /* + * These are actually not used anymore, but left because some + * gdb versions depend on them as a marker. + */ + unsafe_put_user(*((u64 *)&code), (u64 __user *)frame->retcode, Efault); + user_access_end(); + /* Set up registers for signal handler */ regs->sp = (unsigned long) frame; regs->ip = (unsigned long) ksig->ka.sa.sa_handler; -- 2.11.0