Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp704211imm; Thu, 6 Sep 2018 08:52:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdahTOW1Qa8iNWrTdtygnp70lWjEuXpWhKeFpy2KzAvWbuWR7D29O7gV+1WIwW3jCc0QHkJL X-Received: by 2002:a63:fa49:: with SMTP id g9-v6mr3514350pgk.18.1536249146693; Thu, 06 Sep 2018 08:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536249146; cv=none; d=google.com; s=arc-20160816; b=R2Z8jviXkFHdJeNTCiFlZNWhOBOFZseTwrhRjhBDf+GJA0mLg4AjB1n5OeEvCK3nJC QT2oXQGxOXxZFeX/oPPqYHV7y1HgbuSPjr9N/+YUAYu8J2TnvlAEg7JPEAJhuX0CL3J1 jLXIFkrS0gWEyDiXwj70D1nsnsu7E3VPN2qjYv8Cy2eJqhh3dt/QEh6DX9EZ1Ta7rKIf lgdvfG7IlCcq744bps/QaAUS/RXbClszD6W4hVhRHFWW/MrHwdvEO+LGpyaKxBkXFww/ +CsWOxtQwIAp7TWXBNPit0xRsTDmxcXxNCYDlSfFV0RN/sdGcCApYot/6p6x7seE1mLy XpBA== 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=+jnPKTZ0c+/B1RaujfdArsJQjneQQQrPfgDLshUdTD0=; b=jHaKv0JxvHpDgEVudZEEVNlFFaLN6DXcniSSmuj0FG1WCoi+Hmma4yEYvJNVmWTq9y lA8lZ9UEYI5B1IXdRjZIX7zLnr6omFLf0qDPW4Kd/0oCLmkkxGuGX1SZoxOukQys4C7d QYTO9uk8PHgi7Gh9wnOy//bgj85g8ruKPm5vliF5Ko+BsOLsS17XqyKuyzT3PPb4EgJq 92YhpzmPGZQY9xuBq2YW5Rgw+ar8/Ktb8MTCRkGVt8CZzF564nNlrwY2J0ovsFLgYMWV WkqB/lxJd97r9Zzm7fQ5JAnS0abLncFkGeq3Kh8Ckho88EIUREA900FlhMazyPwvdoB3 6BIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=rnBUWG8K; 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 q28-v6si5498263pgm.689.2018.09.06.08.52.11; Thu, 06 Sep 2018 08:52:26 -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=rnBUWG8K; 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 S1730311AbeIFU0U (ORCPT + 99 others); Thu, 6 Sep 2018 16:26:20 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:39940 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730122AbeIFU0T (ORCPT ); Thu, 6 Sep 2018 16:26:19 -0400 Received: by mail-qt0-f196.google.com with SMTP id h4-v6so12811461qtj.7 for ; Thu, 06 Sep 2018 08:50: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=+jnPKTZ0c+/B1RaujfdArsJQjneQQQrPfgDLshUdTD0=; b=rnBUWG8K9HnJN3y24LwW1HwEzwt3AFJcvjF9tXLyU+NrIGKTPuxyXyvQno49+JB6NF 9UjKfMk7oAxA+AltU6qyARGrjtKV0h/i88pwnj6yLSm8zpkU9/lV4ROYJYmRhAZGWGzD 1gyS2tjNJiZwd8KGcJPBJj2qUbuerqQJj7K2sFbnEbXwyv0EpTPW13s0kK08aPpWNcXk OpLisL+cT9dyGmhmqsaMvIFutzLf84Ik9A8nOHgJ26w8mr9hGNIXCDVCyXH+pFndonIq A97yaFF87nvPeVcz+5/+bD7oc+xQcg0/LcfA1MvSG7su5Z2RxxjGL4dBEXBiwkWoFJlp vZ0Q== 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=+jnPKTZ0c+/B1RaujfdArsJQjneQQQrPfgDLshUdTD0=; b=kDXNZyCO7LJJrsK+iZc8FJv6tVFSLI/IlTxIrZr/JSUS3yIVL/jRGzZVk0bZqQsRsk L3kEZ7JvPVkWH0d/P6+9EGEmoxmiJ6uxV0ilQ9HlcTb/TQU1OxXkyQUPaF31cd188MoU 5W4uH0MGyJt3XvY9HiaT6etCIjbhQpPwZFIL5pXsc2pgl02kW5nQOoe4NldlA8wc7rV7 fwDC9ag0uSJ7FNKKhMQklxfG4y+0N8AUH3N9AZpA/12JKlG4JybvmF3PLOLx24edbZ+V BBc3JQLP2iz/7pek5yE0bSVwyavrv0SLtpxt0DzNGwVIVYbaxWqgy9Hk4qIA9yu28pju h8Gg== X-Gm-Message-State: APzg51DvKG+4tVsrparFClB8WrvcAZuz80wlWApIp5xxSTtKDCNaVHrl Bqc4kF6KH5gR9xqYQXmNpkYm3Q== X-Received: by 2002:a0c:fb08:: with SMTP id c8-v6mr2527574qvp.149.1536249012005; Thu, 06 Sep 2018 08:50:12 -0700 (PDT) Received: from cisco.cisco.com ([173.38.117.76]) by smtp.gmail.com with ESMTPSA id c50-v6sm1490625qtb.8.2018.09.06.08.50.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 08:50:11 -0700 (PDT) Date: Thu, 6 Sep 2018 09:50: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 Subject: Re: [PATCH v6 3/5] seccomp: add a way to get a listener fd from ptrace Message-ID: <20180906155008.GA3326@cisco.cisco.com> References: <20180906152859.7810-1-tycho@tycho.ws> <20180906152859.7810-4-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 06, 2018 at 05:45:25PM +0200, Jann Horn wrote: > On Thu, Sep 6, 2018 at 5:29 PM Tycho Andersen wrote: > > > > As an alternative to SECCOMP_FILTER_FLAG_GET_LISTENER, perhaps a ptrace() > > version which can acquire filters is useful. There are at least two reasons > > this is preferable, even though it uses ptrace: > > > > 1. You can control tasks that aren't cooperating with you > > 2. You can control tasks whose filters block sendmsg() and socket(); if the > > task installs a filter which blocks these calls, there's no way with > > SECCOMP_FILTER_FLAG_GET_LISTENER to get the fd out to the privileged task. > [...] > > +long seccomp_new_listener(struct task_struct *task, > > + unsigned long filter_off) > > +{ > > + struct seccomp_filter *filter; > > + struct file *listener; > > + int fd; > > + > > + if (!capable(CAP_SYS_ADMIN)) > > + return -EACCES; > > + > > + filter = get_nth_filter(task, filter_off); > > + if (IS_ERR(filter)) > > + return PTR_ERR(filter); > > + > > + fd = get_unused_fd_flags(0); > > + if (fd < 0) { > > + __put_seccomp_filter(filter); > > + return fd; > > + } > > + > > + listener = init_listener(task, task->seccomp.filter); > > Did you mean to write something like `init_listener(task, filter)` here? Yes, yes I did. Thanks, Jann. Tycho