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 AFEF5C433F5 for ; Wed, 8 Dec 2021 18:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238841AbhLHS1W (ORCPT ); Wed, 8 Dec 2021 13:27:22 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:41372 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238843AbhLHS1W (ORCPT ); Wed, 8 Dec 2021 13:27:22 -0500 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 sin.source.kernel.org (Postfix) with ESMTPS id CCE1DCE2321 for ; Wed, 8 Dec 2021 18:23:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1114AC341C8; Wed, 8 Dec 2021 18:23:43 +0000 (UTC) Date: Wed, 8 Dec 2021 18:23:40 +0000 From: Catalin Marinas To: Mark Brown Cc: Will Deacon , Szabolcs Nagy , Jeremy Linton , "H . J . Lu" , Yu-cheng Yu , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org, Mark Rutland Subject: Re: [PATCH v7 0/4] arm64: Enable BTI for the executable as well as the interpreter Message-ID: References: <20211115152714.3205552-1-broonie@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211115152714.3205552-1-broonie@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Mon, Nov 15, 2021 at 03:27:10PM +0000, 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. Given the silence on this series over the past months, I propose we drop it. It's a bit unfortunate that systemd's MemoryDenyWriteExecute cannot work with BTI but I also think the former is a pretty blunt hardening mechanism (rejecting any mprotect(PROT_EXEC) regardless of the previous attributes). I'm not a security expert to assess whether MDWX is more important than BTI (hardware availability also influences the distros decision). My suggestion would be to look at a better way to support the MDWX on the long run that does not interfere with BTI. -- Catalin 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 CA491C433F5 for ; Wed, 8 Dec 2021 18:25:09 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=C96ZQixDnegUNUlMxumZozt0wEx7KRKAo+9cqmV+le4=; b=ayJ8tUEI+5jAvD 5RXxmv0nUnYy8iNrv12DxeQILirrDbH+Q3AD+tCTPxf5Jixs51knqdAIlUaJWHZoqfWtUNprc9ph+ exNqM9boXuAnUsjBpOf68NOCD0GdLxO841zsoZ8twjSET3zmkO03NHkByYwkNIGK7LJ1zWG13woq9 0lrWzDcCZGSrkv8Yzx+F5yRToke7i9600cT4J1EAYo6QxljFRLrHoNjg1Kdrhtw+VuKaeGsqa+xwI CzJ4v7GIuupdL84GGDHOjh6xtp12YfS0KkvbJXzjrZ0HfpRUfq8+Al+hPBcG8+k9ip0A+u47SjvwD CcPKsXSJZb9GGB9okyTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mv1bb-00DsdZ-Va; Wed, 08 Dec 2021 18:23:52 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mv1bY-00Dscc-It for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 18:23:50 +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 ams.source.kernel.org (Postfix) with ESMTPS id 58533B82267; Wed, 8 Dec 2021 18:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1114AC341C8; Wed, 8 Dec 2021 18:23:43 +0000 (UTC) Date: Wed, 8 Dec 2021 18:23:40 +0000 From: Catalin Marinas To: Mark Brown Cc: Will Deacon , Szabolcs Nagy , Jeremy Linton , "H . J . Lu" , Yu-cheng Yu , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, libc-alpha@sourceware.org, Mark Rutland Subject: Re: [PATCH v7 0/4] arm64: Enable BTI for the executable as well as the interpreter Message-ID: References: <20211115152714.3205552-1-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211115152714.3205552-1-broonie@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211208_102348_781261_A5115E89 X-CRM114-Status: GOOD ( 20.72 ) 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 On Mon, Nov 15, 2021 at 03:27:10PM +0000, 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. Given the silence on this series over the past months, I propose we drop it. It's a bit unfortunate that systemd's MemoryDenyWriteExecute cannot work with BTI but I also think the former is a pretty blunt hardening mechanism (rejecting any mprotect(PROT_EXEC) regardless of the previous attributes). I'm not a security expert to assess whether MDWX is more important than BTI (hardware availability also influences the distros decision). My suggestion would be to look at a better way to support the MDWX on the long run that does not interfere with BTI. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel