Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15865230rwd; Mon, 26 Jun 2023 02:21:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5NIqyLJ4TS+6NWgIfPOXctNsIhwNBmUPuyF1OT7+eNMv0hyrYyVfgjABVnRrdp8E1JAxZb X-Received: by 2002:a05:6a20:244c:b0:10a:e8b1:34bb with SMTP id t12-20020a056a20244c00b0010ae8b134bbmr20448634pzc.56.1687771292301; Mon, 26 Jun 2023 02:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687771292; cv=none; d=google.com; s=arc-20160816; b=ZY/4AvIhYqDM1z1blmc59xlSqgkipd9ZNkRwIJkiS2b8EX/JgCOutjMmxMFTXWdprU DfvtXoGCD8agsiJOC7zk/8D32oybCPZY+e4yHHuBnIN2WCF9oJHzM2W7au0DxxGYnosy 5f5Fb9BtZ1Gmqhw2roxLAX25Jaq16ukZCE1buad6Xete+NdPnjfquuWvuyrUyLA6IECB +TnheTZoPifMUgZTT61gEFYn0smMkzH0ovM2EXTbf+Fu2a8ovC25nJ0n2zc6S32+r3Dn SAbrrGDVlEut2qmcMxOKNdO4s6fPDqMQ60Jx3uM5kt7SDuIjC7KfBQWrMGVcyDZzEjIX xGtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wIK2Rcep3oTD/9mM1hoRY9pxSPkxthvR7CZIRuit+wM=; fh=ZDN7NuLHT2qhHpTmXsboYWVHkSKV2S4+CVD3JjD87DE=; b=DunUVkQ64m9DaptwYiSlZn48FfdcfzXxp/upG1kHsfFLb2yfiJV0zhzTxqjNOPTvCy Zl4E6g2S90zqTzcHCDixkPwbPyef3kmXTBVGC142Z9ETSkKwPdD8VZ6sOe0MACB+S7pu FChk2kUlWsmxbfQ1oRSjUizkETLbHSVBe+1+5UoUsOcpTlJFueuDUYiW9CkKz2oJ87Gi PhZB094aTZGkUmF/EytdmyOUSUtxeD7gOnwcu+p5w5DYA88nuhafI5f2zrVcaCmHELOB HAPOVIbB6pUpXtNbgQKsGcuDEVhcRIayHKRq9EWqkTj/qpOBWtxQ2aNhtCbbQ9JR625f pT/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nfKAbQ31; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u15-20020a056a00158f00b0066009c432d2si4677406pfk.226.2023.06.26.02.21.19; Mon, 26 Jun 2023 02:21:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nfKAbQ31; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229851AbjFZJO3 (ORCPT + 99 others); Mon, 26 Jun 2023 05:14:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbjFZJNO (ORCPT ); Mon, 26 Jun 2023 05:13:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15142E1; Mon, 26 Jun 2023 02:11:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 963D160D2C; Mon, 26 Jun 2023 09:11:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62601C433C0; Mon, 26 Jun 2023 09:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687770715; bh=iLYlNZZUWYeCPAHYoPNaCrwZSkSOhiZiARtAbZAablk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nfKAbQ31xMawaI7b/PDj9Cw9hIyccjj3JE9Tll9auIp659XVpCP2/iCO6Cu+Xydte Mxl7bm+5+OpbJphkikCTk8/XOM+Ch356hqj3JdS48s1MSO6toqhfh7+wICZAGlgCHV R6I2dmYDtgN56gj4N3nZ1bE96HUBfEcroQfK3hOXTh8kF4pnz3wxEBdsv0zKifvkTg ntk4Ey0JKOliEpFxAH3T4rtyoAtXqsFYU736z/7czN25I78b7TDYTXbOtSDbTK5vAr 5ofNw01kFoMM7kN8Pxmwl0tJ2g8IKAmcRReZvP3fkDT001MrqKvJwuN6vuf0a3eaYS zrLIqIim5HPdg== Date: Mon, 26 Jun 2023 10:11:49 +0100 From: Lee Jones To: Greg KH Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-tip-commits@vger.kernel.org, Dave Hansen , x86@kernel.org Subject: Re: [tip: x86/urgent] x86/mm: Avoid using set_pgd() outside of real PGD pages Message-ID: <20230626091149.GA10378@google.com> References: <168694160067.404.13343792487331756749.tip-bot2@tip-bot2> <20230626085450.GA1344014@google.com> <2023062651-random-enjoyment-8838@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2023062651-random-enjoyment-8838@gregkh> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Jun 2023, Greg KH wrote: > On Mon, Jun 26, 2023 at 09:54:50AM +0100, Lee Jones wrote: > > Dear Stable, > > > > On Fri, 16 Jun 2023, tip-bot2 for Lee Jones wrote: > > > > > The following commit has been merged into the x86/urgent branch of tip: > > > > > > Commit-ID: d082d48737c75d2b3cc1f972b8c8674c25131534 > > > Gitweb: https://git.kernel.org/tip/d082d48737c75d2b3cc1f972b8c8674c25131534 > > > Author: Lee Jones > > > AuthorDate: Wed, 14 Jun 2023 17:38:54 +01:00 > > > Committer: Dave Hansen > > > CommitterDate: Fri, 16 Jun 2023 11:46:42 -07:00 > > > > > > x86/mm: Avoid using set_pgd() outside of real PGD pages > > > > > > KPTI keeps around two PGDs: one for userspace and another for the > > > kernel. Among other things, set_pgd() contains infrastructure to > > > ensure that updates to the kernel PGD are reflected in the user PGD > > > as well. > > > > > > One side-effect of this is that set_pgd() expects to be passed whole > > > pages. Unfortunately, init_trampoline_kaslr() passes in a single entry: > > > 'trampoline_pgd_entry'. > > > > > > When KPTI is on, set_pgd() will update 'trampoline_pgd_entry' (an > > > 8-Byte globally stored [.bss] variable) and will then proceed to > > > replicate that value into the non-existent neighboring user page > > > (located +4k away), leading to the corruption of other global [.bss] > > > stored variables. > > > > > > Fix it by directly assigning 'trampoline_pgd_entry' and avoiding > > > set_pgd(). > > > > > > [ dhansen: tweak subject and changelog ] > > > > > > Fixes: 0925dda5962e ("x86/mm/KASLR: Use only one PUD entry for real mode trampoline") > > > Suggested-by: Dave Hansen > > > Signed-off-by: Lee Jones > > > Signed-off-by: Dave Hansen > > > Cc: > > > Link: https://lore.kernel.org/all/20230614163859.924309-1-lee@kernel.org/g > > > --- > > > arch/x86/mm/kaslr.c | 8 ++++---- > > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c > > > index 557f0fe..37db264 100644 > > > --- a/arch/x86/mm/kaslr.c > > > +++ b/arch/x86/mm/kaslr.c > > > @@ -172,10 +172,10 @@ void __meminit init_trampoline_kaslr(void) > > > set_p4d(p4d_tramp, > > > __p4d(_KERNPG_TABLE | __pa(pud_page_tramp))); > > > > > > - set_pgd(&trampoline_pgd_entry, > > > - __pgd(_KERNPG_TABLE | __pa(p4d_page_tramp))); > > > + trampoline_pgd_entry = > > > + __pgd(_KERNPG_TABLE | __pa(p4d_page_tramp)); > > > } else { > > > - set_pgd(&trampoline_pgd_entry, > > > - __pgd(_KERNPG_TABLE | __pa(pud_page_tramp))); > > > + trampoline_pgd_entry = > > > + __pgd(_KERNPG_TABLE | __pa(pud_page_tramp)); > > > } > > > } > > > > Could we have this expedited please? There are users waiting for it. > > > > Upstream commit is: > > > > d082d48737c75 ("x86/mm: Avoid using set_pgd() outside of real PGD pages") > > Please look through your emails you got this weekend, it's already > queued up in the following stable trees: > queue-5.4 queue-5.10 queue-5.15 queue-6.1 queue-6.3 Haven't reached those ones yet - only 160 to go! Thank you though, very much appreciated. -- Lee Jones [李琼斯]