Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1350382pxb; Wed, 4 Nov 2020 06:46:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVQlvSEpH3ScEXwdkbL573AFJkU+SKZmcGOc1hx3P1A5q3D5q+aJU5DX6/bk3d3UkSphmf X-Received: by 2002:a05:6402:1206:: with SMTP id c6mr11033165edw.2.1604501188802; Wed, 04 Nov 2020 06:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604501188; cv=none; d=google.com; s=arc-20160816; b=QK0B86SNSoaXkzsUNqCVUT34E/ovRg9rhHkHykVpfxmcQb7w5a71RNiTmX2F4Cf63Z EtrCwfZC01BWfSHtXwNmJNJnDg4h73oaJhMpY6lsv0Q8I0PxVTaRQzTXp8a4iA6QJ8ML bPZrY1ltnFo+t0AbPTqiUh2HWFvLncZ0iJkz1uk4WpZVi3O71GTgkJrBlcHpQ58Bop1C 3p68TmD8ZQikZjsIB8f9xa3oIkjf2OLUb8QOIR/1W04WKHOXe8FcUF2BnDPFIulsdZlg iGEZpOMSMpfo+OGs1S9J66b69tj3+2MRJzmTrf76uXrhy5uRahJ7j3KfTj0hZEbui2S+ ZvWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=E4Y4/toxRhDqMjyX8DZxPI9B9mt5GiSMEFNI8Kko5Vc=; b=M+hYYVh4CwgvT9qmGJZltHcCR/SkX/UohriYapXw1uqSqLNGzTaRKUn5pKx/UB1M+i +h4QspM1qp9hviGWxQr0qbiAcAl8PHQFcxdmduPBb18wNvP0CwNfviJO9Fmuw77yCN5x +E+9Vx2GPDfjkYZO/5mbrcl6tdiHJx1Ji1lPg5LUnFS5ByPCtDq2ytyHYpwkUXk52fk2 iKf7B2ysUhmCxRt+HC53fYWeQjmCq8WpvSs3F2U+6GIDuy+0HV+iFydrDUhLKenaz249 rMoIYLrpZQ/jDcE4YaLllbz+xsCMC4cHRKThAy5hE+7KtsFdRHfeNKJ8RxO1tXy8TbLC 7wNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc13si1395851edb.104.2020.11.04.06.46.05; Wed, 04 Nov 2020 06:46:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730073AbgKDOl2 (ORCPT + 99 others); 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