From patchwork Mon Nov 15 15:27:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 47679 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0AAE33857C42 for ; Mon, 15 Nov 2021 15:27:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AAE33857C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636990068; bh=Gu88fQwSWj4ZyUjDCfCXa3U8WWoYzknHCIzqm//0shw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=kQI1oJDLFSO4S/75W+hLQkvqb5HsziolZgNm3yE2VPyk5wNOCAHl69ukRa6yGTvwK 1MRDWwqr9Buj51WaYOFOtzjOPwyIYEUys7HOsSfunTUiRmIT7UpgrU/R509wmDts4N NMZ/telAlLOI5ebh20lTpOgkowWT/gE642FuVh7I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by sourceware.org (Postfix) with ESMTPS id C96623858D39 for ; Mon, 15 Nov 2021 15:27:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C96623858D39 Received: by mail.kernel.org (Postfix) with ESMTPSA id D61DC60EB2; Mon, 15 Nov 2021 15:27:21 +0000 (UTC) To: Catalin Marinas , Will Deacon Subject: [PATCH v7 0/4] arm64: Enable BTI for the executable as well as the interpreter Date: Mon, 15 Nov 2021 15:27:10 +0000 Message-Id: <20211115152714.3205552-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=2375; h=from:subject; bh=y2gJEptAy9Et9KNJ+WgWMubC2Cf2DYOaQGtmMK574eM=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhknxLTDDzIIYxy+ulyMSW7G9JFvtTRLsXNuPUPEwl 4lYp3TqJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYZJ8SwAKCRAk1otyXVSH0F+rB/ 9Ui/dB66NxvOi8g/beOGNPDLFGwrLIyaBV8Ro1VoGi8dU9mcRWkTNhiYEFk2h70oDW8Ss3RIqeq9hm j2ZOIk/yXtfqbpVXIc3qIdznwiwqvlxCiNC9CWHBk9PnjZmn0f5di2+RHyVliiJCUVOir55WC8TMv2 aoEWxAuMzOwQgfeDIs7ai3pM7J7goBNFWEQo8l6pKSvu+RVOt8x/O0AecknD/4Hy9YTWuHfrfFPig8 ZCK/PZRfCM3nbOYRjDCi7W+ThbG4HRNnRmuiK6pofKVnFBf3UoUmPiVfv4q1FPPgfmUbfZQQIcmwJo SkngK8Mq1B6BOWkV9NU+1KBosJwLMm X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Spam-Status: No, score=-5.7 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 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-Patchwork-Original-From: Mark Brown via Libc-alpha From: Mark Brown Reply-To: Mark Brown Cc: linux-arch@vger.kernel.org, Yu-cheng Yu , libc-alpha@sourceware.org, Szabolcs Nagy , Jeremy Linton , Mark Brown , linux-arm-kernel@lists.infradead.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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 handling the BTI property for both the interpreter and the main executable. This does mean that we may get more code with BTI enabled if running on a system without BTI support in the dynamic linker, this is expected to be a safe configuration and testing seems to confirm that. It also reduces the flexibility userspace has to disable BTI but it is expected that for cases where there are problems which require BTI to be disabled it is more likely that it will need to be disabled on a system level. 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 (4): elf: Allow architectures to parse properties on the main executable arm64: Enable BTI for main executable as well as the interpreter elf: Remove has_interp property from arch_adjust_elf_prot() elf: Remove has_interp property from arch_parse_elf_property() arch/arm64/include/asm/elf.h | 14 ++++++++++++-- arch/arm64/kernel/process.c | 16 +++------------- fs/binfmt_elf.c | 29 ++++++++++++++++++++--------- include/linux/elf.h | 8 +++++--- 4 files changed, 40 insertions(+), 27 deletions(-) base-commit: fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf