Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp244272ybi; Wed, 29 May 2019 20:31:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoS5djd+QfoeCDYGPS3hm6qpVACut4OiKEdGroOcPbtpcJSAHUf0eTEtSFtQfNlmCFTrOf X-Received: by 2002:a17:90a:a00b:: with SMTP id q11mr1402395pjp.108.1559187098318; Wed, 29 May 2019 20:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187098; cv=none; d=google.com; s=arc-20160816; b=zalemE+69zpyUfKB1F/OoMW+yezzhG1Q7feewKiWXQb/uiJHWdxA8a+LrlVLDbog8H BmYhSvUBfzdBtvqzlkKZBOUBoV3aFlyaZ9Vc3vJYwwYOHwAfNNO2BFn3j4ti0Il5Una9 /tr4ZwnTg16W29wXE8s7y9E+FASpWdvkdrql1LcbvsGOlt0UGQHOM7OvvERlH9ifiCfM yPx4xws+3SR0bF261EmeDn8+nCHhFcnFlaOU3K4/nfnkl/13vQlazVoHs3+gpxAKicVY zEAJUmwdHJb3/NY7LMW4wEBLIhXs3Fw14BB6n22c5X9WTAYQQIpgo1xZIQVPwTnZ/VFn J+aA== 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=xx4sHYHnmtuE8GYlqWpBplOISb1/12CINeU3QcnGDYQ=; b=A/tM67gvGmZgl490rQPeeCXQe9BRqOhAJFcoDLZK6PMqZMDi0kmV1DDrZ2dJGYlWD0 b5XTB08tvnkURVY6XQMaXOUypQyDLxQQjAvEj61d7TVGt+2s4WWwyMJ24VtYwufunQlI YiwZfCfsova4sVy1D7yvk7QXYs/1oDZLtP0kZe8qL4xi0Qpb6JUKcooXVDwj9wtWMpC4 VlTANBsk2xQY5+TM5d452UCMw05LlcXkXr0Fy2DZCQDvPAEaFDpLUqUXmhdmOLHXsS9s aed7eZl4Mo325csKf5+wEnOoVGPqPk23Esu9dSt3T7Rkek4qkefSg7elTO2hrHJcA4Pt zSwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q3GmCmTA; 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 134si1795027pga.492.2019.05.29.20.31.20; Wed, 29 May 2019 20:31:38 -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=q3GmCmTA; 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 S2387744AbfE3DaJ (ORCPT + 99 others); Wed, 29 May 2019 23:30:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:33390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731822AbfE3DVN (ORCPT ); Wed, 29 May 2019 23:21:13 -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 CDD68249BA; Thu, 30 May 2019 03:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186472; bh=e3s4UrEv6xMX5GRkiPYXSaV+FTPoCSQU4s8SkeHOC9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3GmCmTAxHhcLV1OPfLeAILfmRY6g30aDSBqL9zDOvMdwI9gcjpUugZPJfmoymQvl rve2bB64yfn5ADg+3GaZp+naE8po7kDVwICG6JfdUIjeDKpdVV4BWCyxbz8Ar8iUv3 u5DrazS8Ii7VXkcDArJxt6o95f9yfuEYBEhIolSU= 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.9 102/128] x86/uaccess, signal: Fix AC=1 bloat Date: Wed, 29 May 2019 20:07:14 -0700 Message-Id: <20190530030452.954507391@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030432.977908967@linuxfoundation.org> References: <20190530030432.977908967@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 b1a5d252d482a..ca010dfb9682b 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -129,16 +129,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 */ @@ -147,6 +137,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(); @@ -458,6 +457,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); @@ -470,9 +470,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); @@ -538,6 +540,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; @@ -552,9 +555,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