Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp44722rwd; Wed, 14 Jun 2023 12:00:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6XMY0USMPNfkd6HeDNog6Q4Q/S1hjW847DBpSZQefYn6r0glA75HWl5irhb1jntqXa43BT X-Received: by 2002:a05:6a21:9984:b0:10c:c9ac:14c6 with SMTP id ve4-20020a056a21998400b0010cc9ac14c6mr2572153pzb.39.1686769224000; Wed, 14 Jun 2023 12:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686769223; cv=none; d=google.com; s=arc-20160816; b=mSnTOoEE/a5dsWfjKIBi4TDLrssRmu0YkZ7mOVTOiPl92Sg5/yDpA0Vt5ZVh0RP1CA pUChPKCTIZicD5ietwM91oiJguBT5CEjuEfxrKRBhrj8PYErfjFRybFfS1iqQlL73kOs +uPCNMpk1+Md2kyScyhaZ0CbARKozQ8JfKrzhhmwdWA2lO9vVkarbxrDvxwSO5/dydeQ +Nl6njCV4CTvgelx+xxleHSlIQT+wdHL6ef9DUrAyl1ogOW8ZNApcTypCi/GOrQG2Ah6 w+7/X4EsIhRWdaQYIBoVmTiwtuB3XKHPrTaNaWBguSrqqLUzE1khobcwmTc0L2Z3NLDD JZGg== 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=iAuaqMnCoaB3YmySrzfcGlXO3jvrdx/sMIvUMKJ1WtU=; b=qIWwuhpVohQ2a/RRnMy7a4bhRLMMuHU85OBIliY+i9rOotiD7n06n00pZHa6f4Rsh1 ZOwQr0EFZADkPDPSlQUBn2r0gODLUnFf/ZlQE8FsR+CBGSExYKXUa9Mkv6lCp4T4i22E lSq18bU52uGhjsDbBKHEIafkfaGM+nLPz4VDFWmneoBqUBS+vapxB46Scf2fHGK2JwQj 9XDeENRdS0Nbwn/xMqhH937CC1eId1AlQMLi0Xpw2jCLmgxBAnkC/RT4VbQ0ZjpOFEPa SCmSwgQvJY63OwiZGTr8ygBSIG1zTF0LW14RKIrSiiLHkCkGGIro6CSlERGufoQdQl5t NKGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZiRPIZzE; 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 b20-20020a637154000000b0053ef09db573si7820497pgn.247.2023.06.14.11.59.29; Wed, 14 Jun 2023 12:00:23 -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=ZiRPIZzE; 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 S233114AbjFNSoD (ORCPT + 99 others); Wed, 14 Jun 2023 14:44:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231225AbjFNSnw (ORCPT ); Wed, 14 Jun 2023 14:43:52 -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 B88F7212C for ; Wed, 14 Jun 2023 11:43:48 -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 4829063FA9 for ; Wed, 14 Jun 2023 18:43:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14270C433C8; Wed, 14 Jun 2023 18:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686768227; bh=NIXlB9+2WkBQ/E/Qxn+H6VTpQkwCpTesI9A9vvN9CeE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZiRPIZzEq2FBbYrmRtsGLLdeSFFu9b8Q2J8fTocoPtIuJCnofrg1Bec5Yp2PbYOVp l/NO9PSsw60vOuWoKwlOJB4/NPA4/O9PYBMZXskmIOZ/65qF80usL6zzYvox32T6tF +v0gTMY9g9PgFXipLQ8f8Zo4l8B6QAkmclqRu3PMwMQG8rHyuZDvJ6w+gsToVoDMK7 AW9naZnVLIKx5dXQ28ot6P3H5Q+Q1/H0pKlQ9KWr5nH7adquqZ54HGh+0NXrKfs5U3 OdvGZfwKz6jDYoV4MOFpRXv63LJs/Rp5zjJ40kIBSb6v/f016GGtDZG/N5SZ3ymDQU c6z9G9ehSeqWA== Date: Wed, 14 Jun 2023 19:43:41 +0100 From: Lee Jones To: Nick Desaulniers Cc: dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/1] x86/mm/KASLR: Store pud_page_tramp into entry rather than page Message-ID: <20230614184341.GC3635807@google.com> References: <20230614163859.924309-1-lee@kernel.org> <20230614163859.924309-2-lee@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Wed, 14 Jun 2023, Nick Desaulniers wrote: > On Wed, Jun 14, 2023 at 05:38:54PM +0100, Lee Jones wrote: > > set_pgd() expects to be passed whole pages to operate on, whereas > > trampoline_pgd_entry is, as the name suggests, an entry. The > > ramifications for using set_pgd() here are that the following thread of > > execution will not only place the suggested value into the > > trampoline_pgd_entry (8-Byte globally stored [.bss]) variable, PTI will > > also attempt to replicate that value into the non-existent neighboring > > user page (located +4k away), leading to the corruption of other global > > [.bss] stored variables. > > > > Suggested-by: Dave Hansen > > Signed-off-by: Lee Jones > > Nice work tracking this one down! > > Fixes: 0925dda5962e ("x86/mm/KASLR: Use only one PUD entry for real mode trampoline") > Cc: I was planning on backporting this myself once it hits Mainline. Happy to submit a RESEND with those pieces added if required though. Or perhaps someone would be kind enough to add them on merge? > > --- > > 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 557f0fe25dff4..37db264866b64 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)); > > } > > } > > -- > > 2.41.0.162.gfafddb0af9-goog > > -- Lee Jones [李琼斯]