From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29988C2B9F4 for ; Mon, 14 Jun 2021 22:33:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01BAE613AC for ; Mon, 14 Jun 2021 22:33:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229696AbhFNWfJ (ORCPT ); Mon, 14 Jun 2021 18:35:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:52064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbhFNWfI (ORCPT ); Mon, 14 Jun 2021 18:35:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7C120611CE; Mon, 14 Jun 2021 22:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623709984; bh=1kttxY5HjwWN86k+EJQoe+g9QsvSoz0LeKgZ0xCI6qc=; h=From:To:Cc:Subject:Date:From; b=AdFG1sq8HMXV2ZTKKp6R25/GSxMTmILuJliaSeS0vXJ9k62bkhVpyse8fsk9z3CUX z+BbzJi1whsha2sn7Gy70wyU6Fqj1B+U8s6GU3M4Acj/5ZiX/zBpez/QHbIHwCgnjd I5houeQ3Cy7ypxvXUThwRlm1qmRcnxPMuW/5VSRJIKk9207Qqj6Al8oDHqCBdpnM0S /RuK1R2qkt4wZTZ1tzds9vBFIunQXcgl/wzTGEQ6jCgdFNpZ8Mp5xqIQOTC3+K/QtZ R0OcjOYemg5tjgvodhDYdGsYTJ3rkucvk/aPx3H822A4j8rdAFYWJn4aeSI3Qr7xU+ gse5kA0bFa3zw== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Szabolcs Nagy , Jeremy Linton , Dave Martin , "H . J . Lu" , Yu-cheng Yu , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org, Mark Brown 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 Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org 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 -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 193ABC2B9F4 for ; Mon, 14 Jun 2021 22:34:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C552161356 for ; Mon, 14 Jun 2021 22:34:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C552161356 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ww9jxjAPVJ6K066z5K1a9rW9pw9bCyAkhivCaQTB2R4=; b=Z3mAHP9ELKus9v OlQWZ6Iv6qC8nYiNIkU1I1ggl/ZnlqhAPDK2UAz/4mzuYHZz69DYOARWFzWOFh6ep5Np4reD1creD DX/IMW4R9JWR5BE1DAtmmGSa29UwzXbZwio4m59pRx/WjLaBaryFqCpVXJVpmC/udga1NcjOCrjNw sxMryrrbkMs+2gPnuAxpd0IooHqXk4l/e4MzIX/RVhP9FTA2wPXC4QbY5sc7fmn4n4hq1Wl7cRUii RspMI3TEIvWD7qrUlpIaN0J4ptYVsEyZ+jI1uPusm+bqQQz4v1gbpwIyHKr5hYjTqPKHpkT5ATHvw RI6tzVavXdZ+GxYc4cug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsv8m-00GPe4-Dh; Mon, 14 Jun 2021 22:33:08 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsv8i-00GPdU-ES for linux-arm-kernel@lists.infradead.org; Mon, 14 Jun 2021 22:33:05 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7C120611CE; Mon, 14 Jun 2021 22:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623709984; bh=1kttxY5HjwWN86k+EJQoe+g9QsvSoz0LeKgZ0xCI6qc=; h=From:To:Cc:Subject:Date:From; b=AdFG1sq8HMXV2ZTKKp6R25/GSxMTmILuJliaSeS0vXJ9k62bkhVpyse8fsk9z3CUX z+BbzJi1whsha2sn7Gy70wyU6Fqj1B+U8s6GU3M4Acj/5ZiX/zBpez/QHbIHwCgnjd I5houeQ3Cy7ypxvXUThwRlm1qmRcnxPMuW/5VSRJIKk9207Qqj6Al8oDHqCBdpnM0S /RuK1R2qkt4wZTZ1tzds9vBFIunQXcgl/wzTGEQ6jCgdFNpZ8Mp5xqIQOTC3+K/QtZ R0OcjOYemg5tjgvodhDYdGsYTJ3rkucvk/aPx3H822A4j8rdAFYWJn4aeSI3Qr7xU+ gse5kA0bFa3zw== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Szabolcs Nagy , Jeremy Linton , Dave Martin , "H . J . Lu" , Yu-cheng Yu , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org, Mark Brown 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210614_153304_535198_6542EC31 X-CRM114-Status: GOOD ( 12.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel