Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4536375imm; Tue, 11 Sep 2018 13:31:01 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaj2GQYSUwKGE91d4a/i5MNVt2Y4DjxRTB2zrB1YBBx+wvMoYYa48b6X5y8OBaIE434jlOR X-Received: by 2002:a63:b507:: with SMTP id y7-v6mr30681781pge.425.1536697861095; Tue, 11 Sep 2018 13:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536697861; cv=none; d=google.com; s=arc-20160816; b=WVyHeCinhqUBwdxKBycWG0sc+AjgnCmgf1dsnBBaUjcGg4f4m2RnZDBKkim6zKJz2p Eu5dICoeLkiOi7Hvs86eiTtaRx6jxNX1hWdJSmiSWXt/dz+5h9RrowD6IidqCr9iKjuf ftVZTInqnRIMXJ4e6FFTAMPX8NJ2IcOWmtI76DS+YVXcfusxyz3vHgJOQo1cIZpAPIY4 cRV5x3NMQVSP01eIdFawVti8GOrn5gND76bcuBASAXsSFmOJRYC2d7yWM9OS0230ZDmY +Vbtiw5LncP9M1Ilyd0o0YRRh+yli7pz3WTjEW2F6f22bMl9R6Xy+ekRPh9NkZayK0w/ dqpw== 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=LPhGsIHjf7EgVEmAOdZo0zwEu84/eXjx7dDE3FxUxvk=; b=UhDul1cfP2jo2AQkGM+VVesIdMgqz63uy4tl5ajpTy+t67S/L7uD8bXX5WIvZQc1fl /kGbvYcMbjRePHtc+gFsKF9I3k9WhwFOyxVTGA9E/3+3uKL60Ld0ywqLpo1wbrbJ6YBq PNm194Thbbo/ipPEScQz/GJNajd90FovaZ/tYxDSw9l41WVgSXpdsOx3acqaBNf5sLGs u1JjZ7ZiHjLqVCgckc4NdnPQIDZDPp5p8DPVSONRgP5afWAvjxMtVxssk/Jo2k3Dyrht 9aUnqybnY3mFqS6qqpT0H7j+Cheo15BuUkKzw9dtqzaTFUkMsc7844qgD+ZK00vsbS2a tzNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=U4q2uuyC; 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 y22-v6si21077846pgj.436.2018.09.11.13.30.45; Tue, 11 Sep 2018 13:31:01 -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=U4q2uuyC; 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 S1727762AbeILBaw (ORCPT + 99 others); Tue, 11 Sep 2018 21:30:52 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:46541 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726730AbeILBaw (ORCPT ); Tue, 11 Sep 2018 21:30:52 -0400 Received: by mail-ed1-f67.google.com with SMTP id k14-v6so20258033edr.13 for ; Tue, 11 Sep 2018 13:29:53 -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=LPhGsIHjf7EgVEmAOdZo0zwEu84/eXjx7dDE3FxUxvk=; b=U4q2uuyClpFU9iFcqpu9Yb6m+RwawpuSkNwOXrht2WbP1IjUeHflKiJlfSoNtZ3JSd K4QM+9qqH1GvHcEV0Q9SK0bkRXWAhOJWgikR7sml432dizjARQnP519WgDKO0mFturQN /7WjhY5QvG6FKx37DEgdVAsTzyDraPqb+x0KPyxQ+Y0+9IY0G1mPhloNx2/avDCv1vS3 1F+oC+QdRwo03CharcMEKX40hGBA4Bng/jP1gPVARveFK6GbbhUmnLRcjOYULmpml25v skNtXnzodr2dFATtPGZEdxfn3eyqhdhs7zZfmr/sV1bZdUXzYVuVy/FI4LG9viM8r6tT siRw== 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=LPhGsIHjf7EgVEmAOdZo0zwEu84/eXjx7dDE3FxUxvk=; b=rRQSITD87X7Z1us7FfrYlwwIbIHaoOM8oyH9bBl0+2PgovN/Darvr7XrJfNzSl9LvE lFLHg8UCKMDaKWP2H09EdMngV7EhXi0QSN5GzS4TRhfZeAlCloJLmTZ1MeONyTr6SrqC LANiQsBA7QkCrWA8ma1nxkfPhenZgrnIM8PzPAiNT0KklYKLAgPT3ibIc5oCqdTFo5pq G6a/oh1UrAL1ELyXOW7grbhqyKE20Ner6ua8FU1jSg3bHHJg2sfV8x2yzM656A+cKkir 05qcMbK1iCKMM3/+xQliK/ZTRStHyI3yFfPmJlhdrkT/spBSlPFJW+QWS3LC5BXpAbYC g9lg== X-Gm-Message-State: APzg51DNmp2pIZfeaTH8/FqEQ7cKaHQgh5YT6rVWj8F18SvVjTbeLJlL qvCqcaRd3Nr5fAoQ+P7TCFcVNQ== X-Received: by 2002:aa7:c40a:: with SMTP id j10-v6mr30191152edq.134.1536697793039; Tue, 11 Sep 2018 13:29:53 -0700 (PDT) Received: from cisco.cisco.com (85-220-54-220.dsl.dynamic.simnet.is. [85.220.54.220]) by smtp.gmail.com with ESMTPSA id l48-v6sm10826055eda.94.2018.09.11.13.29.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Sep 2018 13:29:52 -0700 (PDT) Date: Tue, 11 Sep 2018 14:29:49 -0600 From: Tycho Andersen To: Jann Horn Cc: Kees Cook , kernel list , containers@lists.linux-foundation.org, Linux API , Andy Lutomirski , Oleg Nesterov , "Eric W. Biederman" , "Serge E. Hallyn" , Christian Brauner , Tyler Hicks , suda.akihiro@lab.ntt.co.jp Subject: Re: [PATCH v6 4/5] seccomp: add support for passing fds via USER_NOTIF Message-ID: <20180911202949.GG3444@cisco.cisco.com> References: <20180906152859.7810-1-tycho@tycho.ws> <20180906152859.7810-5-tycho@tycho.ws> <20180906162246.GB3326@cisco.cisco.com> <20180906183018.GC3326@cisco.cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 10, 2018 at 07:00:43PM +0200, Jann Horn wrote: > On Thu, Sep 6, 2018 at 8:30 PM Tycho Andersen wrote: > > On Thu, Sep 06, 2018 at 10:22:46AM -0600, Tycho Andersen wrote: > > > On Thu, Sep 06, 2018 at 06:15:18PM +0200, Jann Horn wrote: > > > > On Thu, Sep 6, 2018 at 5:29 PM Tycho Andersen wrote: > > > > > The idea here is that the userspace handler should be able to pass an fd > > > > > back to the trapped task, for example so it can be returned from socket(). > > > > [...] > > > > > diff --git a/Documentation/userspace-api/seccomp_filter.rst b/Documentation/userspace-api/seccomp_filter.rst > > > > > index d1498885c1c7..1c0aab306426 100644 > > > > > --- a/Documentation/userspace-api/seccomp_filter.rst > > > > > +++ b/Documentation/userspace-api/seccomp_filter.rst > > > > > @@ -235,6 +235,9 @@ The interface for a seccomp notification fd consists of two structures: > > > > > __u64 id; > > > > > __s32 error; > > > > > __s64 val; > > > > > + __u8 return_fd; > > > > > + __u32 fd; > > > > > + __u32 fd_flags; > > > > > > > > Normally, syscalls that take an optional file descriptor accept a > > > > signed 32-bit number, with -1 standing for "no file descriptor". Is > > > > there a reason why this uses a separate variable to signal whether an > > > > fd was provided? > > > > > > No real reason other than I looked at the bpf code and they were using > > > __u32 for bpf (but I think in their case the fd args are not > > > optional). I'll switch it to __s32/-1 for the next version. > > > > Oh, I think there is a reason actually: since this is an API addition, > > the "0" value needs to be the previously default behavior if userspace > > doesn't specify it. Since the previously default behavior was not to > > return an fd, and we want to allow fd == 0, we need the extra flag to > > make this work. > > > > This is really only a problem because we're introducing this stuff in > > a second patch (mostly to illustrate how extending the response > > structure would work). I could fold this into the first patch if we > > want, or we could keep the return_fd bits if the illustration is > > useful. > > I feel like adding extra struct fields just so that it is possible to > write programs against the intermediate new API between two kernel > commits is taking things a bit far. Yep, I tend to agree with you. I'll fold the whole thing into the first patch for the next version. Tycho