Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1251063imm; Wed, 10 Oct 2018 11:27:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV60wLZ2agdJgF9mQhaSlqfSxsMIi2xeiKcfn1c60/tjAzaJhVsogI+90/JQ8psb/wu1BzZku X-Received: by 2002:a62:1bce:: with SMTP id b197-v6mr36177369pfb.102.1539196055023; Wed, 10 Oct 2018 11:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539196054; cv=none; d=google.com; s=arc-20160816; b=Zo0fQrKS71zSWtGi/X4F+HBIEzq8c1kw5f4fML3+vFi9MBoYrHAJKTfHEVfiGnDDgv Lq9/z8DWL8xSrVRRBzwdAnuLkJLPcZNh3iTFDC2Jyg1Kk9YmgChFgdVMkjILCFKJM7KG 10NoIDUyaJZEvG9QbGuv5IT0YV4XKsX48oioW48VaPgKadyXahI8kGyJEWiqb8/+Zv+N q7uCmCiQbRcmpdWeRHL8kR54vMU3SN1T1ToeRcnDWD/I/3DkyAv+Ygq10I9gZDLI9jiS X/NAmQq6kN+pOKR5NUcF+ShNU1V1q7svEJuET/8xzqX0FCW8v5XtutYT6ooljOj13shV VDZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=v+qJ2nhpq0jpyLRsflMa0SxSL8J3mcPs38ogmv/TZnw=; b=BUzQmUyYiZ1hG6o1oDDHQhcwvRK0zoDF8tbdFcx7zJVxUVuXGK3MbNpep0yLwsVaSo dC4eeML61PUbe9x2zw+nhv7hYkH9fnLdphE41Z6aU3wJrd4B0AjvCs8v6EhHtTyFbuxv I+hT1GJAWXr3hj/iW/FNDglM6W0NIoCsPiZzqvVFM5wr8TVBrzoQ8/xVgTL35gyFACsp w9qbUARnl/YH47MyDvTVKGgidhThDlbknXQFKo+kIkKFm9IBueQqvZsi9Ak8vjub2Zj9 g/CAlYM/5evDi6X4ltoxuCv1a5XtXDS7kFYoHUZDYmH8l937/1Py1wkUhjWXxHoAb6D3 hzKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=bQs8HRss; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2-v6si19429923pgc.573.2018.10.10.11.27.20; Wed, 10 Oct 2018 11:27:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=bQs8HRss; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727781AbeJKBuA (ORCPT + 99 others); Wed, 10 Oct 2018 21:50:00 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39970 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727753AbeJKBt7 (ORCPT ); Wed, 10 Oct 2018 21:49:59 -0400 Received: by mail-wm1-f65.google.com with SMTP id z204-v6so6800188wmc.5 for ; Wed, 10 Oct 2018 11:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=v+qJ2nhpq0jpyLRsflMa0SxSL8J3mcPs38ogmv/TZnw=; b=bQs8HRssRdZ5L7O3609J9m+1ERciHxnFrH5EPpZ67mKwSVyUaWdE8SiAfC+qdbPui8 n4damocFPWwpwtC84ikjCyBU/JsvBUbtJNKJbvObk1LGcD86j+5pAB+f0MQ/4/fBl2Eq O9EtsoMWddC8jJMs6L9SfZYLg88YYl6+h0ezmrxE9dPnriKISuoM4naTdNUZjWyXYujv vj/fZVpUpzjoJ9htroJfTbjOjSr+0gshJ22n/84upTwv52B2gK6BdgGer4r16aJ6oDxn SvlqEjIZu1UTpWPiyuVVvcCu42dNm4mwK8AtJDiIZTGBbuaH1oZXIe+spv8yXuyytPRS Qe6Q== 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:user-agent; bh=v+qJ2nhpq0jpyLRsflMa0SxSL8J3mcPs38ogmv/TZnw=; b=JQh6axj6QkMhqIQLwHjWXzhjoxeYanDJaZVyq7NcMYW2k7s7SLXNJQPUonFVg2jOIN +oLyhwNeE6md91Kg8nvIWZAE9Hz+1MNCffi4hVxW6p0orhcvD4RYX4+WcS/z4OUBl0FG VvUPKzhySCeCiHaTkSE1PM0M9RXYTNG2gmJizWjGZj+5vv+vq4pNt4C5yZOsRXpxi7aK XbX6A0RziaX5TaSQOkE2QBW4yn+e6y+Pb8sjVzfkeVHAA5hx+Rnj9aNmEJ1BvfNutVaM tTZTankCmdV3WMLYnwI3LofINZYY7R+DusWe9sIEaUniyYpGZ24dSocYjUp3UH4IWSA/ QPTg== X-Gm-Message-State: ABuFfojGuLZ6QVzkH1yZ/5dzS/O14n/hAWRsx0nZUbuanreiQnilBCGt u8zaXEE9RZv/gcE0risyizDuCA== X-Received: by 2002:a1c:930c:: with SMTP id v12-v6mr1932741wmd.9.1539195996992; Wed, 10 Oct 2018 11:26:36 -0700 (PDT) Received: from brauner.io ([2a02:8070:8895:9700:8197:8849:535a:4f00]) by smtp.gmail.com with ESMTPSA id j128-v6sm15730600wmb.43.2018.10.10.11.26.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Oct 2018 11:26:36 -0700 (PDT) Date: Wed, 10 Oct 2018 20:26:30 +0200 From: Christian Brauner To: Andy Lutomirski Cc: Tycho Andersen , Kees Cook , Jann Horn , Linux API , Linux Containers , Akihiro Suda , Oleg Nesterov , LKML , "Eric W. Biederman" , Linux FS Devel , Christian Brauner Subject: Re: [PATCH v7 3/6] seccomp: add a way to get a listener fd from ptrace Message-ID: <20181010182628.hgprnywup4wgmycg@brauner.io> References: <20180927151119.9989-1-tycho@tycho.ws> <20180927151119.9989-4-tycho@tycho.ws> <20181008151629.hkgzzsluevwtuclw@brauner.io> <20181008180043.GE28238@cisco.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 10, 2018 at 10:45:29AM -0700, Andy Lutomirski wrote: > On Mon, Oct 8, 2018 at 11:00 AM Tycho Andersen wrote: > > > > On Mon, Oct 08, 2018 at 05:16:30PM +0200, Christian Brauner wrote: > > > On Thu, Sep 27, 2018 at 09:11:16AM -0600, Tycho Andersen wrote: > > > > As an alternative to SECCOMP_FILTER_FLAG_GET_LISTENER, perhaps a ptrace() > > > > version which can acquire filters is useful. There are at least two reasons > > > > this is preferable, even though it uses ptrace: > > > > > > > > 1. You can control tasks that aren't cooperating with you > > > > 2. You can control tasks whose filters block sendmsg() and socket(); if the > > > > task installs a filter which blocks these calls, there's no way with > > > > SECCOMP_FILTER_FLAG_GET_LISTENER to get the fd out to the privileged task. > > > > > > So for the slow of mind aka me: > > > I'm not sure I completely understand this problem. Can you outline how > > > sendmsg() and socket() are involved in this? > > > > > > I'm also not sure that this holds (but I might misunderstand the > > > problem) afaict, you could do try to get the fd out via CLONE_FILES and > > > other means so something like: > > > > > > // let's pretend the libc wrapper for clone actually has sane semantics > > > pid = clone(CLONE_FILES); > > > if (pid == 0) { > > > fd = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER, &prog); > > > > > > // Now this fd will be valid in both parent and child. > > > // If you haven't blocked it you can inform the parent what > > > // the fd number is via pipe2(). If you have blocked it you can > > > // use dup2() and dup to a known fd number. > > > } > > > > But what if your seccomp filter wants to block both pipe2() and > > dup2()? Whatever syscall you want to use to do this could be blocked > > by some seccomp policy, which means you might not be able to use this > > feature in some cases. > > You don't need a syscall at all. You can use shared memory. Yeah, I pointed that out too in the next mail. :) > > > > > Perhaps it's unlikely, and we can just go forward knowing this. But it > > seems like it is worth at least acknowledging that you can wedge > > yourself into a corner. > > > > I think that what we *really* want is a way to create a seccomp fitter I thought about this exact thing when discussing my reservations about ptrace() but I didn't want to defer this patchset any longer. But I really like this idea of being able to get an fd *before* the filter is loaded. > and activate it later (on execve or via another call to seccomp(), > perhaps). And we already sort of have that using ptrace() but a > better interface would be nice when a real use case gets figured out.