Received: by 10.213.65.68 with SMTP id h4csp93605imn; Thu, 15 Mar 2018 10:31:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELseauxMaB9x1xytkvSlErEtjoIi/SGl4F3q1wGAaHMrb3LITY7lepaHQF5VoGh3zAG9MkAx X-Received: by 2002:a17:902:6f17:: with SMTP id w23-v6mr9209631plk.336.1521135117624; Thu, 15 Mar 2018 10:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521135117; cv=none; d=google.com; s=arc-20160816; b=UGSZym+LYeSee+0GO/+3QDxDwe19kEptVkMHYN6zkRWNVCNjXeCRRMz3dKwCpuso+w nSx1/APxDWTfTkfNMIY/IqtCklffiGjvndCU96K0xMNSBZFZVu7q8mWZzcTh2Fc4qZu9 tw+EGMMNy2dFHeLeiaeY/MFsLPLZHYfneuv1zVOIpD/OdGRHt6bumzNGL7tIHcdXuc3y phnQimKXf22tfqct7BKdr4XCy339ZerOpHseabshlqLhfqxx78lOm+bst48QCvfi68GD hOi7PrdNxmV6Y2jeB1NRm2//fSCmFK2ziOTkPtM2UW0JnFvHHxdkiABUepA+aRkt0k5S G1wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=XbAfVWDl/cmDOSs59S5Aau0zSzQ5iCMPKREl5Mf7vHo=; b=Hipp2+beQsGMzj3C/HRfq0uFQAj/XRJmZozssppXb2ofLKtirdBizwFu33q+RB791J TqSHEdM3VdXHS3OhmCn11d2wWor5io1Ulpvs/ggGdHuEg7SFgp5UcaF9nUjnnOfUJbUO 7EodcojxdE5kaVNuVe4vIW0tyy575D+ohjbR4BijwzCRtoLfuvxNKKWbKYtmvMggfbQG ofyCbDiautFz4YoDv0x1VzwTwPdvoKFnGiNg+r1ffOx2HvgIwNKtLA0TQ2bnjuapy70C wftscN0xaP/oRVTyhRbbaZ9BF9nEVXBut606Z7Ap3XksoVE8NhUvAMgPowwbSnHirwwx kpQg== ARC-Authentication-Results: i=1; mx.google.com; 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 s76si3096270pfa.105.2018.03.15.10.31.41; Thu, 15 Mar 2018 10:31:57 -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; 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 S1751834AbeCORae (ORCPT + 99 others); Thu, 15 Mar 2018 13:30:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbeCORad (ORCPT ); Thu, 15 Mar 2018 13:30:33 -0400 Received: from mail-it0-f43.google.com (mail-it0-f43.google.com [209.85.214.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 851C8217D4 for ; Thu, 15 Mar 2018 17:30:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 851C8217D4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org Received: by mail-it0-f43.google.com with SMTP id v194-v6so10168580itb.0 for ; Thu, 15 Mar 2018 10:30:32 -0700 (PDT) X-Gm-Message-State: AElRT7FC6QNKSgVUlC6QVfUJ+Z9W5AbSeMSW1VuFc2VVMnPNZfgqJ4Pp S7zJLQONFy1g76H46udDvOsKqUm4Y648ZJPXWYOtXw== X-Received: by 10.36.48.193 with SMTP id q184mr2774623itq.54.1521135031741; Thu, 15 Mar 2018 10:30:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.137.101 with HTTP; Thu, 15 Mar 2018 10:30:11 -0700 (PDT) In-Reply-To: <20180315172558.GA28108@gmail.com> References: <20180315170509.GA32766@mail.hallyn.com> <20180315172558.GA28108@gmail.com> From: Andy Lutomirski Date: Thu, 15 Mar 2018 17:30:11 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 0/3] seccomp trap to userspace To: Christian Brauner Cc: Andy Lutomirski , "Serge E. Hallyn" , Tycho Andersen , LKML , Linux Containers , Kees Cook , Oleg Nesterov , "Eric W . Biederman" , Christian Brauner , Tyler Hicks , Akihiro Suda Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 15, 2018 at 5:25 PM, Christian Brauner wrote: > On Thu, Mar 15, 2018 at 05:11:32PM +0000, Andy Lutomirski wrote: >> On Thu, Mar 15, 2018 at 5:05 PM, Serge E. Hallyn wrote: >> > Quoting Andy Lutomirski (luto@kernel.org): >> >> On Thu, Mar 15, 2018 at 4:09 PM, Christian Brauner >> >> wrote: >> >> > On Sun, Feb 04, 2018 at 11:49:43AM +0100, Tycho Andersen wrote: >> >> >> Several months ago at Linux Plumber's, we had a discussion about adding a >> >> >> feature to seccomp which would allow seccomp to trigger a notification for some >> >> >> other process. Here's a draft of that feature. >> >> >> >> >> >> Patch 1 contains the bulk of it, patches 2 & 3 offer an alternative way to >> >> >> acquire the fd that receives notifications via ptrace (the method in patch 1 >> >> >> poses some problems). Other suggestions for how to acquire one of these fds >> >> >> would be welcome. >> >> >> >> >> >> Take a close look at the synchronization. I think I've got it right, but I >> >> >> probably don't :) >> >> >> >> >> >> Thanks! >> >> >> >> >> >> Tycho Andersen (3): >> >> >> seccomp: add a return code to trap to userspace >> >> >> seccomp: hoist out filter resolving logic >> >> >> seccomp: add a way to get a listener fd from ptrace >> >> >> >> >> >> arch/Kconfig | 7 + >> >> >> include/linux/seccomp.h | 14 +- >> >> >> include/uapi/linux/ptrace.h | 1 + >> >> >> include/uapi/linux/seccomp.h | 18 +- >> >> >> kernel/ptrace.c | 4 + >> >> >> kernel/seccomp.c | 467 ++++++++++++++++++++++++-- >> >> >> tools/testing/selftests/seccomp/seccomp_bpf.c | 180 +++++++++- >> >> >> 7 files changed, 653 insertions(+), 38 deletions(-) >> >> > >> >> > Hey, >> >> > >> >> > So, I've been following the discussion silently in the background and I >> >> > see that it got sidetracked into seccomp + ebpf. While I can see that >> >> > there is value in adding epbf support to seccomp I'd really like to see >> >> > this decoupled from this patchset. Afaict, this patchset would just work >> >> > fine without the ebpf portion (but I might be just have missed the >> >> > point). So if possible I would like to see a second version of this with >> >> > the comments accounted for and - if possible - have this up for merging >> >> > independent of the ebpf patchset that's floating around. >> >> > >> >> >> >> The issue is that it might be (and, then again, might not be) nicer to >> >> to *synchronously* call out to the monitor in the filter. eBPF can do >> >> that very cleanly, whereas classic BPF can't. >> > >> > Hm, synchronously - that brings to mind a thought... I should re-look at >> > Tycho's patches first, but, if I'm in a container, start some syscall that >> > gets trapped to userspace, then I hit ctrl-c. I'd like to be able to have >> > the handler be interrupted and have it return -EINTR. Is that going to >> > be possible with the synchronous approach? >> >> I think so, but it should be possible with the classic async approach >> too. The main issue is the difference between a classic filter like >> this (pseudocode): >> >> if (nr == SYS_mount) return TRAP_TO_USERSPACE; >> >> and the eBPF variant: >> >> if (nr == SYS_mount) trap_to_userspace(); >> >> I admit that it's still not 100% clear to me that the latter is >> genuinely more useful than the former. > > We've just discussed this on irc and the fact that most problems can be > addressed by interfaces we already have makes it questionable what ebpf > brings to the game here. Especially since the discussion gave the > impression that if ebpf ever makes it to seccomp it will basically be > because it allows a nice implementation of the trap to userspace. If > it's even unclear whether it is really the better choice for this task > then we could consider to no try and make this patchset use it. (I > probably sound way more polemic than I intend to.) > No argument from me. To be clear, I don't think that trap to userspace should block on eBPF at all. It was just a coincidence that both patches showed up around the same time, and if they actually work well together, then it could make sense to combine them. But if trap to userspace ends up working perfectly without eBPF, that's fine too.