Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9270064ybi; Wed, 10 Jul 2019 07:29:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqztYxfP2RZI+W7uDFBlkrTB3Kso0L1YLzCCP7wWh9hmdl8BRjyReuNpv6zcoEQrQ9c5s+ZO X-Received: by 2002:a63:f510:: with SMTP id w16mr38192613pgh.0.1562768967678; Wed, 10 Jul 2019 07:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562768967; cv=none; d=google.com; s=arc-20160816; b=ZgjS2PC3MyjXcCecxWrKZg/fhJv5fgbV9kR8s83AZBoGfnl68aSwZVpb2J9VJDRWIC LaLmq+RT4IqWqXmvlax5Tnr4ssmW3tBygwH9RmMIFhDXXEMEVvuxyGFLvEtxo2Sq8CzV Qs/jZF+dQqtlrwvS5ble7dZFyWbm7AVTkgFvOUkzQlVuccesH6VXvPJMHCGThCWn3foL A27nIwe+6weHhyx8SBXEFteZtIQTVBAYvtxoJdJ+G5CYdXflniwscHgYxGYrr6fh+2OH Er59hhliZkoiYFdyyU4F+OnLqYmjZxKw92r9z/sMXey9WIWGvrtLPWIhW08AMt5wSr0U 9mtw== 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=RlXhAkaMUAdGOUFAYrqz8nfH2erzY8x7rCdtY4iPiGs=; b=oh5VXf6HY2ipx8tfDLvWHwqG4VvzypQiTx4cWs8QRvr9hB5OZCc39WcdFhHiC40kX+ IoZ28iA4M1ikiWkDG42PnV1hlDL/RvP54K9AGvskmBZxFJ7LrKD29SDMaaKYAfFp9v/b nx15+hv4Kgta3ruJ/uGIM4qvMWI7PrQ9quPARQxVS2Lx5fsor3admQ9V6uIA89XZsmCh b1XRQC9LIEC+h5/p6hgop15M2Ks0Olmzf+1mfmUYCTyHVANlgfztEua+WsZryMXWnMOf M+anzsjYotdvBVOqQmXl8Mu7sw3LozNps7SwAKZbpEs+0GrSO1hJ5L5EDYJxhk3SYTEA Uj7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PdeAjWx0; 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 h5si2391489pls.280.2019.07.10.07.29.11; Wed, 10 Jul 2019 07:29:27 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PdeAjWx0; 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 S1727903AbfGJO1F (ORCPT + 99 others); Wed, 10 Jul 2019 10:27:05 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41440 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727154AbfGJO1E (ORCPT ); Wed, 10 Jul 2019 10:27:04 -0400 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=RlXhAkaMUAdGOUFAYrqz8nfH2erzY8x7rCdtY4iPiGs=; b=PdeAjWx0z/Z2HRIX9fIQXsgSp 0FfZL97fOFsyolzkLrlxkK7Hxm9I8/Z1HSpUzXgjpAs8V8w75sCFYrQ1/Y0tqjoYfe7YAKeQRkjT+ dT+CCglesn8W5g8qdGMO7mIAnQXhOjFVB1iJgM5lcfe7HME0xGegljFhFUIl6Xtxq8Dr/HFGubLiM Qng0pLVJNE0Q/3ojwNvwNecgCzz7xqfdWiEt8E8gsGSJy/e7KQRN5XdsVYanqtdAs3D7P5suYUZxi Lw4fV3U4FNSLzMB+97/QTFtVh5TL1qniaKDKzDrAOWg0ECTGP4CBKG+53ZPXsiWlkMr1QgFR8Lll0 lskCi+l+A==; 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.92 #3 (Red Hat Linux)) id 1hlDYd-0006FG-0I; Wed, 10 Jul 2019 14:26:57 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 47DA220977440; Wed, 10 Jul 2019 16:26:53 +0200 (CEST) Date: Wed, 10 Jul 2019 16:26:53 +0200 From: Peter Zijlstra To: Jiri Kosina Cc: Xi Ruoyao , Thomas Gleixner , Kees Cook , Linus Torvalds , Ingo Molnar , Linux List Kernel Mailing , Borislav Petkov , Len Brown , Andrew Morton , "Rafael J. Wysocki" , Tony Luck , Bob Moore , Erik Schmauss , Josh Poimboeuf , Daniel Bristot de Oliveira , Nadav Amit Subject: Re: [GIT PULL] x86/topology changes for v5.3 Message-ID: <20190710142653.GJ3419@hirez.programming.kicks-ass.net> References: <201907091727.91CC6C72D8@keescook> <1ad2de95e694a29909801d022fe2d556df9a4bd5.camel@mengyan1223.wang> <768463eb26a2feb0fcc374fd7f9cc28b96976917.camel@mengyan1223.wang> <20190710134433.GN3402@hirez.programming.kicks-ass.net> 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 Wed, Jul 10, 2019 at 04:22:51PM +0200, Jiri Kosina wrote: > On Wed, 10 Jul 2019, Peter Zijlstra wrote: > > > If we mark the key as RO after init, and then try and modify the key to > > link module usage sites, things might go bang as described. > > > > Thanks! > > > > > > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c > > index 27d7864e7252..5bf7a8354da2 100644 > > --- a/arch/x86/kernel/cpu/common.c > > +++ b/arch/x86/kernel/cpu/common.c > > @@ -366,7 +366,7 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c) > > cr4_clear_bits(X86_CR4_UMIP); > > } > > > > -DEFINE_STATIC_KEY_FALSE_RO(cr_pinning); > > +DEFINE_STATIC_KEY_FALSE(cr_pinning); > > Good catch, I guess that is going to fix it. > > At the same time though, it sort of destroys the original intent of Kees' > patch, right? The exploits will just have to call static_key_disable() > prior to calling native_write_cr4() again, and the protection is gone. This is fixable by moving native_write_cr*() out-of-line, such that they never end up in a module.