Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp250646ybi; Wed, 29 May 2019 20:39:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiMmpZsWVUvNNIDhihQ6r1DQ4bDQBs1qKfRqBIMn8JAyp2FHpk6ZN9FOS+jP75QHkN2Z5w X-Received: by 2002:a17:90a:cb10:: with SMTP id z16mr1403659pjt.81.1559187563512; Wed, 29 May 2019 20:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187563; cv=none; d=google.com; s=arc-20160816; b=TRcpKmEHpB66uOZfRLDMdDZ5R6OpgGb06mOLFzy+rc/1oMBguxTESSJuE2rclC6BCy sDIaQbXIDvmbydaCcaKG8dPoSffBUorUROF0IdEcLEUHMYzHn/o7uFOSIeJ5mexC/I3W 8z5LLjxMY89EIl7VcXWYDj2SBMH8yjBug3m2Tp6pnZWIf0TN07lh+hwz4b2VzdKj1/5a 1QjweRkx1uOlFCaJKBQiR8FFlnM5I7SpUnBvCGPe9bwdzUvXSdqYJe5HZuDIyC+IIrp6 fIEqi/RUaVRulW19ZaR4Jnst9JsjYcs4ALCOSJasio2HpXcokez+kmP986YI55M0qZKh QEow== 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=7rt0xL05wZXmTjacOzJJlC5LVbyPaev9/Ob6Wtu44aw=; b=xux0wWdu+yMDflg1eADhS/h7YENK4B+Z6c3KSXZDbyNIY3zQfE/FAXP6QeSwdZqWUO JcKje8PFHJJiK4l4H4vnx/NcUBI1+x3vpDu19Z268UB90Tmns/uO5Y2Errxhm+n+zUoJ IBfTvjAnFZ2C1pBr4dPs+YxIrFERsS2gPrNQTHUhKaBIAmjm35wR+opcr8KClREjTsYx lhiDyCwZvkTYfzOmnA24PvOdzlBofJ84CeFnxCmkLpBwgNvI8OKwQdw2anxIiLEVk/gz xXUPVy8GIQIHRfEsvAnhZSLswphGsSN51WunSbas1ZVUtsyomTS7D2Yaf+opfwJzEvTT B5hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tqiETaho; 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 90si1885409pld.231.2019.05.29.20.39.07; Wed, 29 May 2019 20:39:23 -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=tqiETaho; 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 S1732169AbfE3DYP (ORCPT + 99 others); Wed, 29 May 2019 23:24:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:48756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731266AbfE3DRu (ORCPT ); Wed, 29 May 2019 23:17:50 -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 343CB246A8; Thu, 30 May 2019 03:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186269; bh=YiRpyNlzCzcEpWtS4gydfZ8A3XMZuET072msQe/H26k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tqiETahoJ7EKM9Xy7WxchgSOYVudwACG2D8UWsnC45xKLJXUMgTu6UE+xrC5tFXt7 ViPf39ac55tWM4jVSaXh6rCOfycVUkD235fpOI3fuxCX0vWGOUuqEfB4V05lfAWbPl wzWilGVPdhrc/TP8rdGseMGaMuxOnqisi8w/Ifas= 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.19 207/276] x86/uaccess, signal: Fix AC=1 bloat Date: Wed, 29 May 2019 20:06:05 -0700 Message-Id: <20190530030538.076039362@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@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 92a3b312a53c4..44e647a65de88 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -132,16 +132,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 */ @@ -150,6 +140,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(); @@ -461,6 +460,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); @@ -473,9 +473,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); @@ -541,6 +543,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; @@ -555,9 +558,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