Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1990617rwb; Sat, 24 Sep 2022 00:35:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41jFBVXChgwmXx50bGP+1IxHMTZ0opWJMPYIYgykzBQElPzcLJ5mpyrkj9jszfc63Njkgg X-Received: by 2002:a17:907:2722:b0:77e:d84d:9e09 with SMTP id d2-20020a170907272200b0077ed84d9e09mr10225482ejl.679.1664004949239; Sat, 24 Sep 2022 00:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664004949; cv=none; d=google.com; s=arc-20160816; b=vB3o5CbMHKuC75ylIC6An2Eey4y8MuHtPohisOeVAi4TtfRuCXyyzPgu/wiS8PrtUf Awwd5iwu34Dwy5mQ6JThpM34qbxw/bFHf/ZamaZABkdFeM8TzsDFl/mzO7UW8m9AD82c zqPSGDRGYRJvSFruglXhX5T+eYlCNzt1rST629FMf792H/GvlnMN8JehEZBJyKUFRwrd osehmtg41kCLNP1yLoSYeEnrQpbWAw/ussPUmossS27VQxKEmMJyfGjIdBNVQPrP6qVE dIZTNMavBTECFR8CEItjsQO541y7/gomJN0mn1xAzAc+5Cb400ZKUkFwRGeK4dEh0FKh 6Yxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jKyO2bx1wmwkYKutmdmRyjuwCiuqEpbbqKUT8awjQG8=; b=UPhtPGWn667EFupZbYDQU+wY3A7Z8vKWLf744VaENACtO1L6IdFBEpGKd2YOBNBlOx PekM/cTmSZ71qFU0kya8P5fPw4G3Si99Rp9gA0IbivEqKsOzP/msXKtuqvpB7KuFCPuS u3f6RCb3RDT5PFj25HrSiNsdIHK+buIYPjximb7M6HODNUgLPMrThmMAmcAXmXRt0xB9 g66YHgtKdGBMpBb52ddClzQeCFGAfZGoFGO5q8Si4r5gNg3N6lBG5eDVqUrxhYmnAKwT gvCGyUE8JYWYkzc6h6v9LixXAuU5AD7aVFnhTFFOS/fdH1WB3q93Q+UsVRgP0jBLlDub RGzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cxu6aV2F; 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 ds10-20020a0564021cca00b00456964d3369si3193212edb.230.2022.09.24.00.35.24; Sat, 24 Sep 2022 00:35:49 -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=cxu6aV2F; 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 S233464AbiIXH2O (ORCPT + 99 others); Sat, 24 Sep 2022 03:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233446AbiIXH13 (ORCPT ); Sat, 24 Sep 2022 03:27:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C36EF38A10; Sat, 24 Sep 2022 00:27:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9F56460DB7; Sat, 24 Sep 2022 07:27:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04310C4347C; Sat, 24 Sep 2022 07:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664004422; bh=tt0jOXg97xVp5NYM4iKyzC9fLT2QSJBCxqt4QUSnBRs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cxu6aV2FnfOTOBFphC5ZhTe811lcPISTQ/85BkdTyf9dCqLA1+JcDRKlXOn5zqjUg cAjuCr1vgSxUem3m1D2lyUjJtIyrYez9+GmdnMeKewSy1i9ElB3HwHQ/TNApi1FYRA 4dEQVoLmkxIAHOJDpemMDIjjVj+z8STIXyQ3iKxTjw+VmkLKNPAfCY0o7A9UWt6Usu gWrT+6C5BYxyIgzTzcWNC/w914r2HINcoQmuBsD2JJH3g2bXyvqeImxbJc7M0osTWN 7FcS99mWTDdzh5vMgqu9cYt8i+mSgSOftq5xL8vK2aRlDwjHptSKG2fPMUtqWrnm8f yLEWtrRy/1z4w== Received: by mail-lj1-f181.google.com with SMTP id j24so2267003lja.4; Sat, 24 Sep 2022 00:27:01 -0700 (PDT) X-Gm-Message-State: ACrzQf15tQKyWMWEmzEzThxqMycTChdGnMOI2Fc+gqS+UEW8wz5nRwOB WvNlw4z0PKjy5sDK5e2KlUIffGiJKfbOVlbZ5ww= X-Received: by 2002:a2e:8349:0:b0:26c:4311:9b84 with SMTP id l9-20020a2e8349000000b0026c43119b84mr4410587ljh.152.1664004419937; Sat, 24 Sep 2022 00:26:59 -0700 (PDT) MIME-Version: 1.0 References: <20220923221730.1860518-1-dave.hansen@linux.intel.com> In-Reply-To: <20220923221730.1860518-1-dave.hansen@linux.intel.com> From: Ard Biesheuvel Date: Sat, 24 Sep 2022 09:26:48 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/mm: Disable W^X detection and enforcement on 32-bit To: Dave Hansen Cc: linux-kernel@vger.kernel.org, Guenter Roeck , Darren Hart , Andy Shevchenko , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, linux-efi@vger.kernel.org, "H. Peter Anvin" , Kees Cook Content-Type: text/plain; charset="UTF-8" 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 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 Sat, 24 Sept 2022 at 00:17, Dave Hansen wrote: > > The 32-bit code is in a weird spot. Some 32-bit builds (non-PAE) do not > even have NX support. Even PAE builds that support NX have to contend > with things like EFI data and code mixed in the same pages where W+X > is unavoidable. > > The folks still running X86_32=y kernels are unlikely to care much about > NX. That combined with the fundamental inability fix _all_ of the W+X > things means this code had little value on X86_32=y. Disable the checks. > > Reported-by: Guenter Roeck > Signed-off-by: Dave Hansen > Cc: Ard Biesheuvel > Cc: Darren Hart > Cc: Andy Shevchenko > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: x86@kernel.org > Cc: linux-efi@vger.kernel.org > Cc: "H. Peter Anvin" > Cc: Kees Cook > Link: https://lore.kernel.org/all/CAMj1kXHcF_iK_g0OZSkSv56Wmr=eQGQwNstcNjLEfS=mm7a06w@mail.gmail.com/ Acked-by: Ard Biesheuvel > --- > arch/x86/mm/pat/set_memory.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c > index 20b1e24baa85..efe882c753ca 100644 > --- a/arch/x86/mm/pat/set_memory.c > +++ b/arch/x86/mm/pat/set_memory.c > @@ -587,6 +587,14 @@ static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long star > { > unsigned long end; > > + /* > + * 32-bit has some unfixable W+X issues, like EFI code > + * and writeable data being in the same page. Disable > + * detection and enforcement there. > + */ > + if (IS_ENABLED(CONFIG_X86_32)) > + return new; > + > /* Only enforce when NX is supported: */ > if (!(__supported_pte_mask & _PAGE_NX)) > return new; > -- > 2.34.1 >