Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1048781ybm; Wed, 27 May 2020 14:53:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywqN1Pzase/UXE6IZXH3XtGCbqFFyRKHbjm/5audQK8l/pjGdq4ow7oQilIguNnPjaKdO/ X-Received: by 2002:a50:a693:: with SMTP id e19mr162547edc.275.1590616426837; Wed, 27 May 2020 14:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590616426; cv=none; d=google.com; s=arc-20160816; b=UFlmjjD/c4Rludqo6WbgiZG90gYB3ToDUUq681Y7eAc/gxkXwGShZSpY59z1zatKvh LifUvXVuU18s6SAqvjexRyK51/9x5RuwqyOmhbTHiMD7Y3j4uwQAE65ngVvGLYa6ltor yq8+hi1hIZO+6/TfP+RhroTljPpVvmXpL5v4ZTgXcSJyVNnzLe/9J9F73SAVn77YQ4AK 29q4ZaJI8B7POJu9+0NYnP8hCk07E7s69eDi3oa9cWDM/zrFSybU8AiPjqr2Wn6XfXIL g9MMp3gybY9G0zODXQX+nLSA22vKZSIiFymbJpxL8DplbmhNkWPBlkZxN79BdW2fZHYK RDWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=x7jiIKB3e6Jtd1I9S0cpqPXeXNU+2ctymnq/r4aUKrg=; b=Kqs4e0XzMzDLMRAI/q0fSrFiH2PouFC5tWzyZmaZRR1eahxcknEAS14JSyI8LvXZH6 B1AnYwAmlJkpHG0iSwnMhApjLRgKA4eBT4d7pqEboNPpI/9ICLg9t86Y7VkvLoYFwRIy OqbMTdML9RvMw+7xTCcQ4wBqfhkzwPk9T0LCKqR+hG1ZeUHz/w8MZX/m5T36Xgs56Wk0 6s9JwheYgn0r+x1A3z/rtF6s5QsOBOZGRxRAfaDcQvEhdKj8D7wX6/ww4Mdjl5YKI98r /urF5y9zE5F62/yV3tHNhaU5mFd8CVSSu+WLAj4jRDZfDRay8gEx15XK/nnNnOAIZtNT pmOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ba17si2385462edb.20.2020.05.27.14.53.24; Wed, 27 May 2020 14:53:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728703AbgE0TNm (ORCPT + 99 others); Wed, 27 May 2020 15:13:42 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:46020 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbgE0TNl (ORCPT ); Wed, 27 May 2020 15:13:41 -0400 Received: from ip5f5af183.dynamic.kabel-deutschland.de ([95.90.241.131] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1je1Ue-0003jw-Hw; Wed, 27 May 2020 19:13:36 +0000 Date: Wed, 27 May 2020 21:13:35 +0200 From: Christian Brauner To: Sargun Dhillon Cc: Kees Cook , Chris Palmer , Jann Horn , Robert Sesek , Jeffrey Vander Stoep , Linux Containers , linux-kernel@vger.kernel.org, Matt Denton , Andy Lutomirski Subject: Re: [PATCH 1/2] seccomp: notify user trap about unused filter Message-ID: <20200527191335.mt5ywrgvpppiqj7v@wittgenstein> References: <20200527111902.163213-1-christian.brauner@ubuntu.com> <20200527173706.GA1242@ircssh-2.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200527173706.GA1242@ircssh-2.c.rugged-nimbus-611.internal> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 27, 2020 at 05:37:07PM +0000, Sargun Dhillon wrote: > On Wed, May 27, 2020 at 01:19:01PM +0200, Christian Brauner wrote: > > +void seccomp_filter_notify(const struct task_struct *tsk) > > +{ > > + struct seccomp_filter *orig = tsk->seccomp.filter; > > + > > + while (orig && refcount_dec_and_test(&orig->live)) { > > + if (waitqueue_active(&orig->wqh)) > > + wake_up_poll(&orig->wqh, EPOLLHUP); > > + orig = orig->prev; > > + } > > +} > > + > Any reason not to write this as: > for (orig = tsk->seccomp.filter; refcount_dec_and_test(&orig->live); orig = orig->prev)? Mainly to follow coding style if you look at: static void __put_seccomp_filter(struct seccomp_filter *orig) { /* Clean up single-reference branches iteratively. */ while (orig && refcount_dec_and_test(&orig->usage)) { struct seccomp_filter *freeme = orig; orig = orig->prev; seccomp_filter_free(freeme); } } seemed easier to just have a visual correspondence between those two codepaths. > > Also, for those of us who are plumbing in the likes of Go code into the > listener, where we don't have direct access to the epoll interface (at > least not out of the box), what do you think about exposing this on the RECV I think requiring users to import golang.org/x/sys/unix is reasonable. You'll need to special case this to linux builds anyway even if you have a client or some such that build on on-unixes. And even if you don't want to import there's always the possibility to use cgo. :) > ioctl? Or, do you think we should lump that into the "v2" receive API? I'm confused how you want to plumb this into the ioctl. That seems unpleasant and against usual poll/wait semantics. I'm now also wondering how you're using this whole interface without poll. The idea is to wait until you're notified you can receive. > > Either way, this seems useful, as right now, we're intertwining process > tree lifetime with manager lifetime. This seems cleaner. Cool. Christian