Received: by 10.213.65.68 with SMTP id h4csp83542imn; Thu, 15 Mar 2018 10:12:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELtIFKcLbLrr/UheDBygBMdMnh4J/lRSnu+PW4zwbYQC6bu2c0MXxc0lT53UttXu/2CmWDpO X-Received: by 10.99.158.81 with SMTP id r17mr4067298pgo.348.1521133977615; Thu, 15 Mar 2018 10:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521133977; cv=none; d=google.com; s=arc-20160816; b=QjY+QKbdfH4leuaUqT+4nCndIy4tcnHAxICelrwkjd9c4Szq5PKoBMo/1+HPyocSb/ yA6m9kefit2efWfvozeunBkW5hYysF7DHzmvusdMIKIjExBBm+ZitlHWfggfdd5qADGg 6gptAiSD3V+Wsrwi8z8m73AuoIfoTEJs89vZ4Bcn59JlBeRYzUCFtzutNY88eIC5SSlX FWJb+f7R85Mvwn2qrSgSmDQ0lZYdbhLRLlHtwieTFyFpWy9K5Drg/A8GJ3fcSgvomecL rYu7LFXKCiPjM2NbLgD5TEL9BcmF32MVV/xqdoPXii/YakU40baetzj3gD9UlTH/MO1f 2VZQ== 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=YSdaFE9C/V/xmFpA3YVvQbqjwJ6PE0GbFW9F6Eb6WRY=; b=d3MdXqv4n9JFmEmr1Y+U7UETC7Wj4vAk3zR4nv1WvvDtuUvs2kMDxiolybeJGYlKBc z0Wdy01VrUjKm3eL+aaoxtpATLYgSpJhJEmK7EV5Kx2YfQhAt57imbMnuoGli196+/cS yVjbFB2qGrAazC+esyE5n1spN1YD8PXl9o8Nlw5V1etbuS5VsRrieWolw8+dwKv/i7b8 c6NCCfaDF9sqHJR1ezCsBDJoNQgK/0KzBPD3e15BjZIQ6aaL++87AjDxenAlasy3HArL RWAHpWeNFBBi06nIvGNX7TBu1mJ/Ki+tOOwAuErp3jbB4c4n05x+zHn7DOvqqOdE7ahZ tepw== 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 t9-v6si4279502plq.321.2018.03.15.10.12.43; Thu, 15 Mar 2018 10:12: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 S932383AbeCORLz (ORCPT + 99 others); Thu, 15 Mar 2018 13:11:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:46220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751549AbeCORLx (ORCPT ); Thu, 15 Mar 2018 13:11:53 -0400 Received: from mail-it0-f41.google.com (mail-it0-f41.google.com [209.85.214.41]) (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 22F22217D2 for ; Thu, 15 Mar 2018 17:11:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22F22217D2 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-f41.google.com with SMTP id d13-v6so10023067itf.0 for ; Thu, 15 Mar 2018 10:11:53 -0700 (PDT) X-Gm-Message-State: AElRT7HTCZ/aVRcWvN0YgNKpybdYLxsMuKTlqhIHUPteu+QtJAjvUsPI +PYmUbOhm6TWizgOtX2neLUB+JCJ2IefCUrxGJ7+jA== X-Received: by 10.36.48.193 with SMTP id q184mr2708211itq.54.1521133912476; Thu, 15 Mar 2018 10:11:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.137.101 with HTTP; Thu, 15 Mar 2018 10:11:32 -0700 (PDT) In-Reply-To: <20180315170509.GA32766@mail.hallyn.com> References: <20180204104946.25559-1-tycho@tycho.ws> <20180315160924.GA12744@gmail.com> <20180315170509.GA32766@mail.hallyn.com> From: Andy Lutomirski Date: Thu, 15 Mar 2018 17:11:32 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 0/3] seccomp trap to userspace To: "Serge E. Hallyn" Cc: Andy Lutomirski , Christian Brauner , 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: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. The case where I think the synchronous function call is a huge win is this one: if (nr == SYS_mount) { log("Someone called mount with args %lx\n", ...); return RET_KILL; } The idea being that the log message wouldn't show up in the kernel log -- it would get sent to the listener socket belonging to whoever created the filter, and that process could then go and log it properly. This would work perfectly in containers and in totally unprivileged applications like Chromium.