Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp254715imm; Thu, 21 Jun 2018 17:52:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIiwPa3UXlRVdU4jNoJN/23RNS1vQLZrlSJ271mixHJq+tAHqhjwLtLLr4sk7JMwKg1p3OC X-Received: by 2002:a17:902:6802:: with SMTP id h2-v6mr30512603plk.113.1529628759296; Thu, 21 Jun 2018 17:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529628759; cv=none; d=google.com; s=arc-20160816; b=E9dSuRqws0XA1wxoKZDbTpNs86tcXTc7/MsG9IxRoR6N/bGctkoevA7hqRCHO34mPB Se/fm/OFAmbJUw9Xod1c+23kK8+8H1f25EC0A9kkazEE6/WZMiI/Bdlh7d5RD46nS3F0 NZhro/s/p2PTv9lt340h0tgXBhvF8B89vR/f8MZMqF9O6cwsOHMgl2WsQ7NNoOWcLkp8 IR62zb8KwNUpfk/viYR60G/IOGTsX0qyzGIaHHymy3W8ti0MlR+8IMLLXncF3Z2CJDCX 292XQoq382K3aE6ielXB06lkj8kCQAGQlPVbBo7+00/oDRJhD2c7Pm8bXeYh3BUkRHC9 Cj3g== 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=b5z48HeJ1lP4NZgcMC1Xib0kcwWubGoVrtOpUOakYu8=; b=UaJtklO9BkAyVPze0UTd71Rt3Qwan1CRU2dqyo90qNRnBJffAs34yr5kpWgrGVSFX3 rf/s+RsPIzHU253tw25WKFfN3R8b5Ud/Acw06ZCnxZXV5m9e3N4ypWNED7jUWkT9vrfC 1m2Fp1btOhAPOJrslfmlmAnCQwVFuCgL/8qbPdCrp/IMnlEmQJGub2YawLLcn5qgVbbm 4SDx6mumvUcQWSEv9CAnu/HiaJizOPASkLWA0n9G2dp3uh0tbyCMxZ8Mwle/gIESJKlA /krUcbAK548GI9gI1DTMgy/l1X5fgxgBrwzV3iPukpEtJtyWd+6z6KtXqh62cTV6F9JI 67Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=nC0CZtDx; 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 f192-v6si6423151pfa.252.2018.06.21.17.52.24; Thu, 21 Jun 2018 17:52:39 -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=nC0CZtDx; 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 S934101AbeFVAvk (ORCPT + 99 others); Thu, 21 Jun 2018 20:51:40 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:41919 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934052AbeFVAvi (ORCPT ); Thu, 21 Jun 2018 20:51:38 -0400 Received: by mail-qt0-f193.google.com with SMTP id y20-v6so4620945qto.8 for ; Thu, 21 Jun 2018 17:51:38 -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=b5z48HeJ1lP4NZgcMC1Xib0kcwWubGoVrtOpUOakYu8=; b=nC0CZtDxrf9nv7egcQzflXi3k/lu+RztX69n0MQhUmFzi5DjB2MGBFJz6R7JibnR8e +zg8B9P1Qh8JJvN5m5NGGKrswCi4zWBhhMWZA14RvvGRFeCsVXfZwC8qlHo9jPZ+MeMI Z0O1/Ug+j7JiwIySVUpG8jIVRpNT5YkepQueOpR7PLj5YqXz0PfQ59CS18PXh12TpMKs OOy/gy47RqsNRounZmYf1hB25NMc0LawlPWiLREtpMVH2UK0a6MJCeqaNY7SMIazxDSd VDXyUFHxK2mnAxdtctoRo0+1JlOgEzhfojrdDGqFnL1ALu6h2e+frYV9iN+CtmEscNFi 7LcA== 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=b5z48HeJ1lP4NZgcMC1Xib0kcwWubGoVrtOpUOakYu8=; b=NrpQaMxgzdsV0CizGE9SE/emgN+gRVXYPaJlt7AgLG0CXpP4Dwfpoo1gwjbA+gS2pv FO1CK/hLAnokRw90qLxqmi+jK7L8XemMjrVNW8ZPq9tyJkwxNT4x70+291Xhxx61yz5r eC682U4ycqIyOK7aWGz+QCHre7ygcSCrmvytNWlJDr7O/VxX9bMSvgt3Am1lJ4WI0f3i 1wqI26YFgO3tpi8lx+nnEbWoCUaEgEtXmLHRTx0tyxbvbVTouuGJTcqY8kKMRW8JGoi4 sVHc8wgi47ewbZmjn9M6NMSDW5TpqibR8n5h4lHYOXwGmCWQsS5sWfSMMDTYLmZNTI4v rbHQ== X-Gm-Message-State: APt69E0FTLaljiUjevYtQcuq+YzLpJsAfc65CzR8z/r6QWJZOWRazvBj 826p6OqX1hA2usovRynU53IYeQ== X-Received: by 2002:ac8:2931:: with SMTP id y46-v6mr26022891qty.416.1529628697814; Thu, 21 Jun 2018 17:51:37 -0700 (PDT) Received: from cisco ([173.38.117.67]) by smtp.gmail.com with ESMTPSA id v123-v6sm4152739qka.79.2018.06.21.17.51.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 17:51:36 -0700 (PDT) Date: Thu, 21 Jun 2018 18:51:34 -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, "Tobin C. Harding" Subject: Re: [PATCH v4 4/4] seccomp: add support for passing fds via USER_NOTIF Message-ID: <20180622005134.GJ3992@cisco> References: <20180621220416.5412-1-tycho@tycho.ws> <20180621220416.5412-5-tycho@tycho.ws> 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 Fri, Jun 22, 2018 at 01:34:18AM +0200, Jann Horn wrote: > On Fri, Jun 22, 2018 at 12:05 AM 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(). > [...] > > +Userspace can also return file descriptors. For example, one may decide to > > +intercept ``socket()`` syscalls, and return some file descriptor from those > > +based on some policy. To return a file descriptor, the ``return_fd`` member > > +should be non-zero, the ``fd`` argument should be the fd in the listener's > > +table to send to the tracee (similar to how ``SCM_RIGHTS`` works), and > > +``fd_flags`` should be the flags that the fd in the tracee's table is opened > > +with (e.g. ``O_EXCL`` or similar). > > fd_flags only contains file descriptor flags (meaning only O_CLOEXEC). > O_EXCL is a file creation flag, so setting it here wouldn't make sense. > Setting file status flags like O_APPEND does make sense, but those are > stored in the `struct file` and don't need to be passed separately; > the caller can e.g. set them via fcntl(fd, F_SETFD, flags) or on > open(). > (The fcntl.2 manpage explains these.) Ugh, yes, O_CLOEXEC is what I meant. Thanks, I'll clarify. Tycho