Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760873AbcLBLlV (ORCPT ); Fri, 2 Dec 2016 06:41:21 -0500 Received: from mail-wj0-f176.google.com ([209.85.210.176]:35744 "EHLO mail-wj0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751866AbcLBLlT (ORCPT ); Fri, 2 Dec 2016 06:41:19 -0500 MIME-Version: 1.0 In-Reply-To: <20161202104804.GC26086@quack2.suse.cz> References: <20161102220851.GA1839@veci.piliscsaba.szeredi.hu> <20161105213411.GA32353@quack2.suse.cz> <20161109111005.GA32353@quack2.suse.cz> <20161110194625.GG31098@quack2.suse.cz> <20161202104804.GC26086@quack2.suse.cz> From: Amir Goldstein Date: Fri, 2 Dec 2016 13:41:17 +0200 Message-ID: Subject: Re: fsnotify_mark_srcu wtf? To: Jan Kara Cc: Miklos Szeredi , Eric Paris , linux-fsdevel , linux-kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1724 Lines: 37 On Fri, Dec 2, 2016 at 12:48 PM, Jan Kara wrote: > On Fri 02-12-16 09:26:51, Miklos Szeredi wrote: ... >> >> Hmm, how about this: when removing mark from inode, drop refcount. If >> refcount is zero can remove from list. Otherwise mark the mark "dead" >> and leave it on the list. >> >> And fsnotify can just skip dead marks. > > I had this idea as well and when trying to implement this, I've stumbled > over some problems. I think the biggest problem was that destruction of a > notification mark is relatively complex operation (doing iput() for > example) and quite a few places dropping mark references are in a context > where this can cause problems. Also I don't want to defer iput() to a > workqueue as that will have unexpected consequences such as unlinked > watched inode lingering in the system (possibly colliding with umount > etc.). > I am wondering out loud if we are trying to solve a real problem or a made up test case. I wonder if Miklos' test program truly represents the original bug report. I am asking because fanotify permission events are usually associated with system security software and it usually makes sense on a vfsmount_mark and not an inode_mark. Maybe the break even solution is not to split destroy lists per group priority, but to split destroy lists by inode marks and vfsmount marks and also keep 2 separate lists per group. I am only asking this because you mentioned iput as a thorn in the solution. Since vfsmount mark does not pin the mount, nor hold an elevated reference, perhaps dealing with simpler destruction of vfsmount marks can solve the problem for "rogue fanotify permission mount watch" and maybe that is enough for all practical matters? Amir.