Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5248166imb; Thu, 7 Mar 2019 11:02:11 -0800 (PST) X-Google-Smtp-Source: APXvYqz0EuDIi6IY9hqPCOR/STbbFXfNZHP5B20SCT6270Zvm2RB7YtsL7tzcpZJ/+HPKsg5a1Qr X-Received: by 2002:a17:902:74cb:: with SMTP id f11mr14647380plt.180.1551985331654; Thu, 07 Mar 2019 11:02:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551985331; cv=none; d=google.com; s=arc-20160816; b=KwXJnsfMlYD6Xvz09958O2qNt3IN9RRMiWP13RBwOPnIKJZgO23JeNJEVElFrTcIhz vOsALb968R0Wah5832umdSuSt7vcscKiqFqpSWm19KNzaB0+jRZ4IXTutCc80w01zcl3 ukiQ8Rt5bnDW1zn2sbOpQ0Ru+Lwk9hP+aY5IWMNjgQhHFj9RVEK/iGngjq2Y2yWb0SMO xXQ+E6RW36jv5aq3IRiHciLrTHjYH6A2bJUnmqTPLJY1OoM0Odd6/rVgahM5hLTfKZOD xf8qu/Q3w6csWFEAzF2ZTC9wgWvoxogoruWyuPikIzEHGpyYZlpi3pgmOe/pZ1Yv8Q6K hFfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gGmYOEezlYoLoO0joDUV5GhkDVpNGHdbcg3KKJ8/zgw=; b=TLS5ldgNvnpT5MgC9Ev2wDSrKHqxgE2st9HqjlUhAG41Chu+/R17fNyMbRvsG7XGVC DxLY6wBLSaYO9Y/p7BygL67BKkFEkAXyB16tWe3La04WbkptxMdcM4t1AOTLZ0J6xz8x fJXoItgnxhWujj9C1GfRgo+L1DVnS0c7ryjjjt4pWPqDi++Twp+a0oWU3/UCp8ZnDWrY Qm2goec8C4nbz9PXxFB21M6KV/6xjkfsLQtnv8r9hZgQeA7NMFtSWspnAqpFnyzQ/mzu 0dWoZlFtM7NxC/I7HuHgN4qItBKDPbkK5RaveId88AjQAwdImJIDcjEleSune0WXFdMq uMJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=kpeVHztU; 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 c19si4308597pgw.516.2019.03.07.11.01.55; Thu, 07 Mar 2019 11:02:11 -0800 (PST) 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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=kpeVHztU; 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 S1726694AbfCGTAA (ORCPT + 99 others); Thu, 7 Mar 2019 14:00:00 -0500 Received: from merlin.infradead.org ([205.233.59.134]:55604 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbfCGS7s (ORCPT ); Thu, 7 Mar 2019 13:59:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gGmYOEezlYoLoO0joDUV5GhkDVpNGHdbcg3KKJ8/zgw=; b=kpeVHztUq/iGy8hyqLOKVFMM/ cTiKPOslBkaiGhUXH3WpScswCI9mxDbf7Y9sUtg7wJKfcQM3cS38XfvOdFedCJnhTUK1cD1PlglOJ g38mAhLx6wfFS9UWTDvRhZilHcSrJQyoMo8C24us5clpy2i5fin/4hAD8iDZsK9baj/YT2abrVUiO dxDy4k+MPgxaaAlKUAkGtzaGohOOjg/d2j7yL5b2lJlUvxJDyGyz/mH/j+yN8sOR135tVEasCuX09 hpU4I/uoTwuZbrvoL7kz7xvMmDQTPEALZWfDa3TrlMH7IPilY2ayrQAW9qwN1WmQqzrzjHVoTYYTn 0kCe9Sdyg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1yEo-0000g7-Bh; Thu, 07 Mar 2019 18:59:26 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 5152C9837F2; Thu, 7 Mar 2019 19:59:22 +0100 (CET) Date: Thu, 7 Mar 2019 19:59:22 +0100 From: Peter Zijlstra To: Andy Lutomirski Cc: Linus Torvalds , Thomas Gleixner , "H. Peter Anvin" , Julien Thierry , Will Deacon , Ingo Molnar , Catalin Marinas , James Morse , valentin.schneider@arm.com, Brian Gerst , Josh Poimboeuf , Andrew Lutomirski , Borislav Petkov , Denys Vlasenko , LKML , Dmitry Vyukov , Steven Rostedt Subject: Re: [PATCH 07/20] x86/uaccess: Always inline force_valid_ss() Message-ID: <20190307185922.GA2482@worktop.programming.kicks-ass.net> References: <20190307114511.870090179@infradead.org> <20190307115159.708180729@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 07, 2019 at 10:05:43AM -0800, Andy Lutomirski wrote: > On Thu, Mar 7, 2019 at 3:52 AM Peter Zijlstra wrote: > > > > arch/x86/kernel/signal.o: warning: objtool: restore_sigcontext()+0x3cc: call to force_valid_ss.isra.5() with UACCESS enabled > > > > XXX: move the callsite out of te AC=1 region instead? > > Let's move it instead. I looked at the code and it should be fine. Something like so; or did I miss something subtle? --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -132,16 +132,6 @@ static int restore_sigcontext(struct pt_ 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_ 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(); @@ -441,7 +440,7 @@ static int __setup_rt_frame(int sig, str return 0; } #else /* !CONFIG_X86_32 */ -static unsigned long frame_uc_flags(struct pt_regs *regs) +static __always_inline unsigned long frame_uc_flags(struct pt_regs *regs) { unsigned long flags; @@ -461,6 +460,7 @@ static int __setup_rt_frame(int sig, str { 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, str 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);