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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 F2A3FC388F9 for ; Wed, 4 Nov 2020 14:41:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2FAD20756 for ; Wed, 4 Nov 2020 14:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730119AbgKDOl2 (ORCPT ); Wed, 4 Nov 2020 09:41:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:44774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbgKDOl2 (ORCPT ); Wed, 4 Nov 2020 09:41:28 -0500 Received: from gaia (unknown [2.26.170.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E5960206DB; Wed, 4 Nov 2020 14:41:23 +0000 (UTC) Date: Wed, 4 Nov 2020 14:41:21 +0000 From: Catalin Marinas To: Szabolcs Nagy Cc: Jeremy Linton , Mark Brown , libc-alpha@sourceware.org, Mark Rutland , Will Deacon , Florian Weimer , Kees Cook , Salvatore Mesoraca , Lennart Poettering , Topi Miettinen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org Subject: Re: [PATCH 0/4] aarch64: avoid mprotect(PROT_BTI|PROT_EXEC) [BZ #26831] Message-ID: <20201104144120.GD28902@gaia> References: <20201103173438.GD5545@sirena.org.uk> <8c99cc8e-41af-d066-b786-53ac13c2af8a@arm.com> <20201104085704.GB24704@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201104085704.GB24704@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 04, 2020 at 08:57:05AM +0000, Szabolcs Nagy wrote: > The 11/03/2020 23:41, Jeremy Linton wrote: > > On 11/3/20 11:34 AM, Mark Brown wrote: > > > On Tue, Nov 03, 2020 at 10:25:37AM +0000, Szabolcs Nagy wrote: > > > > > > > Re-mmap executable segments instead of mprotecting them in > > > > case mprotect is seccomp filtered. > > > > > > > For the kernel mapped main executable we don't have the fd > > > > for re-mmap so linux needs to be updated to add BTI. (In the > > > > presence of seccomp filters for mprotect(PROT_EXEC) the libc > > > > cannot change BTI protection at runtime based on user space > > > > policy so it is better if the kernel maps BTI compatible > > > > binaries with PROT_BTI by default.) > > > > > > Given that there were still some ongoing discussions on a more robust > > > kernel interface here and there seem to be a few concerns with this > > > series should we perhaps just take a step back and disable this seccomp > > > filter in systemd on arm64, at least for the time being? That seems > > > safer than rolling out things that set ABI quickly, a big part of the > > > > So, that's a bigger hammer than I think is needed and punishes !BTI > > machines. I'm going to suggest that if we need to carry a temp patch its > > more like the glibc patch I mentioned in the Fedora defect. That patch > > simply logs a message, on the mprotect failures rather than aborting. Its > > fairly non-intrusive. > > > > That leaves seccomp functional, and BTI generally functional except when > > seccomp is restricting it. I've also been asked that if a patch like that is > > needed, its (temporary?) merged to the glibc trunk, rather than just being > > carried by the distro's. > > note that changing mprotect into mmap in glibc works > even if the kernel or systemd decides to do things > differently: currently the only wart is that on the > main exe we have to use mprotect and silently ignore > the failures. Can the dynamic loader mmap() the main exe again while munmap'ing the original one? (sorry if it was already discussed) -- 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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 274AFC2D0A3 for ; Wed, 4 Nov 2020 14:42:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 90B352074B for ; Wed, 4 Nov 2020 14:42:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mB8zfRMp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90B352074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=s0f97NesDldaCLJHGrNhrQZAKxcdbqP8qG+i7NBeWMg=; b=mB8zfRMp8S17yJBIRhhp124C6 qdm0J8q2tk7emPIUMmF84LdP+PtihH56lc+sc3xnT+/Dy3VGv/Ccuoa9nAZAhrx9ytCInSjAdhK3D o8RKW5NXOJngtoEOAS8dgF97QD14/+gIIyIjBBZiOTa3fKTtISm8Ps8RWwOq+1A5C1zsr8qacKcWa akvYPrOF0NcHBCibn4jPO38q0bC7kBt7DADZO37nror4Hu0mdh1DXE8JNP0sVLTvx5ykSGjzeJN48 DryqAfbcu1ogeoPCjFLKc1XXm5801IDL+g8MrYUX5Xac3WvHTPPobftr1sl541aZaoZ365eyNhZ5N 1Poize98w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaJyd-00050U-Iw; Wed, 04 Nov 2020 14:41:31 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaJya-0004zk-KJ for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2020 14:41:29 +0000 Received: from gaia (unknown [2.26.170.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E5960206DB; Wed, 4 Nov 2020 14:41:23 +0000 (UTC) Date: Wed, 4 Nov 2020 14:41:21 +0000 From: Catalin Marinas To: Szabolcs Nagy Subject: Re: [PATCH 0/4] aarch64: avoid mprotect(PROT_BTI|PROT_EXEC) [BZ #26831] Message-ID: <20201104144120.GD28902@gaia> References: <20201103173438.GD5545@sirena.org.uk> <8c99cc8e-41af-d066-b786-53ac13c2af8a@arm.com> <20201104085704.GB24704@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201104085704.GB24704@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201104_094128_760437_491041CE X-CRM114-Status: GOOD ( 30.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Florian Weimer , libc-alpha@sourceware.org, Kees Cook , kernel-hardening@lists.openwall.com, Salvatore Mesoraca , linux-kernel@vger.kernel.org, Jeremy Linton , Mark Brown , Lennart Poettering , linux-hardening@vger.kernel.org, Topi Miettinen , Will Deacon , linux-arm-kernel@lists.infradead.org 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 Wed, Nov 04, 2020 at 08:57:05AM +0000, Szabolcs Nagy wrote: > The 11/03/2020 23:41, Jeremy Linton wrote: > > On 11/3/20 11:34 AM, Mark Brown wrote: > > > On Tue, Nov 03, 2020 at 10:25:37AM +0000, Szabolcs Nagy wrote: > > > > > > > Re-mmap executable segments instead of mprotecting them in > > > > case mprotect is seccomp filtered. > > > > > > > For the kernel mapped main executable we don't have the fd > > > > for re-mmap so linux needs to be updated to add BTI. (In the > > > > presence of seccomp filters for mprotect(PROT_EXEC) the libc > > > > cannot change BTI protection at runtime based on user space > > > > policy so it is better if the kernel maps BTI compatible > > > > binaries with PROT_BTI by default.) > > > > > > Given that there were still some ongoing discussions on a more robust > > > kernel interface here and there seem to be a few concerns with this > > > series should we perhaps just take a step back and disable this seccomp > > > filter in systemd on arm64, at least for the time being? That seems > > > safer than rolling out things that set ABI quickly, a big part of the > > > > So, that's a bigger hammer than I think is needed and punishes !BTI > > machines. I'm going to suggest that if we need to carry a temp patch its > > more like the glibc patch I mentioned in the Fedora defect. That patch > > simply logs a message, on the mprotect failures rather than aborting. Its > > fairly non-intrusive. > > > > That leaves seccomp functional, and BTI generally functional except when > > seccomp is restricting it. I've also been asked that if a patch like that is > > needed, its (temporary?) merged to the glibc trunk, rather than just being > > carried by the distro's. > > note that changing mprotect into mmap in glibc works > even if the kernel or systemd decides to do things > differently: currently the only wart is that on the > main exe we have to use mprotect and silently ignore > the failures. Can the dynamic loader mmap() the main exe again while munmap'ing the original one? (sorry if it was already discussed) -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel