From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by sourceware.org (Postfix) with ESMTPS id AFE93385780D for ; Tue, 19 Apr 2022 10:52:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AFE93385780D 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 ams.source.kernel.org (Postfix) with ESMTPS id 33833B816A6; Tue, 19 Apr 2022 10:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73DCFC385A7; Tue, 19 Apr 2022 10:52:00 +0000 (UTC) From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Szabolcs Nagy , Jeremy Linton , "H . J . Lu" , Yu-cheng Yu , Kees Cook , Eric Biederman , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org, Mark Brown Subject: [PATCH v13 0/2] arm64: Enable BTI for the executable as well as the interpreter Date: Tue, 19 Apr 2022 11:51:54 +0100 Message-Id: <20220419105156.347168-1-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2110; h=from:subject; bh=Kps/nxXdvPmFXoUlorRs+A7ltjd1wVHQC8NezFMOSIE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiXpRJcfio29GZoxSti3bpnKc41Y8y84J37Pv6Tfyd ZJzwHuiJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYl6USQAKCRAk1otyXVSH0HFoB/ wJVd2GkOxINUznTSbBRQrTn7aErJQuxDfrnxxIUuz5e4u5Ch2h/G/zyIq736my/GfE619j+hJsCmzO Xl5zl4F6l+WOeobRpHCtOt7gUHdGlXJLQbAWhaEIFzZ2RQZRMc9JJ/YYo6TcZERutsIDdYBXUXfMiX TgooicRZ4bErr3yEcfFUlEFnZVrfec0l9aFLpOSfK2QFQBZs9Hsn+yWyZ31/7oTzVvuHsp2OTYVqsa NRcpH9Wyp2esgbjcw1v/hbwxvddO1K4CKGokpZC6eVLYdobt+hxetNJl8QRzT2BL36IUbi+iQdXGu4 haUUXsU5oBv32Ji2i/lxBRE+JkgARk X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Apr 2022 10:52:07 -0000 Deployments of BTI on arm64 have run into issues interacting with systemd's MemoryDenyWriteExecute feature. Currently for dynamically linked executables the kernel will only handle architecture specific properties like BTI for the interpreter, the expectation is that the interpreter will then handle any properties on the main executable. For BTI this means remapping the executable segments PROT_EXEC | PROT_BTI. This interacts poorly with MemoryDenyWriteExecute since that is implemented using a seccomp filter which prevents setting PROT_EXEC on already mapped memory and lacks the context to be able to detect that memory is already mapped with PROT_EXEC. This series resolves this by providing a sysctl which when enabled will cause the kernel to handle the BTI property for both the interpreter and the main executable. v13: - Rebase onto v5.18-rc3. v12: - Rebase onto v5.18-rc1. v11: - Ignore extra PT_INTERPs. v10: - Add a sysctl abi.bti_main controlling the new behaviour. v9: - Rebase onto v5.17-rc3. v8: - Rebase onto v5.17-rc1. v7: - Rebase onto v5.16-rc1. v6: - Rebase onto v5.15-rc1. v5: - Rebase onto v5.14-rc2. - Tweak changelog on patch 1. - Use the helper for interpreter/executable flag in elf.h as well. v4: - Rebase onto v5.14-rc1. v3: - Fix passing of properties for parsing by the main executable. - Drop has_interp from arch_parse_elf_property(). - Coding style tweaks. v2: - Add a patch dropping has_interp from arch_adjust_elf_prot() - Fix bisection issue with static executables on arm64 in the first patch. Mark Brown (2): elf: Allow architectures to parse properties on the main executable arm64: Enable BTI for main executable as well as the interpreter arch/arm64/include/asm/elf.h | 14 ++++++++-- arch/arm64/kernel/process.c | 52 +++++++++++++++++++++++++++--------- fs/binfmt_elf.c | 34 ++++++++++++++++------- include/linux/elf.h | 4 ++- 4 files changed, 78 insertions(+), 26 deletions(-) base-commit: b2d229d4ddb17db541098b83524d901257e93845 -- 2.30.2