Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1370036pxu; Sat, 24 Oct 2020 08:34:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3kHblEBGma2bUNZY/EhhY4l7G+IR8+dnyjx2V54V15t3OPIsdQ779PtRnOmp/JRLEfN7W X-Received: by 2002:a17:906:3997:: with SMTP id h23mr5592077eje.191.1603553681768; Sat, 24 Oct 2020 08:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603553681; cv=none; d=google.com; s=arc-20160816; b=PjnarvdXtevpdnqnvAPCxUZKsSDJtlpmAELDV7oB9BgcqOGsvPXV4AsAr3RzNRGonC KXDYe+PxhdhQlbc6fJI7iXScm0ShWN46a1jCv77ZjvZrTsU0jRZORiYRB0c3oXuQqIid AvCRhvlvdeXAcHW/B9D9p+KFLLLw7bSkSh52r2HbonCf4wDlA0VtLP+NGpANldx5uNBo Y5zj3PXUEMlKQfJ6P/YKFhok+mCsJA8Th4kNZX6o5+bmfPbSPrAMdXVQoPZUfG7vzY1J A1bF8Q8gvYNdVZp4kURkTjYKJ9/S9xLlBwZ2EYxLuwv/j2k5wBhkg0aAW1KOo0TwGvP1 FS5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MgJfeca/4s0satLk61+xOaVoEfLF7ds/Hi2JJEDziWU=; b=p8PoAtct+LtLeaEtkA1ho34KGoTWrcPHjfq09SuZpqWF2/pr9B10L+/7aH8IgUT0jy SbfekFIkI6pzQDtlGcjoxhuF/3NvvfPA7rKMlJMjGUGG+GSqVdaX8Am2PPZ2Pk5YGijw tSujUyGrcQ2VS/qJYxlhmjYsh3qwd0r+e7NIkRjZEtpQ14HVwaW5ieONBkec+whNESpq GVzlj6/TVZYNbWa57UshgIk2ZqJdImFV8HLoO/R5paZi/TujCN42zRBP9aZ0frMO1fXH O88yOfgg9FL2IXgalLHe1MskjSR9iDHYN1gFHcLrht1WSX8Nhm9ZOJb/uPCS2eHbuXSZ l+bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IzmyyaMK; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si3450143edx.366.2020.10.24.08.34.19; Sat, 24 Oct 2020 08:34:41 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IzmyyaMK; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761924AbgJXOMs (ORCPT + 99 others); Sat, 24 Oct 2020 10:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759741AbgJXOMs (ORCPT ); Sat, 24 Oct 2020 10:12:48 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1757C0613CE; Sat, 24 Oct 2020 07:12:47 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id z2so4132841ilh.11; Sat, 24 Oct 2020 07:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MgJfeca/4s0satLk61+xOaVoEfLF7ds/Hi2JJEDziWU=; b=IzmyyaMKU2FOSHtQEv29DmMZ//m10onETt/WtXiLJiW/9Niiew7CKHOfdD0QD+iq0r g8ZU06WwFvjWtyJQhXFsnF/6x0Gm/ir3FAprI+07pbGtdb+FeM7MmjKdUOrn/ta+hCNz bELE3uPLlHqPSdnAfUdnmX6qg+RIoMep0UXSZZxA8ysv+nAeLrtlgclER3WEPFILvFpK nAvM6vXz4BVY0iErk77oeVia6Uo8SaaH0O7ljraTkjq0j/LMPpiKgvtBDxCYJ2xBOvsr lta/5kNNzxFL4BTXBv86WYLJt6KSo/Rki35Gkyce0gLg8q7gCcWN/7Xk8s9pROJmjw0C j2jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MgJfeca/4s0satLk61+xOaVoEfLF7ds/Hi2JJEDziWU=; b=h6Mnb00TalYWmkLjYuTfTBOy6nTqZ59FNkUkXtbWrrCio++eGUKgK0OCVDW6DyDy/z rDpZBqccYqcyOcs9sDSd+LMIofHp9GPjlOnRM7K7LV0pKxxvL5iYbAamCV3Ff2cDHzYX 6hkjtqkxeQc9JigO1XqsmzzpCAXSSCesZIgxb46rtuxbUQ+h6Fx7OJRPqHp7G7U5ZX1U BYmLuphzYP1vMXva058KgJNOEAu4zL6uEOfEf/Vt6hcsXlbKCDsMWBp+D62i8l3XLZJD qTOIlyJM+8ZBHHFdHnQ90cLAkzUwuQXL8zhoCODVnIEcVZnoUqcAPBDuYt+vVRd+EeDR v1TQ== X-Gm-Message-State: AOAM5327aqNlE43vLR4iRBsGEIupwKW0mNMqqBpKq/BUAmiUEpcKOLmF GDINdwnAqxYXa50R4EKBsuEEd55/hM67YiGjxZA= X-Received: by 2002:a05:6e02:d01:: with SMTP id g1mr4895628ilj.246.1603548767191; Sat, 24 Oct 2020 07:12:47 -0700 (PDT) MIME-Version: 1.0 References: <8584c14f-5c28-9d70-c054-7c78127d84ea@arm.com> <20201022075447.GO3819@arm.com> <78464155-f459-773f-d0ee-c5bdbeb39e5d@gmail.com> <202010221256.A4F95FD11@keescook> <180cd894-d42d-2bdb-093c-b5360b0ecb1e@gmail.com> <3cb894d4-049f-aa25-4450-d1df36a1b92e@gmail.com> In-Reply-To: <3cb894d4-049f-aa25-4450-d1df36a1b92e@gmail.com> From: Salvatore Mesoraca Date: Sat, 24 Oct 2020 15:12:36 +0100 Message-ID: Subject: Re: BTI interaction between seccomp filters in systemd and glibc mprotect calls, causing service failures To: Topi Miettinen Cc: Kees Cook , Szabolcs Nagy , Jeremy Linton , "linux-arm-kernel@lists.infradead.org" , libc-alpha@sourceware.org, systemd-devel@lists.freedesktop.org, "linux-kernel@vger.kernel.org" , Mark Rutland , Mark Brown , Dave Martin , Catalin Marinas , Will Deacon , Kernel Hardening , linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 24 Oct 2020 at 12:34, Topi Miettinen wrote: > > On 23.10.2020 20.52, Salvatore Mesoraca wrote: > > Hi, > > > > On Thu, 22 Oct 2020 at 23:24, Topi Miettinen wrote: > >> SARA looks interesting. What is missing is a prctl() to enable all W^X > >> protections irrevocably for the current process, then systemd could > >> enable it for services with MemoryDenyWriteExecute=yes. > > > > SARA actually has a procattr[0] interface to do just that. > > There is also a library[1] to help using it. > > That means that /proc has to be available and writable at that point, so > setting up procattrs has to be done before mount namespaces are set up. > In general, it would be nice for sandboxing facilities in kernel if > there would be a way to start enforcing restrictions only at next > execve(), like setexeccon() for SELinux and aa_change_onexec() for > AppArmor. Otherwise the exact order of setting up various sandboxing > options can be very tricky to arrange correctly, since each option may > have a subtle effect to the sandboxing features enabled later. In case > of SARA, the operations done between shuffling the mount namespace and > before execve() shouldn't be affected so it isn't important. Even if it > did (a new sandboxing feature in the future would need trampolines or > JIT code generation), maybe the procattr file could be opened early but > it could be written closer to execve(). A new "apply on exec" procattr file seems reasonable and relatively easy to add. As Kees pointed out, the main obstacle here is the fact that SARA is not upstream :( Salvatore