From patchwork Tue Oct 4 18:07:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: thermal-bot for Julien Panis X-Patchwork-Id: 612405 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 F154DC433F5 for ; Tue, 4 Oct 2022 18:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbiJDSHl (ORCPT ); Tue, 4 Oct 2022 14:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbiJDSHl (ORCPT ); Tue, 4 Oct 2022 14:07:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0BCD53D3F; Tue, 4 Oct 2022 11:07:36 -0700 (PDT) Date: Tue, 04 Oct 2022 18:07:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1664906855; h=from:from:sender:sender:reply-to: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:content-transfer-encoding; bh=eY2DWEEsNVLOS2vTQvlgLOYzWOASEQKGPb+PmiY9Yvg=; b=tw5FDHmr+caSLOcJ2uTKG8xq857H2mRp/lXPkSWFdYzNlhCotQl2b7hpYzcVnWImOrRcmi jgs/yUik6hROJ4o4UrW4AOaVT56Ivjm6hVQwsKwUl0XWfutOcAM2fkJq3MBOhdf81okFyO sBbpM14fygs6m5TU5cWFa11+ODo4Nj4q6D8nN+CM9dEUGejbhuuF5ZXNqfgZIlkNfidOVt U5mQioK55W76lQG0GiX7J7V7e4cxpykDrlCslBAtYGnq7H6Y5aTggekBGaeLDGDo4edSNZ Xk1AVx62c4SoIXia92HbKBFrXb4QXKf9JJY4q2sFqDHUXsROFrWVgkpY55wcDg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1664906855; h=from:from:sender:sender:reply-to: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:content-transfer-encoding; bh=eY2DWEEsNVLOS2vTQvlgLOYzWOASEQKGPb+PmiY9Yvg=; b=okv/dvpZP/6q7Bb7VOMHRppHmR6+b2HN2p03upwoeujGbnqg7tVvtimID36CWBRRhaOyNZ TVu8/svjA8XeLzBQ== From: "tip-bot2 for Dave Hansen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] x86/mm: Disable W^X detection and enforcement on 32-bit Cc: Guenter Roeck , Dave Hansen , Ard Biesheuvel , Darren Hart , Andy Shevchenko , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, linux-efi@vger.kernel.org, "H. Peter Anvin" , Kees Cook , linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166490685372.401.8724006488941040622.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The following commit has been merged into the x86/mm branch of tip: Commit-ID: 8c4934f4754057e3577bb1536c6ecc0efa2c966e Gitweb: https://git.kernel.org/tip/8c4934f4754057e3577bb1536c6ecc0efa2c966e Author: Dave Hansen AuthorDate: Fri, 23 Sep 2022 14:29:45 -07:00 Committer: Dave Hansen CommitterDate: Mon, 03 Oct 2022 13:12:23 -07:00 x86/mm: Disable W^X detection and enforcement on 32-bit 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/ --- 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 20b1e24..efe882c 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;