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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01666C433F5 for ; Mon, 28 Feb 2022 13:07:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234642AbiB1NIO (ORCPT ); Mon, 28 Feb 2022 08:08:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234424AbiB1NIJ (ORCPT ); Mon, 28 Feb 2022 08:08:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BD63C54 for ; Mon, 28 Feb 2022 05:07:27 -0800 (PST) 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 1B4DDB81110 for ; Mon, 28 Feb 2022 13:07:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 434FEC340E7; Mon, 28 Feb 2022 13:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646053644; bh=3D39ey04d2tSNbYQJqs5wQw0sel+gm4JWNwn6CjOQDE=; h=From:To:Cc:Subject:Date:From; b=MMnnNZZ5eyLiSG7wE8SPOb1ibR/3l4ykdObinp/uZfNzmqXIBcBEntj/6SocZrif9 +Lni1c8SS7RDh8SnVTfR5T+Oz0359Be5evJJgomtdwyjKT0eBJ7EIw7k930zOB1WDb t5Ypq9Da3VO5WGKsPkACoINS1pT8qrRoZ3OdT3paNM+4sXsWotlWfEMnJo3r9R5Q+b mW7Cs8eRAz4NWAs6BB0kQsjUzL+CmEkO/lnwJLo2ZTF5tboh7ehxt0QcnA7O9HBnMX Xanf6kSR2ZvVNhn0aNt6XNqAdpXcVWWZNT6WBsiW4XhGKISNEAWKSuB+ohnEHgwRZh SZE1L1B7RK+XQ== 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 v10 0/2] arm64: Enable BTI for the executable as well as the interpreter Date: Mon, 28 Feb 2022 13:06:04 +0000 Message-Id: <20220228130606.1070960-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=2008; h=from:subject; bh=3D39ey04d2tSNbYQJqs5wQw0sel+gm4JWNwn6CjOQDE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiHMi78Ns5UeAT/TGmHQuigmHVKkTD9PzzsXgY1IG5 ZD50ZaGJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYhzIuwAKCRAk1otyXVSH0IewB/ 0Q7xcFWIflR0OS+UJ9X62BLVivIDZjb9fXEwAcXQ9yjpJjvK0kO/C5eUxUAjrbmWCIf3vYcfqzViBe cjiDZ4ZZ6sRBTT7fdqIthTIm1/FI1vJl/skbbtPgx1gSoWZ1Z3JxRUVxXspBKP8iV0eSa8jzmSEeB3 EdkOm5zAkbl9baqLWPEtz7VtMUGC42/ZaVGhBOVFaq4pX2MuV5pvLH38TKS5n6TDwfDrBXeDO6JtxN df5S+oM9zUStWZcyNW+tmrWm7ytNIaa8jua3lgjlNbNm9+TebxmavpUhSuUN/GdS8cSi2MR3WVIisa R8jp02hcLXFpCsxnidTaAQnwA74Zo/ 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 providing a sysctl which when enabled will cause the kernel to handle the BTI property for both the interpreter and the main executable. 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 | 32 +++++++++++++++------- include/linux/elf.h | 4 ++- 4 files changed, 77 insertions(+), 25 deletions(-) base-commit: dfd42facf1e4ada021b939b4e19c935dcdd55566 -- 2.30.2 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 65B03C433EF for ; Mon, 28 Feb 2022 13:20:02 +0000 (UTC) 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=bVOuMN2hnGFI22ciMPqrJOO4E7OsSjIjCJjzQtzY3N4=; b=G5igMa9WJQh/i5 JNzwR20uMj/gqqv7Hhuo0gi2RE/sSg/+mCbmN4gBy37MW39zSd1jN/3/DJoUp85bqHCoAPimd+wcF 3uL0aq5MF9nfJHLYS9QiXLh1fgseHxznlu8zjXRvE6qsF7ShxkGxkqdJKwsdmY5d2lddZ40RQXSZ5 KtvTNtCRCD0ZQ7ve7cGzFaA+xuEVRCT5gUGrqv7OPC/fnIM7+gQmIzLaizCcxMOKmzkn7t24EqD9h 68EvUJ5W/Bcep/E6lsNi10I+GOvMx39TGcMVSz8PJB+m1QnLjaggGC6Y1NeH4/EaibHoE5+YrjswE uzgFJEdMbfhHqid5j+hA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOfv3-00CVG7-J3; Mon, 28 Feb 2022 13:18:29 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOfkM-00CRIh-N4 for linux-arm-kernel@lists.infradead.org; Mon, 28 Feb 2022 13:07:29 +0000 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 dfw.source.kernel.org (Postfix) with ESMTPS id 6359E612CA; Mon, 28 Feb 2022 13:07:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 434FEC340E7; Mon, 28 Feb 2022 13:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646053644; bh=3D39ey04d2tSNbYQJqs5wQw0sel+gm4JWNwn6CjOQDE=; h=From:To:Cc:Subject:Date:From; b=MMnnNZZ5eyLiSG7wE8SPOb1ibR/3l4ykdObinp/uZfNzmqXIBcBEntj/6SocZrif9 +Lni1c8SS7RDh8SnVTfR5T+Oz0359Be5evJJgomtdwyjKT0eBJ7EIw7k930zOB1WDb t5Ypq9Da3VO5WGKsPkACoINS1pT8qrRoZ3OdT3paNM+4sXsWotlWfEMnJo3r9R5Q+b mW7Cs8eRAz4NWAs6BB0kQsjUzL+CmEkO/lnwJLo2ZTF5tboh7ehxt0QcnA7O9HBnMX Xanf6kSR2ZvVNhn0aNt6XNqAdpXcVWWZNT6WBsiW4XhGKISNEAWKSuB+ohnEHgwRZh SZE1L1B7RK+XQ== 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 v10 0/2] arm64: Enable BTI for the executable as well as the interpreter Date: Mon, 28 Feb 2022 13:06:04 +0000 Message-Id: <20220228130606.1070960-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=2008; h=from:subject; bh=3D39ey04d2tSNbYQJqs5wQw0sel+gm4JWNwn6CjOQDE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiHMi78Ns5UeAT/TGmHQuigmHVKkTD9PzzsXgY1IG5 ZD50ZaGJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYhzIuwAKCRAk1otyXVSH0IewB/ 0Q7xcFWIflR0OS+UJ9X62BLVivIDZjb9fXEwAcXQ9yjpJjvK0kO/C5eUxUAjrbmWCIf3vYcfqzViBe cjiDZ4ZZ6sRBTT7fdqIthTIm1/FI1vJl/skbbtPgx1gSoWZ1Z3JxRUVxXspBKP8iV0eSa8jzmSEeB3 EdkOm5zAkbl9baqLWPEtz7VtMUGC42/ZaVGhBOVFaq4pX2MuV5pvLH38TKS5n6TDwfDrBXeDO6JtxN df5S+oM9zUStWZcyNW+tmrWm7ytNIaa8jua3lgjlNbNm9+TebxmavpUhSuUN/GdS8cSi2MR3WVIisa R8jp02hcLXFpCsxnidTaAQnwA74Zo/ 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-20220228_050726_889099_17F81CFB X-CRM114-Status: GOOD ( 12.94 ) 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 providing a sysctl which when enabled will cause the kernel to handle the BTI property for both the interpreter and the main executable. 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 | 32 +++++++++++++++------- include/linux/elf.h | 4 ++- 4 files changed, 77 insertions(+), 25 deletions(-) base-commit: dfd42facf1e4ada021b939b4e19c935dcdd55566 -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel