Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp480776ybm; Thu, 28 May 2020 07:42:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzaHLxtUAo6hZVg4ZMoCG4FNCrVE4OCgtEBHce8nFzzPFbbWBVhzhWN5kDc5o2bgBPfILy X-Received: by 2002:a17:906:2b04:: with SMTP id a4mr3423822ejg.98.1590676974296; Thu, 28 May 2020 07:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590676974; cv=none; d=google.com; s=arc-20160816; b=zCH6x00IWojEVQpKhQqUh2T3t264qEemx9htkMj6Io0FbgShwnVceGWjOXlAn5C3/y yrRmR85BNEPytDGlIjzSNpXcwV3GCl1dlZ4H0H/Whcb/y5VP5+lQaO5jT81O0zPKXSGu nnlHpOeH8TzkcML+8LzgZCj5fCEd7M/i+F8voQyEfnyJB0Astf3C4Tggl5IsDtWvQMDX 5t8WAYTRNd3qhQs9vUY3rhWjPOihmJG3VOi5z1awCi/tYkWunb2NODWf/yBJDsb14tDK jfTf3iP9Nh7VbSdeSWxKMH5aBOMWg//JGKlxhJhpdgG4a0Wc8JQCA120GCQCd+TF2vDF re1Q== 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=hQsfIpL0AhOWhQWenX989s7u9fasopVrqCEwF0QSVI4=; b=y/gzQxiW0BslHjGnGhDTqFqeXsS0DJuycFIMiotFHngfLczOcaIiSjCI/an0EI/OLW DC2vU25G8uWYyChV/EjB6NJreX7Zuu0uTImsLO45B81/GTxhE06B56ATM2EuHkNDht39 05LRnRzfNCONyTA4Z2vd6b0kv1nqmsMS//p9SXWmsNbwCcJUyKUFgBfnaHxZzjBdKIkg 4tSOG9uJBwTm+7Lh/Px1378YI+nGIvlhnI9PdBdvHAMRbWlnH7BKMHu4HhYQC8jOKzBS XyZIdjtT42U+5ELKGjHvV/fUKeSyPdcMwCmxVxMxyXA/0CScxKlYvSc4ezvT2QCGx3i+ SVbQ== 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 a21si3606688edr.375.2020.05.28.07.42.30; Thu, 28 May 2020 07:42:54 -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 S1727811AbgE1OkD (ORCPT + 99 others); Thu, 28 May 2020 10:40:03 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57213 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgE1OkB (ORCPT ); Thu, 28 May 2020 10:40:01 -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 1jeJhP-0004jD-Ej; Thu, 28 May 2020 14:39:59 +0000 Date: Thu, 28 May 2020 16:39:57 +0200 From: Christian Brauner To: Kees Cook Cc: linux-kernel@vger.kernel.org, Andy Lutomirski , Tycho Andersen , Matt Denton , Sargun Dhillon , Jann Horn , Chris Palmer , Aleksa Sarai , Robert Sesek , Jeffrey Vander Stoep , Linux Containers Subject: Re: [PATCH 1/2] seccomp: notify user trap about unused filter Message-ID: <20200528143957.lhyjorrfqrexjurz@wittgenstein> References: <20200527111902.163213-1-christian.brauner@ubuntu.com> <202005271408.58F806514@keescook> <20200527220532.jplypougn3qzwrms@wittgenstein> <202005271537.75548B6@keescook> <20200527224501.jddwcmvtvjtjsmsx@wittgenstein> <20200527231646.4v743erjpzh6qe5f@wittgenstein> <202005271851.B7FBA02F@keescook> <20200528141658.dfjple4zddzkc3bj@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200528141658.dfjple4zddzkc3bj@wittgenstein> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 04:17:00PM +0200, Christian Brauner wrote: > On Wed, May 27, 2020 at 06:59:54PM -0700, Kees Cook wrote: > > On Thu, May 28, 2020 at 01:16:46AM +0200, Christian Brauner wrote: > > > I'm also starting to think this isn't even possible or currently doable > > > safely. > > > The fdtable in the kernel would end up with a dangling pointer, I would > > > think. Unless you backtrack all fds that still have a reference into the > > > fdtable and refer to that file and close them all in the kernel which I > > > don't think is possible and also sounds very dodgy. This also really > > > seems like we would be breaking a major contract, namely that fds stay > > > valid until userspace calls close, execve(), or exits. > > > > Right, I think I was just using the wrong words? I was looking at it > > like a pipe, or a socket, where you still have an fd, but reads return > > 0, you might get SIGPIPE, etc. The VFS clearly knows what a > > "disconnected" fd is, and I had assumed there was general logic for it > > to indicate "I'm not here any more". > > > > I recently did something very similar to the pstore filesystem, but I got > > to cheat with some massive subsystem locks. In that case I needed to clear > > all the inodes out of the tmpfs, so I unlink them all and manage the data > > lifetimes pointing back into the (waiting to be unloaded) backend module > > by NULLing the pointer back, which is safe because of the how the locking > > there happens to work. Any open readers, when they close, will have the > > last ref count dropped, at which point the record itself is released too. > > > > Back to the seccomp subject: should "all tasks died" be distinguishable > > from "I can't find that notification" in the ioctl()? (i.e. is ENOENT > > sufficient, or does there need to be an EIO or ESRCH there?) > > I personally think it's fine as it is but as it might help users if we > reported ESRCH something like the patch below might do. > Actual cleanup of the notifier should still happen in > seccomp_notify_release() imho, and not in __poll_t both conceptually and > also because f_op->release() happens on finaly fput() which punts it to > task_work() which finishes when the task returns from kernel mode (or > exits) - or - if the task is not alive anymore just puts it on the > kernel global workqueue which is perfect for non-high-priority cleanup > stuff. It's better than making __poll_t heavier than it needs to be. > Unless there's an obvious reason not to. Scratch the patch I posted before here; it's garbage of course.