[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131108213551.GR13318@ZenIV.linux.org.uk>
Date: Fri, 8 Nov 2013 21:35:51 +0000
From: Al Viro <viro@...IV.linux.org.uk>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: Miklos Szeredi <miklos@...redi.hu>,
Andy Lutomirski <luto@...capital.net>,
"Serge E. Hallyn" <serge@...lyn.com>,
Linux-Fsdevel <linux-fsdevel@...r.kernel.org>,
Kernel Mailing List <linux-kernel@...r.kernel.org>,
Rob Landley <rob@...dley.net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Matthias Schniedermeyer <ms@...d.de>,
Linux Containers <containers@...ts.linux-foundation.org>
Subject: Re: [REVIEW][PATCH 1/4] vfs: Don't allow overwriting mounts in the
current mount namespace
On Fri, Nov 08, 2013 at 12:51:52PM -0800, Eric W. Biederman wrote:
> The return value of d_mountpoint can be obsolete as soon as it returns
> as well, so I don't see this as being significantly different.
Not if the ->i_mutex of that sucker is held. And it *is* held in
vfs_unlink/vfs_rmdir/vfs_rename. Note that we only care about a mountpoint
being falsely assumed to be a non-mountpoint - in the other direction we
can just shrug and say that we'd won the race and got EBUSY for that.
> In 3.12 vfs_rmdir checks d_mountpoint with the
> dentry->d_inode->i_mutex and
> dentry->d_parent->d_inode->i_mutex held.
>
> In 3.12 vfs_unlink checks d_mountpoint with the
> dentry->d_inode->i_mutex and
> dentry->d_parent->d_inode->i_mutex hel.d
>
> In 3.12 vfs_rename_dir and vfs_rename_other checks d_mountpint with the
> target->i_mutex, new_dir->i_mutex, and old_dir->i_mutex held.
>
>
> Therefore the guarantees in 3.12 are:
> - unlink versus mount races are prevented by the
> dentry->d_inode->i_mutex of the dentry being removed.
> - unlink versus umount races are uninteresting.
> - mount versus rename races in testing of d_mountpoint are ignored.
Read what you've written a few lines above. The part about target->i_mutex
being held.
> So comparing this to how I have implemented covered the test is at a
> slightly different location in the call path so there may be a slightly
> larger race in rename.
You've got a race in unlink. You've got a race in rename. You've got a race
in rmdir. And none of those had that race in 3.12 (including rename()).
BTW, could you describe the races with umount in a bit more details? Races
with mount are simple - rmdir() sees that victim isn't a mountpoint and
proceeds, mount() sees that victim is still alive and proceeds, despite
the fact that victim is irretrievably on the way to removal. And that's
what ->i_mutex on victim prevents, making "check for d_mountpoint / remove /
call dont_mount()" atomic wrt mount(). What is the problem you are seeing
with umount()? rmdir() getting EBUSY because it hasn't noticed umount()
happening in parallel with it? Legitimate behaviour, as far I can see...
Or is it about something different?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists