Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2998103rwd; Wed, 14 Jun 2023 09:50:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7bjoXuB+VLWvfKj6gr2DHvH94jmnKiZjIOWY/aaPKfJILNIfsqorTscwk1w+2Ec8qBDoMT X-Received: by 2002:a05:6a20:a586:b0:111:997d:d215 with SMTP id bc6-20020a056a20a58600b00111997dd215mr2376479pzb.8.1686761434945; Wed, 14 Jun 2023 09:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686761434; cv=none; d=google.com; s=arc-20160816; b=rBWY27u+oO1X83t31NN/DDFOwIOuV6uDgHMHHps21yu4fIuFpokIKAMqP7v1voim2Y jDGV4iRm92yvzEDs6v4sjlbX2D52mW6XJMAr+bX45NLrHdVHZQmckM0zeiVT6d2pKFIQ w7mx6srTqWeHTvTx8S9DW9Jn6V11gCFHHdc7hkXusWv1ZHt6IPX26e5mpCMr+4xZHcvM COq3NQoMZswp34Lmkfu8JXXa6lBQa+GwGondbhR3pp2BaUfv354lHClu/Kb2KGtHeYxD XEZ3T/CZy4BaUiaxprS20Z4R8ylPxUDCO2RJuVdNZJx5FlBU8qvIBbjbDIAOabfdVcN+ qwZw== 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=Cex6EvixN2V666t5YewIJvSSGhYQ+eBybs+tFsSL2No=; b=vCNNSNV5PSNKZcf6vmvh4lIRiVTETUHrwY7ZeUnhMR7LanoE4Gx4avLfN/JDs98iU5 waLD1FTEz15JFwKhpsRLjL06dzLxu788OzHphRwJVB911uXIIgXF+/NS7Q16S/ZQeuXF dsivHUce2fFWKm1Vb+zYWpSxwHzM+rl3PcUOVEn0AM6m2+5NYkRprpYjqt6WmBvDUwDV nnG7/NKH+Ib5XpHEtvs7WgXE4QuHIM9cJj0nuCmOQbNc4Wy4cODim5rIaHRBxrcOfIbF iYENhY5U9eDz090K/cXAOaGJuLA9ccvzQLzt+LJQQUmLLEPt5mZ07nClYfkY9bsPc35R EMnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MhOQgO8G; 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 z11-20020a6552cb000000b00534913a5303si11504251pgp.540.2023.06.14.09.50.15; Wed, 14 Jun 2023 09:50:34 -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=MhOQgO8G; 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 S233885AbjFNQbG (ORCPT + 99 others); Wed, 14 Jun 2023 12:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234327AbjFNQa7 (ORCPT ); Wed, 14 Jun 2023 12:30:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D8342718 for ; Wed, 14 Jun 2023 09:30:41 -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 9DC2064478 for ; Wed, 14 Jun 2023 16:30:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7ED2C433C0; Wed, 14 Jun 2023 16:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686760240; bh=BTRpdtoeEYlLDtLE5Hz7bt0AbC5snDe5AP82plYvJB4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MhOQgO8G7rjuCicC7gc96DgmWWy5WmsW0DPUJAHvRFytzAflm2xm/wTrFaJiKc5QR /ucL6nOYDR+QO7DpHsmcygaAaASqwz4lC+0uQAU9ylqrB88mAOD5mU4HW6+5RR3/Sq BuevYHU8Rhd44fxypacea7cRdKgB0oXwbZj4qRbBBSX4+jR98pCfiebWP5P6RRR3ui 7woSZEChE9xIRJI8rJnXknXln3W0PtKEfujbIholja0O0vCXlrQ/P+P+8mDcpkxFwv 8+DnTNZ9DkBBzZh3WDvIA3fJusUpTF9on5k+Lk2ZZIRyZzq8xkxfXood8rIvnNFhfp Rb0bOAtfaV5gQ== Date: Wed, 14 Jun 2023 17:30:34 +0100 From: Lee Jones To: 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 Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] x86/mm/KASLR: Store pud_page_tramp into entry rather than page Message-ID: <20230614163034.GB3635807@google.com> References: <20230614155223.905222-1-lee@kernel.org> <20230614155223.905222-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: <20230614155223.905222-2-lee@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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, 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 > --- > arch/x86/mm/kaslr.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c > index 557f0fe25dff4..ee6f22f3385b6 100644 > --- a/arch/x86/mm/kaslr.c > +++ b/arch/x86/mm/kaslr.c > @@ -175,7 +175,7 @@ void __meminit init_trampoline_kaslr(void) > set_pgd(&trampoline_pgd_entry, > __pgd(_KERNPG_TABLE | __pa(p4d_page_tramp))); This needs converting too. v2 in test. > } else { > - set_pgd(&trampoline_pgd_entry, > - __pgd(_KERNPG_TABLE | __pa(pud_page_tramp))); > + trampoline_pgd_entry = > + __pgd(_KERNPG_TABLE | __pa(pud_page_tramp)); > } > } -- Lee Jones [李琼斯]