Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp24494imm; Thu, 27 Sep 2018 15:15:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ZW+D2C04cr1Fp0LF2Zc0LLGjTi9VCgBEsYkOsYIhTpWriNFD5FT2N7kz8TEo2c8yRzMS7 X-Received: by 2002:a17:902:9a83:: with SMTP id w3-v6mr13352796plp.75.1538086533072; Thu, 27 Sep 2018 15:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538086533; cv=none; d=google.com; s=arc-20160816; b=JeamgpXEVqck5wyvcvDAZaOTeqNuvuNo6aBeU0mZqhpOMSxEnMXruxOLJ5fvNgpVMf 5zI8SsPD8aMLEfG3+15jD5VxVTKSsKcP9ZSVvTeZ/eOfAPUiVzqf4vA7DGIekbrpDQ6L RcAVaRKVPZ+bE3LvrB4q3ES+VT+lNYm4dXph6UnOKJiLsT9jGiwBmLpgkqLGzjfAyjDU 2nBvy9Koe/hXqpTisvwQGAZ4OkjyHRK89GVzTvQZkPmmNrG2C4hQo2daUg/eF8kAAHoV 2K9LEX7Ts9cfMudZ5WjSG7i/h6WxP6n1xgkzFtjN4Jn2UYg6BJyyMRKSpg10kKt7JVCy 5rXA== 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=HQlKN50WM+JsabHzn7SoqTNDtIQjbrBcqRFw4MRzbUs=; b=DsjJqMcbR47upea8kD/t57gbpoItfsGDaAhpZABJwzxa71Fj8m0hWK+7COdVh7YS8j qv4J0h0iAYyQD5B8mI+UozFNaXWRq371Wa6/JVsrW/tOfvr9SA/xrqUGH5FZv0xmqfAz N+NRfqOz0d2zG0l1t73sG0AnUmvhv11HGYISvR/jppRYoZN+kFi3ou2IDiLdYOVHBkqU QWejC7etLTFH+MYu2WmN1iD/37/UhD494jXXgKNZ+Lo2KeAAXdd0Bm86xG9ntqCE6Hsk tTfuqWW9wdlet/lerQqrfT/EbfP7Bla+UOTVUP7VGs9d6p4tiA3s9UdayDqCZehW8K9N WhTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=gHJlrtn1; 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 y27-v6si3063135pgc.197.2018.09.27.15.15.14; Thu, 27 Sep 2018 15:15:33 -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=gHJlrtn1; 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 S1727974AbeI1Eek (ORCPT + 99 others); Fri, 28 Sep 2018 00:34:40 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:32990 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbeI1Eek (ORCPT ); Fri, 28 Sep 2018 00:34:40 -0400 Received: by mail-ot1-f66.google.com with SMTP id m23-v6so4174817otf.0 for ; Thu, 27 Sep 2018 15:14:12 -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=HQlKN50WM+JsabHzn7SoqTNDtIQjbrBcqRFw4MRzbUs=; b=gHJlrtn1QnDzhLXqtuhUqeCLNaHdxtWSqXb+Fc+qlaNSOrPv71buxujhZ9Y/ZPfVNa KD8y+vz6c8a63YR5uHObZmARgtOnvkrjYWwx4PULqaZNCxrNvPs9LvkUsZmuGKog7cSw uZB3+7TaXO/XvWtjc4n1wKgmgXjf6rtuOJe5BTtdzKUkyIJTU91AwgIK6CXu3yvdQCaj bT6PLQnYv11juGov9/FkTIThkZ3IC2w20LZ0mr1IRBe9i/40UFC5mqr8YrFJnKxNmAQ0 rSbi2AGuerOZFVSwgQ6LreuRkJZ4GagpGJwAzguNsdismlaeg+FVq/sV/kYs4cpltnHM 03HQ== 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=HQlKN50WM+JsabHzn7SoqTNDtIQjbrBcqRFw4MRzbUs=; b=KpYUv1hj8J82DkpUKxOCGixTP9+B/ltX4vnf+dI5pViy7DiL5AtlXiJ95fqYFDumVl CVzKzK1wi8PcekFn9a5YXZs3kkT6UJ4GGdmav7JjqkwYHffG6yoM3JheVE6HDJyKyMGa Ol9Zv+s/sHnlirS9+q5coQBNrBbGRbnRnElkNOtnJrlIQcYnIs/8kHQH3MXNVWtJHUg4 mKc0NqX9mfYGU/QQcWE1y1UuoMsezeTPfBgDK89N1n7QrmtONGXY5EDTo1kOloMh4rn7 0j2KUSNAHmkhmMSXMJ7iAlDZBL5yemvQYlMnBlxPhxfgZDDqDmVC1tsOJot2GRHbxtSB EIdQ== X-Gm-Message-State: ABuFfoiZi0MlYzfUjzuyrzyuuUv7sqfj7SSttA7uh3aHT3TEWydhDmv8 pGelq/hcnXd58B1P/mImwcUI8Q== X-Received: by 2002:a9d:7185:: with SMTP id o5-v6mr8657920otj.60.1538086452138; Thu, 27 Sep 2018 15:14:12 -0700 (PDT) Received: from cisco.cisco.com ([128.107.241.175]) by smtp.gmail.com with ESMTPSA id e7-v6sm953076oii.26.2018.09.27.15.14.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Sep 2018 15:14:11 -0700 (PDT) Date: Thu, 27 Sep 2018 16:14:08 -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, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v7 5/6] seccomp: add a way to pass FDs via a notification fd Message-ID: <20180927221408.GD15491@cisco.cisco.com> References: <20180927151119.9989-1-tycho@tycho.ws> <20180927151119.9989-6-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 Thu, Sep 27, 2018 at 09:28:07PM +0200, Jann Horn wrote: > On Thu, Sep 27, 2018 at 5:11 PM Tycho Andersen wrote: > > This patch adds a way to insert FDs into the tracee's process (also > > close/overwrite fds for the tracee). This functionality is necessary to > > mock things like socketpair() or dup2() or similar, but since it depends on > > external (vfs) patches, I've left it as a separate patch as before so the > > core functionality can still be merged while we argue about this. Except > > this time it doesn't add any ugliness to the API :) > [...] > > +static long seccomp_notify_put_fd(struct seccomp_filter *filter, > > + unsigned long arg) > > +{ > > + struct seccomp_notif_put_fd req; > > + void __user *buf = (void __user *)arg; > > + struct seccomp_knotif *knotif = NULL; > > + long ret; > > + > > + if (copy_from_user(&req, buf, sizeof(req))) > > + return -EFAULT; > > + > > + if (req.fd < 0 && req.to_replace < 0) > > + return -EINVAL; > > + > > + ret = mutex_lock_interruptible(&filter->notify_lock); > > + if (ret < 0) > > + return ret; > > + > > + ret = -ENOENT; > > + list_for_each_entry(knotif, &filter->notif->notifications, list) { > > + struct file *file = NULL; > > + > > + if (knotif->id != req.id) > > + continue; > > Are you intentionally permitting non-SENT states here? It shouldn't > make a big difference, but I think it'd be nice to at least block the > use of notifications in SECCOMP_NOTIFY_REPLIED state. Agreed, I'll block everything besides REPLIED. Tycho