Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10217128ybi; Thu, 11 Jul 2019 01:38:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaAy4JuQA1uY66kbdl7BTnvh06aO/nJDq63TIvJ+bBLFvs1fwTtfgHkmwjYfXlR/C85Dj3 X-Received: by 2002:a17:90a:22aa:: with SMTP id s39mr3426616pjc.39.1562834329990; Thu, 11 Jul 2019 01:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562834329; cv=none; d=google.com; s=arc-20160816; b=zqPf09euF3/b49Imy4uUt4Zyo79+bK5wQxAersSIa6GAkEimVKNbFomyzY1UQ/cV83 0J5vC54Pk5sPHd0RGsGVgCEr3U+BJB9jOTv6LppP7uyjTh/STcINV3GsxJmQmtWW+ZY3 rokCiWNRGcLup757YINpu6JGRIFjgeo0I/YDnZCBpLjSLX32DuBt6VYJer2DhD/gMSSo Z3N3OUxOl2hZtIz/MyqwyOtUZgceqJNtTYHMM0yvbFrawP3HT1cVvByciNuK1KXj4mUH vo/bsQ3V/XxOqRpCUB3lcsdoMZwSWy7r+RYLgnIw+ZoyfRe0JQCM2wHaJd0keFZ+E6WX rLmw== 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=A03zSnTkTg2q+IeHEsoCAZqj8bLFqYpbZDWV+8dIVqY=; b=0TbAzOdZZl9DHqinbMdym/Wyf3tskN/MZ3966om+QA4xkCz1ZdLtc14MxJoPpd0cPc ljsHwkQL3oUdgJczoeXAE7s4QwWsB7UjkRexAz+n52mPvH2VSKZdjqUoRRCR/2/VUS+r zgOhWeS3FL+woTFAX8OdyDbxlbSz9mHhh1KsPH7RiZJG/Vh36gO4Q5tsQpuhbFn5Bg8l uyjhWPpIFiPuxgjf5Wik0vfCoQXkO0WrJ6y4SrMXB03jjK/aR8zDylm0XcKyLdzkZ+kT pvVABprtGVs67vVvO7IQlMrsIioG49NWQ2dx9S61xr1EjS9lv2fDOtB1jETIxP0BNJjq kvog== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Zd4NDoB9; 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 z185si4719410pfb.109.2019.07.11.01.38.33; Thu, 11 Jul 2019 01:38:49 -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=Zd4NDoB9; 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 S1728124AbfGKIBr (ORCPT + 99 others); Thu, 11 Jul 2019 04:01:47 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:56526 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727829AbfGKIBr (ORCPT ); Thu, 11 Jul 2019 04:01:47 -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=A03zSnTkTg2q+IeHEsoCAZqj8bLFqYpbZDWV+8dIVqY=; b=Zd4NDoB94ntRjV9Zzpxt1Hycy 12KpDBNlA7v9OsJOjnaZr57vvtyMwpEQJS8YBPHmKHUozGsCGEzZ9Y+D2L7pGpXScLjrareSOqy+B mGT30yGx7g5YWChXviPLPChKBJauoEcg3xAmA3H8XNGKtzJ3FCBJjccdEWXH71T+aRQgDuEDKgrP0 OgrYfxaqZGmW9PSg05LzoO6nrkH8/WTwcCQv67CtUuSGB2SX4E0qE/Or7L6ItsMwhHaDbqw9MqWDz yA6SnjDptUmVrKYV+NIk2kNSB3uroFetVweynCU+h+LsS+QeS2G9mmTdDNfH6BFMIMZlpN/3NMZLc /V8yf7+kA==; 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 1hlU1I-0000ax-Ke; Thu, 11 Jul 2019 08:01:36 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 71D3820213043; Thu, 11 Jul 2019 10:01:34 +0200 (CEST) Date: Thu, 11 Jul 2019 10:01:34 +0200 From: Peter Zijlstra To: Nadav Amit Cc: Jiri Kosina , 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 Subject: Re: [GIT PULL] x86/topology changes for v5.3 Message-ID: <20190711080134.GT3402@hirez.programming.kicks-ass.net> References: <201907091727.91CC6C72D8@keescook> <1ad2de95e694a29909801d022fe2d556df9a4bd5.camel@mengyan1223.wang> <768463eb26a2feb0fcc374fd7f9cc28b96976917.camel@mengyan1223.wang> <20190710134433.GN3402@hirez.programming.kicks-ass.net> <89EBC357-BEAC-4252-915F-E183C2D350C4@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <89EBC357-BEAC-4252-915F-E183C2D350C4@vmware.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 Thu, Jul 11, 2019 at 07:11:19AM +0000, Nadav Amit wrote: > > On Jul 10, 2019, at 7:22 AM, 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. > > Even with DEFINE_STATIC_KEY_FALSE_RO(), I presume you can just call > set_memory_rw(), make the page that holds the key writable, and then call > static_key_disable(), followed by a call to native_write_cr4(). Or call text_poke_bp() with the right set of arguments.