From patchwork Tue Jan 9 12:14:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13514852 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 270ACC46CD2 for ; Tue, 9 Jan 2024 12:15:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94B716B0092; Tue, 9 Jan 2024 07:15:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FBD46B0093; Tue, 9 Jan 2024 07:15:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C37D6B0095; Tue, 9 Jan 2024 07:15:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6DD7F6B0092 for ; Tue, 9 Jan 2024 07:15:02 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 30FDB16034B for ; Tue, 9 Jan 2024 12:15:02 +0000 (UTC) X-FDA: 81659666844.12.CC62443 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf28.hostedemail.com (Postfix) with ESMTP id 0B6F2C0018 for ; Tue, 9 Jan 2024 12:14:59 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704802500; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=HS9QdPUNUFW/JwtxNBBaQWAJJEG0MI6QHEv6bKC6uK0=; b=7cxcOP08HMBcbziGAXSPVVoIzfFzTl2tgGMot1XNdejZcTDHirFYdYXoaRlKm5bovWbp6D y5P2gHxpPEwC3P4APh65f6nYhr/08c1fp3WzQHRMdIu9fkOdca1Nb3HnMbrZrJIqH1Rg1J o8D/1fWb8fFZkQd6x4I/t1HUz8Ycm6M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704802500; a=rsa-sha256; cv=none; b=KP9tptkmBf6CPxxxd2lpN093En+zk6D9b33StAe7UpVRcVv23whqk35t8Eir9hJOrSan2M 2TjRuzgQqmcp7D9fQgqyLdekqRG/bsDPRo3Y7ZR4DZ8hJRBbt0xmPZDC9cMB3xXwkxhT3F gGqjkbs/tMKZxHqob2WGwT9Krhj6Zxs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4T8VHN1DB7z9v5M; Tue, 9 Jan 2024 13:14:56 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3UZY3QTji_ou; Tue, 9 Jan 2024 13:14:56 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4T8VHN0Hfvz9v2V; Tue, 9 Jan 2024 13:14:56 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 003308B77D; Tue, 9 Jan 2024 13:14:55 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id HBR04NexVvw3; Tue, 9 Jan 2024 13:14:55 +0100 (CET) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.233.126]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6EFF18B774; Tue, 9 Jan 2024 13:14:54 +0100 (CET) From: Christophe Leroy To: linux-hardening@vger.kernel.org, Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Gerald Schaefer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Andrew Morton , Kees Cook Cc: Christophe Leroy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-mm@kvack.org, steven.price@arm.com, Phong Tran , mark.rutland@arm.com, Greg KH Subject: [PATCH 0/4] Refactor CONFIG_DEBUG_WX and check_wx_pages debugfs attribute Date: Tue, 9 Jan 2024 13:14:34 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1704802473; l=2144; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=Rosrc8SJ5lP3rVnXrjZMc3fjClOukQO/LV2fzgZVpQs=; b=s3Okt6I7tVLtHH9cIsW0wOp8leAGxF9lRsidic0YqOYcxb/GPUWk/wsLaGOrOrDVlBeQJRl4d A3TZyNi11uFDTOsNtgCv9Dd/0t2LrUpaUdzKjfrAy93UgJ/oTqyg9E5 X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Stat-Signature: 8krpo6wbxwte6by5p5gwbrof1xz68p87 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 0B6F2C0018 X-Rspam-User: X-HE-Tag: 1704802499-801595 X-HE-Meta: U2FsdGVkX1+55kq/3w7YfKSue4gBHLayt/iVNXI1Kbtge85TkW6dYljGV3GlgquaMdrXiY/fmQjjO40xnsHue0+BAXB1mBEOzuWHHOQH0Rz2ztduBQX7HyhUXOKSWTN1QCpJl8ahynzLgGEIzseAgjOfR4XnRYrHrw3VctCm0I9RZu3PSLpC+PRltCE+/n47BYapGZXt1in0zI2t5YZC+zmK/QS9AOZK7GZZKQBJo5vGyDiVpdqeAqZ7HgjVlpeTJrjvCHtWKunpcrucL5w0H9+DQRjDoPC6GYe2L94T3stdq1mG+QfzCP5oIBu8JsRz6pJJNpHanaDocPKT0Qc0QLqFH2K1lVz7EiMWhRpHxKaMUXXI+zopEX6IoMx7+GRZ1kMVlRxvViyLdniev+Wot6A/cmfPbPk09TPu6jOkkxf5W/Nws7HC5Ye7ZgzSzN0FftizxKV8K1ESqEU+nxnZYWeVzQljVRviXeCZIaF2tuTwWqUKsH/vvxZxLQvFYBAOraymCfIxfk4ImqOHk+vSkntApujL2sgaSHkkAQ84snVE/zPXvmF7mhcPeuTzAgOEarRH+iAfoZA5oAgl4g9j3lagPsrqxzr0fRk6sprzUQHaUZscgUWx/C8E2984uK7S4W1oibMNAJqlydTNY6TPzelMIG8FqExG+JBlvBeQQwqj92x2vDEDQ37GD9m2xt435M8R78DMbtyR3YZLEQ1qh9ixcBN9evpYdu6b3f5KgCHm1emkjUo1aLnTolTFQgFBHUE2GUHMndh0lBR930oA8eJFpWjgsP7Gct5N9SO+3y4nBbV9TKLKixkmKpA8t9HugAJfLG56eFf8skv4MBCj47dLy2gOkpYPpkPOSQrxWilylBRKoNHXrY4JV70wHL1n+7nNSdb24Xs3Bn2IXkBsXsX7NG8Z9S20amxWiYdVlxhOc12CKUQWgdjitnfnwHiRZwkDV373GZ/rxYcraS1 lWyeoiyn 8cPQ0xlXvozQgucWr39y6dzj/MKt+nxl4mvLu96RlfkK6XEdDD6adedFUCd/4jCKouIuv/qzuvAw3wuQC4E88qTV+Y/pXuNQvqF82AKe2zerRDz2PftajOJ97bcA/er26sx/2BV0cz9eLvFGLWMiknE+69MiCO0MR54Su4Lal2fKNosStFOWdX/lBCuy1aVekcP6A/vszI0rjUwMjQCr3chVwVTr0RtakDOeHrJM1z9+r0J9M4ym6DnTyjdmdx4YtgwkfoX7PlfLuzh2NpQf3AECuMQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Refer old discussion at https://lore.kernel.org/lkml/20200422152656.GF676@willie-the-truck/T/#m802eaf33efd6f8d575939d157301b35ac0d4a64f And https://github.com/KSPP/linux/issues/35 This series refactors CONFIG_DEBUG_WX for the 5 architectures implementing CONFIG_GENERIC_PTDUMP First rename stuff in ARM which uses similar names while not implementing CONFIG_GENERIC_PTDUMP. Then define a generic version of debug_checkwx() that calls ptdump_check_wx() when CONFIG_DEBUG_WX is set. Call it immediately after calling mark_rodata_ro() instead of calling it at the end of every mark_rodata_ro(). Then implement a debugfs attribute that can be used to trigger a W^X test at anytime and regardless of CONFIG_DEBUG_WX Christophe Leroy (4): arm: ptdump: Rename CONFIG_DEBUG_WX to CONFIG_ARM_DEBUG_WX arm64, powerpc, riscv, s390, x86: Refactor CONFIG_DEBUG_WX powerpc,s390: Define ptdump_check_wx() regardless of CONFIG_DEBUG_WX ptdump: add check_wx_pages debugfs attribute arch/arm/Kconfig.debug | 2 +- arch/arm/include/asm/ptdump.h | 6 +++--- arch/arm64/include/asm/ptdump.h | 7 ------- arch/arm64/mm/mmu.c | 2 -- arch/powerpc/mm/mmu_decl.h | 6 ------ arch/powerpc/mm/pgtable_32.c | 4 ---- arch/powerpc/mm/pgtable_64.c | 3 --- arch/powerpc/mm/ptdump/ptdump.c | 10 ++++++---- arch/riscv/include/asm/ptdump.h | 22 ---------------------- arch/riscv/mm/init.c | 3 --- arch/riscv/mm/ptdump.c | 1 - arch/s390/include/asm/ptdump.h | 14 -------------- arch/s390/mm/dump_pagetables.c | 8 ++------ arch/s390/mm/init.c | 2 -- arch/x86/include/asm/pgtable.h | 3 +-- arch/x86/mm/dump_pagetables.c | 3 +++ arch/x86/mm/init_32.c | 2 -- arch/x86/mm/init_64.c | 2 -- include/linux/ptdump.h | 7 +++++++ init/main.c | 2 ++ mm/ptdump.c | 19 +++++++++++++++++++ 21 files changed, 44 insertions(+), 84 deletions(-) delete mode 100644 arch/riscv/include/asm/ptdump.h delete mode 100644 arch/s390/include/asm/ptdump.h