Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1038776rwl; Wed, 5 Apr 2023 10:56:13 -0700 (PDT) X-Google-Smtp-Source: AKy350YCQiQiLPEsn490LekW5KW6Vv4uz7n4p+AGXOSjb65M4hvSkyInHHos2tYZTdt0jKMxEPO8 X-Received: by 2002:a17:906:82c3:b0:92f:7c42:8637 with SMTP id a3-20020a17090682c300b0092f7c428637mr4084239ejy.30.1680717373216; Wed, 05 Apr 2023 10:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680717373; cv=none; d=google.com; s=arc-20160816; b=oYM9SsmeMCqpPoiENWM5YccdozZshdJp1oRB/HSvlp7uAi73r5uvjU/RIA52TiJiE1 S36mtVdaOj8fkQsXvKX2Ro24KZnmKlhVbdux3QRMnHfXpnAbFVwN8gq0N3YUXt0rYuX3 2U5mzxP6luexkJ/xImEVa1/Wwu1nwmF+WwDJcJv0ZfLY3zM11H0ycDn1rmrAKo91dqUd xrKjCz8R6IKjxzDDyIK3ITYkBJMX1Y4mttTPseBdOOmY9LZTd4DsKnZkk+kP+CxtBhjC GKQDWKK3KMiA4yqkan4+emoJ3c/JrFUHg8GwgTl3b7BA9PbPapgj0DYyeAkpvevvD9KU Zu8A== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=33UG1WS3gw1CuOwXuYioeLNLGEVKHwH+Ir//ss8v/CY=; b=UDZ00sv5WBVOFwETcfPj1fl/I9cKCeTZyKnd8/eUo4bgEimZI1DkASxP24IlmboSdW nrao71uABn2WkrAU8ijIcSm8J4VShSVzpZF9ufdsMMJk+bH4NOjSK+Bu2FwztJhh9gOr VopvLYk8yKXKKl+3hyuS11l7zjQpyQohOMXBvrHCT42Mx1syeD8/sPG3uCA/dYOQq5px JHAcUT+SARXet7iE3xKIgOzBnaOUUc8kjoN+VtkIWTaLiylwqXippsEiDQR98hrVV7Xr zeklNiu4MmzMfiG3KuooEW78wsm3UWl6IWjbVwe2oRVwXtkXTvU218Ba3TeA4eFQ5mSc 63zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=kypMIPHY; 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=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc37-20020a1709078a2500b00947d54e4c1fsi1610575ejc.88.2023.04.05.10.55.48; Wed, 05 Apr 2023 10:56:13 -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=@alien8.de header.s=dkim header.b=kypMIPHY; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233724AbjDERzc (ORCPT + 99 others); Wed, 5 Apr 2023 13:55:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233563AbjDERz1 (ORCPT ); Wed, 5 Apr 2023 13:55:27 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE19576B8; Wed, 5 Apr 2023 10:55:08 -0700 (PDT) Received: from zn.tnic (p5de8e687.dip0.t-ipconnect.de [93.232.230.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 691C11EC0104; Wed, 5 Apr 2023 19:54:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1680717286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=33UG1WS3gw1CuOwXuYioeLNLGEVKHwH+Ir//ss8v/CY=; b=kypMIPHYDCdQPSLxPrRaxaco3D2GpUwVKRif07IXGNx/UR8guiLAXIk006ChkN1t91Ksz3 6kwgvVhIuKPvVY8bMXe6awdZ06Z/0LZuFbgK1dHjW+GaPbAypxnHB4u1ZfwglmodbV3WVh H0BlnRsRWe7UtmPI0Fxs+zAeL9/coAk= Date: Wed, 5 Apr 2023 19:54:41 +0200 From: Borislav Petkov To: Evgeniy Baskov Cc: Ard Biesheuvel , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , Peter Jones , Gerd Hoffmann , "Limonciello, Mario" , joeyli , lvc-project@linuxtesting.org, x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v5 03/27] x86/boot: Set cr0 to known state in trampoline Message-ID: <20230405175441.GFZC214WxyhULbtl3P@fat_crate.local> References: <63368ff665956a64f07aee9bc863b70c86b8b0c8.1678785672.git.baskov@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <63368ff665956a64f07aee9bc863b70c86b8b0c8.1678785672.git.baskov@ispras.ru> X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Tue, Mar 14, 2023 at 01:13:30PM +0300, Evgeniy Baskov wrote: > Ensure WP bit to be set to prevent boot code from writing to > non-writable memory pages. > > Tested-by: Mario Limonciello > Signed-off-by: Evgeniy Baskov > --- > arch/x86/boot/compressed/head_64.S | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S > index 03c4328a88cb..01fa42d31648 100644 > --- a/arch/x86/boot/compressed/head_64.S > +++ b/arch/x86/boot/compressed/head_64.S > @@ -660,9 +660,8 @@ SYM_CODE_START(trampoline_32bit_src) > pushl $__KERNEL_CS > pushl %eax > > - /* Enable paging again. */ > - movl %cr0, %eax > - btsl $X86_CR0_PG_BIT, %eax > + /* Enable paging and set CR0 to known state (this also sets WP flag) */ > + movl $CR0_STATE, %eax This sets a lot more than WP. Why? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette