Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1023350imu; Tue, 20 Nov 2018 10:22:20 -0800 (PST) X-Google-Smtp-Source: AJdET5e/foGGkeTfLXu5cGlh5+z2z6Pa/OPmWcZN5AaaB4XIp8VrJpjQKlMY9YOwBhhd31lgLxxC X-Received: by 2002:a62:1447:: with SMTP id 68mr3220257pfu.257.1542738140754; Tue, 20 Nov 2018 10:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542738140; cv=none; d=google.com; s=arc-20160816; b=DtTlcsm7Fq/hE6802d+7MtK30Yt8398IAlmQCb7CUWKGk0OWsxYLg39I4StmWqjz6J VdYPW2s7Mh/CSaxArANMdvC4ldloEoh8u+y8LwB20XzUoHaqOMKMzSx7EuXaH980/HjT nCDeUMgLsCGeLyEnA/MYH1ne/6BKk33nHF9/QDtWSi2u/M1b6OXglc8cJyyPg+fsSRsY 53jhkdo2jKzCfc7ed1TpIZY6oCcS5G0CeASjpMIS3QcePTZxR84/0aYTSClDmo77607N 7tLE0dEqxH6hQ3BCsP9zezZnrMpTLX1IavB/p7HbJBw8rMg/BR0A2injznXfPUq87ygN IyHQ== 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=yYG2/dt+yey+HN1j3OMMn3FS9wio/UPftluKiMcmkbE=; b=n/YEoN7IQxSg9OqbA2OQhUnQSFGJY0HikUgsAaQAyfXRtTE1hwCaTA28POng/yzstp b+Z4vvDGdmKvIwLtXBQG7BZyzTf8Uz0jBJkYCTZbEBkG+aKe6ioun1bzvDVuyZaDzu+l vplJ9tXCEC30Q3ACMTfH77uSVfwFsHo0lWK/RGeDChNWGHjfZJysinmRV45cHg3lP0Ta aTURK0GiQDjCXelRfi+griwPnaseZb7nkCn0NVGBVNG6cDqUjplOBbSNQNmIKtb1hHW5 x2+I1MGIt30K2esyoOMYbB5bUTEjPd/TWfOTXOEzJV1ZflRca/6rvhhbQZvI7vACHaWu mLSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PBpq6Tmu; 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 f32-v6si21511360plf.65.2018.11.20.10.21.45; Tue, 20 Nov 2018 10:22:20 -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=bombadil.20170209 header.b=PBpq6Tmu; 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 S1727016AbeKUEvb (ORCPT + 99 others); Tue, 20 Nov 2018 23:51:31 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:43196 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726294AbeKUEvb (ORCPT ); Tue, 20 Nov 2018 23:51:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=yYG2/dt+yey+HN1j3OMMn3FS9wio/UPftluKiMcmkbE=; b=PBpq6TmuNJc4PQ/ATCAFj5CcS NHZ/sRhge+W/70n4H2YTH99T3Qlcm9pDkw32baZPmshbIs/en1xdf20fl5L2Yi6qLuuyQYko/sCxD fOf0d0tx/d4AcnweInnYHIshtYYsDnMSErg5GqxYJFIiCbCKId/tkPC+n9Us6cXbSlUqFtOEbmPVr JwlR01j1d4JhC5mL9dBR0CB+TtdmlorPP+WTZXjSz1QgMBK+7aSK6qyXyOXvJ0vQxekm94IcGqg3z 0u3g6FNGsW/3MfXhh8JLCWLQ5t5UnecTAV6u/Mzt4VfCRe6w3pe1TC+Z5HTLgIH0IzdDdHcBiEo0T IRj6+ISsQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPAbg-0000KW-Pq; Tue, 20 Nov 2018 18:18:41 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 55DFD2029FD58; Tue, 20 Nov 2018 19:18:30 +0100 (CET) Date: Tue, 20 Nov 2018 19:18:30 +0100 From: Peter Zijlstra To: "H. Peter Anvin" Cc: Nadav Amit , Ingo Molnar , linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Borislav Petkov , Dave Hansen , linux_dti@icloud.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Andy Lutomirski , Kees Cook , Dave Hansen , Masami Hiramatsu Subject: Re: [PATCH v5 02/10] x86/jump_label: Use text_poke_early() during early init Message-ID: <20181120181830.GB2131@hirez.programming.kicks-ass.net> References: <20181113130730.44844-1-namit@vmware.com> <20181113130730.44844-3-namit@vmware.com> <76c41854-b12d-5c4e-cfa4-f448e102860b@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <76c41854-b12d-5c4e-cfa4-f448e102860b@zytor.com> 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 Tue, Nov 20, 2018 at 10:10:14AM -0800, H. Peter Anvin wrote: > On 11/13/18 5:07 AM, Nadav Amit wrote: > > There is no apparent reason not to use text_poke_early() while we are > > during early-init and we do not patch code that might be on the stack > > (i.e., we'll return to the middle of the patched code). This appears to > > be the case of jump-labels, so do so. > > > > This is required for the next patches that would set a temporary mm for > > patching, which is initialized after some static-keys are > > enabled/disabled. > > > > Cc: Andy Lutomirski > > Cc: Kees Cook > > Cc: Dave Hansen > > Cc: Masami Hiramatsu > > Co-Developed-by: Peter Zijlstra > > Signed-off-by: Nadav Amit > > --- > > arch/x86/kernel/jump_label.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c > > index aac0c1f7e354..ed5fe274a7d8 100644 > > --- a/arch/x86/kernel/jump_label.c > > +++ b/arch/x86/kernel/jump_label.c > > @@ -52,7 +52,12 @@ static void __ref __jump_label_transform(struct jump_entry *entry, > > jmp.offset = jump_entry_target(entry) - > > (jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); > > > > - if (early_boot_irqs_disabled) > > + /* > > + * As long as we're UP and not yet marked RO, we can use > > + * text_poke_early; SYSTEM_BOOTING guarantees both, as we switch to > > + * SYSTEM_SCHEDULING before going either. > > + */ > > + if (system_state == SYSTEM_BOOTING) > > poker = text_poke_early; > > > > if (type == JUMP_LABEL_JMP) { > > > > Can't we make this test in text_poke() directly, please? He does that in 9/10 iirc.