Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp262076ybi; Wed, 29 May 2019 20:54:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJoAudKgcmWcOA4O9GkVOswO3nkTS60/zbFBa3ZY8t13pevbTG2QBbrI3ldx+5BNCXSrbL X-Received: by 2002:a63:4826:: with SMTP id v38mr1766773pga.417.1559188476115; Wed, 29 May 2019 20:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559188476; cv=none; d=google.com; s=arc-20160816; b=IUmJZl9I2FDYtVbcMxMt+u4UNsNAJ/X87fQj4dkhJRtW6byNJfmlCipC0n7gQeKZql QoTGQzQT1rjikPBsy6qt6wGzX2VpYpgoaOx8ntRnZxFywm8Fvuu3plsVE24C1CL+bpUw 2tEPMgSCyD9U0kL4KrSMZP8yHnHwSWv+2CgpbmHhgF3YxNK32S2519DtWmYYT/y22uGC NQYRZpKLJHXE3SBAzfSU1NLH/lPx3zNoGc8eEpEIAZn5l2acp98R6jMQWUAydXQKbEaA dj5DIuav3IPgdkTTIuFclnyrjTVMc5rWeDrYvz8oBZcaT4dMKMy0TPIV4xhSUvyIwJ/M qItw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kmfdqAD9Iv2tqtN2eHSenpRH8Ik8nsD3+4hcvBZiBn8=; b=MtyfoyHqGwGIih+ePWeEBE6rcPmLIlCavg+VZle7sq7jzzMUYEufq189AtaPBI4Zwi Hqx5Ho2r/dGk4WO6puM6/sUyEO6CSAEKvwfI3VHcX/8h6DG5Lw2tnNdPIyhGTOHD2Vr8 TmnJzzqiu/XSuv743td/7Bsrky7huMsNRJUNNpu2oGRhehMqGo1VhJ158ezrYRY1l4Re FXEO2V15ZVS/SSB0psJuXIEKrqA800W/FEnsGZLzE4XYzoOoXA4WC8aQ1dnB2vZ1MYhj o6o6lzzwMpxzZik9uakeXSHYWP/HdIUbRsOTqUR4aRNOb2GYicHnFn3/BxXzVscw1uKt 6uXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=huKsPXVM; 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 h1si2108371pgs.290.2019.05.29.20.54.20; Wed, 29 May 2019 20:54:36 -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; dkim=pass header.i=@kernel.org header.s=default header.b=huKsPXVM; 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 S1727196AbfE3Dv0 (ORCPT + 99 others); Wed, 29 May 2019 23:51:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:56600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732016AbfE3DTr (ORCPT ); Wed, 29 May 2019 23:19:47 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AFF2F248C9; Thu, 30 May 2019 03:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186385; bh=6LftdqdCwOE0CXY9XVp3kFa+SyP6F6qzttsv7v36EZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=huKsPXVMiemKW4g10QsrysZW49Q4Tl17KAnVS7nLb14UsEVwqsAlLb3fdHPMPHBOt AvMVoBm3gF2TSzkLZyRtyQRT64cYhOAebif5D1T6qvzhmKBXaJGxXIloyDOaryFgSt b/Jvk1fYw7HCoywLzTnG2IaiW4i0ejmAHsswW6Qo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Andy Lutomirski , Borislav Petkov , Josh Poimboeuf , Linus Torvalds , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 153/193] x86/uaccess, signal: Fix AC=1 bloat Date: Wed, 29 May 2019 20:06:47 -0700 Message-Id: <20190530030509.655232817@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 88e4718275c1bddca6f61f300688b4553dc8584b ] Occasionally GCC is less agressive with inlining and the following is observed: arch/x86/kernel/signal.o: warning: objtool: restore_sigcontext()+0x3cc: call to force_valid_ss.isra.5() with UACCESS enabled arch/x86/kernel/signal.o: warning: objtool: do_signal()+0x384: call to frame_uc_flags.isra.0() with UACCESS enabled Cure this by moving this code out of the AC=1 region, since it really isn't needed for the user access. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Andy Lutomirski Cc: Borislav Petkov Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- arch/x86/kernel/signal.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 4cdc0b27ec82f..01741834fd6a0 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -131,16 +131,6 @@ static int restore_sigcontext(struct pt_regs *regs, COPY_SEG_CPL3(cs); COPY_SEG_CPL3(ss); -#ifdef CONFIG_X86_64 - /* - * Fix up SS if needed for the benefit of old DOSEMU and - * CRIU. - */ - if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) && - user_64bit_mode(regs))) - force_valid_ss(regs); -#endif - get_user_ex(tmpflags, &sc->flags); regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); regs->orig_ax = -1; /* disable syscall checks */ @@ -149,6 +139,15 @@ static int restore_sigcontext(struct pt_regs *regs, buf = (void __user *)buf_val; } get_user_catch(err); +#ifdef CONFIG_X86_64 + /* + * Fix up SS if needed for the benefit of old DOSEMU and + * CRIU. + */ + if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) && user_64bit_mode(regs))) + force_valid_ss(regs); +#endif + err |= fpu__restore_sig(buf, IS_ENABLED(CONFIG_X86_32)); force_iret(); @@ -460,6 +459,7 @@ 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; frame = get_sigframe(&ksig->ka, regs, sizeof(struct rt_sigframe), &fp); @@ -472,9 +472,11 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig, return -EFAULT; } + uc_flags = frame_uc_flags(regs); + put_user_try { /* Create the ucontext. */ - put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags); + put_user_ex(uc_flags, &frame->uc.uc_flags); put_user_ex(0, &frame->uc.uc_link); save_altstack_ex(&frame->uc.uc_stack, regs->sp); @@ -540,6 +542,7 @@ static int x32_setup_rt_frame(struct ksignal *ksig, { #ifdef CONFIG_X86_X32_ABI struct rt_sigframe_x32 __user *frame; + unsigned long uc_flags; void __user *restorer; int err = 0; void __user *fpstate = NULL; @@ -554,9 +557,11 @@ static int x32_setup_rt_frame(struct ksignal *ksig, return -EFAULT; } + uc_flags = frame_uc_flags(regs); + put_user_try { /* Create the ucontext. */ - put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags); + put_user_ex(uc_flags, &frame->uc.uc_flags); put_user_ex(0, &frame->uc.uc_link); compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp); put_user_ex(0, &frame->uc.uc__pad0); -- 2.20.1