Received: by 10.213.65.68 with SMTP id h4csp96788imn; Thu, 15 Mar 2018 10:37:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELsnEobJ3qwK+W5ysthvtyoWSZBT25Nmz9K1zPqmV6RefeIFdsPHTGweEyoJ2hBb+j4HzUxy X-Received: by 2002:a17:902:9a08:: with SMTP id v8-v6mr9028522plp.252.1521135472663; Thu, 15 Mar 2018 10:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521135472; cv=none; d=google.com; s=arc-20160816; b=DXrQ5um67/UIQ3o0P4mJk21CHDeiX9NIDaoVOzMcBKWEyYQSHK+hz7jibT8E7Ms6pR cR/DTgHzabD5A9Hv3dxnsFx84SjBgayNbDwICAbvWvvkVf9BKZE0/SbxdKpI0SNuzfE+ o4gK08y2cbCuO0jB7V9d9iKffNdL2uFnKXgJzxDYIY3+ya4NZ9darglyNcXqSCmu4EC+ 4hNYqlG71c3rEy4tOToia3jifSxgEji+47zOUEZfbqCDfnKGiPWYr2AsCrBMFxPYRZpR 9GjxxkPWxQxBr1ol2Kz7lUTy4zgyrM3Kah6qD2Gg9dPQaDKBkIRFh4VLCNCU0tUGIu8g 8Cdg== 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:arc-authentication-results; bh=VnY9DlnTDka74LrwzW06/Q7Yysry0HJfAg5nku+Sucs=; b=SMw0V1MfcGmi4arzww4H0ehe4Rm4PeUCTRqpV58p5EZ0qgHMxbl2nGYOSUuHtPVhkW s11vjUBj+RUps2tBpyDK0xDw5bqMBqrNd4efOwU97Vx2fOwgutRb6XKSdjUXSw6iEE2q bVsksYoqKgpiB9+xQnAvUrzr/21SaSCN8/AHBXsaUVK0U1qgwPyWPx+QVVNIy9AtLLix OsQ70HglRCxyasX2OwO44Apuk3v3hj4KaJYog6tGJxhqVeJ5m2/2fF55NUmx3f5ldkuX TIwVa5FpDIgvN7UoYXYRKsuZMTEcIm//VcqIzhU+jXf0gqdunijGR2hXpPSgy0xMWc/f t7Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=pH01M1Ib; 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 1-v6si4311815plv.375.2018.03.15.10.37.38; Thu, 15 Mar 2018 10:37:52 -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=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=pH01M1Ib; 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 S1752684AbeCORf2 (ORCPT + 99 others); Thu, 15 Mar 2018 13:35:28 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:38135 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751714AbeCORf0 (ORCPT ); Thu, 15 Mar 2018 13:35:26 -0400 Received: by mail-it0-f67.google.com with SMTP id j7-v6so10152069ita.3 for ; Thu, 15 Mar 2018 10:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VnY9DlnTDka74LrwzW06/Q7Yysry0HJfAg5nku+Sucs=; b=pH01M1IbG55ZyFQ5uOoGkOnFCuJyf4z1hX6SWglS04yZKaOyPJgahPUY9mC2td9d9p Vw23ISdc2kuvINq+tWnoCuIfug8V63SSrOA/ULrUunjUDDfRhxlLpyhKKx3C52/ZkYcr r4tP2flbP+tneyHs0GaqiTSbB5lOBaGzITpPF/HSmfpLP1EpqK9VDGkUgDx6fer8JFji vtXN0cSfdMc2N5A7KkWxRG5quexCU3kaKUvOsCQJivUS2ehafpGipT4FBvvH1asemilU z+85+13pqX8krYU3Ra4/s2V9cm0djFK6WBynPz7zCf0D987TcPu/M5KCqGyH/iXOKsJA OhZQ== 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=VnY9DlnTDka74LrwzW06/Q7Yysry0HJfAg5nku+Sucs=; b=ZBpie1yjiE7f9KCuKO5UutL2Dh/9GAJonVjt4vEv62rxE1jM89rBzA8yhCALqvA+Sb HIc07OyV1SqkibKtBUHVgncwqAdGBJSbrFp1UlHE/fbFPfMIUiM9cbqTUP+lki4vfjZ6 lHjKG7G0/WtXiFlrA0uWKdtOE9pOf4FJtWfp8aFXHeqOqZWSaHJrbjSz377K3/LZWh7p 8Em9ceWUVfcwDYXTehobsDnvbUn56E9w+8ZWdn4D74xRBZADGPFHY0u2u5crUFOH0JOX yF6LOw089z4w81qNPAAh+Cth/k7JkzX7SZ10Mkxr8HVXkK8CB/6739tqTyT1BJPEbFmn Bnhw== X-Gm-Message-State: AElRT7FBbemV5TxIjv1iJsbksAkwJj9Ig5VhOW6a4WbqbntAjHluiJvs sQzcNhoUuSP8K1iM396dbXK0gw== X-Received: by 10.36.54.144 with SMTP id l138mr7202520itl.14.1521135325531; Thu, 15 Mar 2018 10:35:25 -0700 (PDT) Received: from smitten ([8.24.24.129]) by smtp.gmail.com with ESMTPSA id t6sm3856588iof.53.2018.03.15.10.35.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Mar 2018 10:35:24 -0700 (PDT) Date: Thu, 15 Mar 2018 11:35:24 -0600 From: Tycho Andersen To: Andy Lutomirski Cc: "Serge E. Hallyn" , Christian Brauner , LKML , Linux Containers , Kees Cook , Oleg Nesterov , "Eric W . Biederman" , Christian Brauner , Tyler Hicks , Akihiro Suda , Alexei Starovoitov Subject: Re: [RFC 0/3] seccomp trap to userspace Message-ID: <20180315173524.k7vwnvnhomg2j5yv@smitten> References: <20180204104946.25559-1-tycho@tycho.ws> <20180315160924.GA12744@gmail.com> <20180315170509.GA32766@mail.hallyn.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, 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: > > 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(); Sargun started a private design discussion thread that I don't think you were on, but Alexei said something to the effect of "eBPF programs will never wait on userspace", so I'm not sure we can do something like this in an eBPF program. I'm cc-ing him here again to confirm, but I doubt things have changed. > 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. The current implementation can't do exactly this, but you could do: if (nr == SYS_mount) { log(...); kill(pid, SIGKILL); } from the handler instead. I guess Serge is asking a slightly different question: what if the task gets e.g. SIGINT from the user doing a ^C or SIGALARM or something, we should probably send the handler some sort of message or interrupt to let it know that the syscall was cancelled. Right now the current set doesn't behave that way, and the handler will just continue on its merry way and get an EINVAL when it tries to respond with the cancelled cookie. Anyway, I think these last two points can be addressed with the approach from this series. The notification to the handler about a cancelled syscall might be slightly awkward, but I'll take a look. Cheers, Tycho