From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out03.mta.xmission.com ([166.70.13.233]:47871 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbeCLX3Y (ORCPT ); Mon, 12 Mar 2018 19:29:24 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Al Viro Cc: John Ogness , Linus Torvalds , linux-fsdevel , Christoph Hellwig , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior , Linux Kernel Mailing List References: <87h8q7erlo.fsf@linutronix.de> <20180223150928.GC30522@ZenIV.linux.org.uk> <20180223174216.GD30522@ZenIV.linux.org.uk> <20180223201317.GG30522@ZenIV.linux.org.uk> <20180224002248.GH30522@ZenIV.linux.org.uk> <20180225073950.GI30522@ZenIV.linux.org.uk> <87bmgbnhar.fsf_-_@linutronix.de> <20180312191351.GN30522@ZenIV.linux.org.uk> <877eqhcab3.fsf@xmission.com> <20180312203916.GQ30522@ZenIV.linux.org.uk> Date: Mon, 12 Mar 2018 18:28:30 -0500 In-Reply-To: <20180312203916.GQ30522@ZenIV.linux.org.uk> (Al Viro's message of "Mon, 12 Mar 2018 20:39:17 +0000") Message-ID: <87woygan6p.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: dcache: remove trylock loops (was Re: [BUG] lock_parent() breakage when used from shrink_dentry_list()) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Al Viro writes: > On Mon, Mar 12, 2018 at 03:23:44PM -0500, Eric W. Biederman wrote: > >> Of the two code paths you are concert about: >> >> For path path_connected looking at s_root is a heuristic to avoid >> calling is_subdir every time we need to do that check. If the heuristic >> fails we still have is_subdir which should remain accurate. If >> is_subdir fails the path is genuinely not connected at that moment >> and failing is the correct thing to do. > > Umm... That might be not good enough - the logics is "everything's > reachable from ->s_root anyway, so we might as well not bother checking". > For NFS it's simply not true. If I am parsing the code correctly path_connected is broken for nfsv2 and nfsv3 when NFS_MOUNT_UNSHARED is not set. nfsv4 appears to make a kernel mount of the real root of the filesystem properly setting s_root and then finds the child it is mounting. > We can mount server:/foo/bar/baz on /tmp/a, then server:/foo on /tmp/b > and we'll have ->s_root pointing to a subtree of what's reachable at > /tmp/b. Play with renames under /tmp/b and you just might end up with > a problem. And mount on /tmp/a will be (mistakenly) considered to > be safe, since it satisfies the heuristics in path_connected(). Agreed. Which means that if you mount server:/foo/bar/baz first and then mount server:/foo with an appropriate rename you might be able to see all of server:/foo or possibly server:/ Hmm.. Given that nfs_kill_super calls generic_shutdown_super and generic_shutdown_super calls shrink_dcache_for_umount I would argue that nfsv2 and nfsv3 are buggy in the same case, as shrink_dcache_for_umount is called on something that is not the root of the filesystem's dentry tree. Eric