From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BF51EB64D8 for ; Fri, 16 Jun 2023 17:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346139AbjFPRB3 (ORCPT ); Fri, 16 Jun 2023 13:01:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343594AbjFPRAl (ORCPT ); Fri, 16 Jun 2023 13:00:41 -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 459AB295B for ; Fri, 16 Jun 2023 10:00:31 -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 CD41B626E0 for ; Fri, 16 Jun 2023 17:00:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B28EBC433CA; Fri, 16 Jun 2023 17:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686934830; bh=bBDGc7l+rp9aL56+CDe+wYli295kdN5xV+/yUxzXB2U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RoXjZJcKmF7VUovmc25dlYZ7bZupC6kQfX7pDjiQaODyhpOeGZxCiFf21vPXfAwfP 8+F5YkVnbWNFVt6sYpMarSafwIkFNaSWz0K8q01rE2tfoQ+TwBt4o5RNcK63i/Zsyj 8nXF0skvL2WB5z/6v0lBUdAx7g1OZlHRMrMsx8uIFsxmRuRA/m7/w3ylzDhgoCsHvO KzSH1LXsvvp9EVK04jY8eO+kL0O8W3sa5xnwcPCzYCu7dNZzvl7BDCrZ6dRFaNt3OV Mz2ZLS+mfc13zG/Ih5VW1mOHdZquspBxinKG9cK1y3HB+xxMtITAXuBfgtqWM82073 943N4gMUeY2Jg== Date: Fri, 16 Jun 2023 18:00:27 +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 v2 1/1] x86/mm/KASLR: Store pud_page_tramp into entry rather than page Message-ID: <20230616170027.GM3635807@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: <20230614163859.924309-2-lee@kernel.org> 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 | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) Is there any more you need from me at this point? Would you like me to resubmit with the Fixes: tag applied, or is someone happy to apply it on merge? > 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 [李琼斯]