Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp96763pxx; Wed, 28 Oct 2020 19:32:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw150y46LT6mWujXn2pcplVtQtodoHR0hbDh4E8s7hdqx69wnC0MuelV71wpXioGrxoZMxH X-Received: by 2002:a17:906:1804:: with SMTP id v4mr2007958eje.201.1603938756189; Wed, 28 Oct 2020 19:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603938756; cv=none; d=google.com; s=arc-20160816; b=w6mRVw8x/kCBXznH8NAnmvZEfIyyznmWEfrS2mJRP5FXBx5ha1y7fnfMqkENCc/iYQ 4f/aOgN6okXQn7WDNVwEt/G3Dj/TEJQ45bYxyRyZfMx6OQrb1/Yc3WODQzHBjJVfjBIE FievWwvN5kp+pLScE2jK8pJPyLWjMbie7xuln/Hn9Blnu5/dqcecV4L2yLlC0lYoPMvv szEpe0BBUEukYI+5awgdE6LYJKoamKK9x5KEVXpRNLtAUUzInfw5NaAFmAldnys6w0ri DrRNVz7sQDT3vxsh9QxCNnQmiLkzEXOmSMI8FBTq2X1O5dYdzVI3eklKA+MehRxAeLDb C1lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bjquVTg1vMGERBSVsx8hHAMGf4NyHc67uQM/Ixwtgw8=; b=dTyoiagyh0eXkGtzKHQQt/TJNDhUziXcVuVs+0+/FSncBxdyfARH799Gw74eQBhLFc Ybmd3i8yRYeDt86nzMRyjP2q+WSq2xHgCLhWebJj46TNOxGtO9dW+pi0wStzXan8y2IF pba33HvuZZnmVnsQgpC07l5gF632c+gyElHbGG1h5MXG2Pm5WUU3/qZuHeBwTZg6FynS UgLJdnfEUuZSdkC9CiY7lLf1XX+1o8w/83VEOxObrpbxuKWglkgF4Yrvf+t7tHa2GdU0 cPGnNwiYkKtdOJHLm8ENU08CQDXL2WrxHZ9+oytCXK6ik6udCGOGze/VVgUWczW30J4l wCEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XrpoH18j; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x4si804776ejf.537.2020.10.28.19.32.14; Wed, 28 Oct 2020 19:32:36 -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=@chromium.org header.s=google header.b=XrpoH18j; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729750AbgJ1WDj (ORCPT + 99 others); Wed, 28 Oct 2020 18:03:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729410AbgJ1WDQ (ORCPT ); Wed, 28 Oct 2020 18:03:16 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B0CFC0613CF for ; Wed, 28 Oct 2020 15:03:16 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id 13so600040pfy.4 for ; Wed, 28 Oct 2020 15:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bjquVTg1vMGERBSVsx8hHAMGf4NyHc67uQM/Ixwtgw8=; b=XrpoH18jr6+Aub7KdGNof7lm6+3iGUHCOkI5ourgPjqCfhpM3nXHbXRrtervIYc1xJ mEjhqg3Loymiacra4gcaRACenTlv1H1cNLD79EtxY1nFgyeIVYXfulEdBUjc3JPv2Leg 7jRhb5cyhKQnhByykHaqPhUIhdyqAq7hbWKX8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bjquVTg1vMGERBSVsx8hHAMGf4NyHc67uQM/Ixwtgw8=; b=Q8NNc6sXBoMWplTg6X67krLtJi/qm+DHgniQpfp+OVoUposXIx9qnhD1ssWUMO4E65 Ov3GCH/fEKlcxD83HjXZAjUEhmjXHT7xr7vyFhFqL2qIkt+dGXoNqCle+Ypcue24ScBF 2qziriR8CbBsCtL5OaKYRUfbpD4vShx47433JvnnnR5eRf3P117MWYnig1fIh+OFhubM aI7odR9k+aE/BGPcb4Md/LJQkNFuuPZ/YB0yGn5nhmjkH470SW//Hkc33HRzAWSTs1iz eqWYKl1OtrTeHUtp3AOXC5SsiwfJSnDoc3QlVgrpgfV7m/YO30sEH/D0pg0x+QodsH1e 39NQ== X-Gm-Message-State: AOAM531k9F6tOTVGRdCBY3ZfwcmSzixZP1cp/3w6em4nfbXbR+5UhI5i g6HXBZK6Q0wyP7hKYbTHM+Vj4g== X-Received: by 2002:a17:90a:1b88:: with SMTP id w8mr953912pjc.130.1603922595791; Wed, 28 Oct 2020 15:03:15 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c10sm549509pfc.196.2020.10.28.15.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 15:03:14 -0700 (PDT) Date: Wed, 28 Oct 2020 15:03:14 -0700 From: Kees Cook To: Rich Felker Cc: Jann Horn , Camille Mougey , lkml , Tycho Andersen , Sargun Dhillon , Christian Brauner , "Michael Kerrisk (man-pages)" , Denis Efremov , Andy Lutomirski Subject: Re: [seccomp] Request for a "enable on execve" mode for Seccomp filters Message-ID: <202010281500.855B950FE@keescook> References: <20201028164936.GC534@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201028164936.GC534@brightrain.aerifal.cx> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 28, 2020 at 12:49:36PM -0400, Rich Felker wrote: > On Wed, Oct 28, 2020 at 01:42:13PM +0100, Jann Horn wrote: > > +luto just in case he has opinions on this > > > > On Wed, Oct 28, 2020 at 12:18 PM Camille Mougey wrote: > > > From my understanding, there is no way to delay the activation of > > > seccomp filters, for instance "until an _execve_ call". > > > [...] > > > I only see hackish ways to restrict the use of _execve_ in a > > > non-cooperative executable. These methods seem globally bypassables > > > and not satisfactory from a security point of view. > > > > You're just focusing on execve() - I think it's important to keep in > > mind what happens after execve() for normal, dynamically-linked > > binaries: The next step is that the dynamic linker runs, and it will > > poke around in the file system with access() and openat() and fstat(), > > it will mmap() executable libraries into memory, it will mprotect() > > some memory regions, it will set up thread-local storage (e.g. using > > arch_prctl(); even if the process is single-threaded), and so on. > > > > The earlier you install the seccomp filter, the more of these steps > > you have to permit in the filter. And if you want the filter to take > > effect directly after execve(), the syscalls you'll be forced to > > permit are sufficient to cobble something together in userspace that > > effectively does almost the same thing as execve(). > > I would assume you use SECCOMP_RET_USER_NOTIF to implement policy for > controlling these operations and allowing only the ones that are valid > during dynamic linking. This also allows you to defer application of > the filter until after execve. So unless I'm missing some reason why > this doesn't work, I think the requested functionality is already > available. Oof. Yeah, that's possible, but I view it as kind of not the point of USER_NOTIF -- I'd rather design a workable solution for the delayed-apply case. -- Kees Cook