Message ID | 20210614223214.39011-1-broonie@kernel.org (mailing list archive) |
---|---|
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> 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 83581384842C for <patchwork@sourceware.org>; Mon, 14 Jun 2021 22:33:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83581384842C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623710006; bh=QSbYWrwPq4XZyimNwogQICx/u7mJD4aIVMnfYBc3cr4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Gifb3yj4gsnGQ2jJqAlhwWJQlF88Au+FWhm4GpPAkYJUa2+Tw9xJL3B52/ruxxes1 TMZlAijhsZ8ZLYS3dZzrCdk0sWrD9pRpzQtCr8lueAj3ZPQXKGWZ5/PH1ESIPFxREN xX+yVLv4MXASTipAFKSmghyWwwYrM2X461aS+3GY= 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 04324385503F for <libc-alpha@sourceware.org>; Mon, 14 Jun 2021 22:33:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 04324385503F Received: by mail.kernel.org (Postfix) with ESMTPSA id 7C120611CE; Mon, 14 Jun 2021 22:33:03 +0000 (UTC) To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org> Subject: [PATCH v3 0/4] arm64: Enable BTI for the executable as well as the interpreter Date: Mon, 14 Jun 2021 23:32:10 +0100 Message-Id: <20210614223214.39011-1-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2156; h=from:subject; bh=1kttxY5HjwWN86k+EJQoe+g9QsvSoz0LeKgZ0xCI6qc=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBgx9jpTlJ5MnJRp0eC3EbCH14AgQ9moJeH2EhyUxrd WkurP8OJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYMfY6QAKCRAk1otyXVSH0L8/B/ 9DF+/o4D85EdoAaFyMTYzLFlyr5QHFDQS0uVicMa+psnlUjGgc8+Dc5MGjrSjh5lQIWgdPJF8FhKYj 2Wiu1QEYji3e+cARAhr6honQGf+mBtevppJc17CpxJs0Id2Q0jBOH0FoREIOGoKphCGTbsS4otXOWh 8L5YFxYvjUGmEUbBID6wgz0sbeRdtCFmlTthdZCdGiMI6g5hY9OTraKZ/TVTg2IdxJUEnEzJQ8ObLW EzaUkw4BJu5jKu8KRaxBCoopD5fUvUTm9HnK/iK5TTMYoRYPjlZsB+FGmK6P5ow4bOFFxgHeUeWHqk +r7lFtHCCM0inhENJ4cZc+sfWpv2Zc X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Mark Brown via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Mark Brown <broonie@kernel.org> Cc: linux-arch@vger.kernel.org, Yu-cheng Yu <yu-cheng.yu@intel.com>, libc-alpha@sourceware.org, Szabolcs Nagy <szabolcs.nagy@arm.com>, Jeremy Linton <jeremy.linton@arm.com>, Mark Brown <broonie@kernel.org>, Dave Martin <dave.martin@arm.com>, linux-arm-kernel@lists.infradead.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
arm64: Enable BTI for the executable as well as the interpreter
|
|
Message
Mark Brown
June 14, 2021, 10:32 p.m. UTC
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. 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 | 13 ++++++++++--- arch/arm64/kernel/process.c | 23 +++++++++++------------ fs/binfmt_elf.c | 33 ++++++++++++++++++++++++--------- include/linux/elf.h | 8 +++++--- 4 files changed, 50 insertions(+), 27 deletions(-) base-commit: c4681547bcce777daf576925a966ffa824edd09d
Comments
Hi, On 6/14/21 5:32 PM, Mark Brown wrote: > 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. It looks like its working as expected now (the previously detailed test is now failing) in a MDWE enviroment, and the smaps/etc looks as expected too. Thanks for fixing this! tested-by: Jeremy Linton <jeremy.linton@arm.com> > > 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 | 13 ++++++++++--- > arch/arm64/kernel/process.c | 23 +++++++++++------------ > fs/binfmt_elf.c | 33 ++++++++++++++++++++++++--------- > include/linux/elf.h | 8 +++++--- > 4 files changed, 50 insertions(+), 27 deletions(-) > > > base-commit: c4681547bcce777daf576925a966ffa824edd09d >