From: Jan Kara <jack@suse.cz>
To: Miklos Szeredi <mszeredi@suse.cz>
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
Miklos Szeredi <miklos@szeredi.hu>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
jack@suse.cz, hch@infradead.org, akpm@linux-foundation.org,
toshi.okajima@jp.fujitsu.com
Subject: Re: [PATCH 2/4] vfs: keep list of mounts for each superblock
Date: Thu, 4 Aug 2011 11:46:16 +0200 [thread overview]
Message-ID: <20110804094616.GC17196@quack.suse.cz> (raw)
In-Reply-To: <1312449054.6032.22.camel@tucsk.pomaz.szeredi.hu>
On Thu 04-08-11 11:10:54, Miklos Szeredi wrote:
> On Wed, 2011-08-03 at 23:17 +0100, Al Viro wrote:
> > On Wed, Aug 03, 2011 at 12:48:39PM +0200, Miklos Szeredi wrote:
> > > @@ -696,6 +696,11 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
> > > mnt->mnt_sb = root->d_sb;
> > > mnt->mnt_mountpoint = mnt->mnt_root;
> > > mnt->mnt_parent = mnt;
> > > +
> > > + br_write_lock(vfsmount_lock);
> > > + list_add_tail(&mnt->mnt_instance, &mnt->mnt_sb->s_mounts);
> > > + br_write_unlock(vfsmount_lock);
> >
> > Racy.
> >
> > > @@ -745,6 +750,10 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root,
> > > if (!list_empty(&old->mnt_expire))
> > > list_add(&mnt->mnt_expire, &old->mnt_expire);
> > > }
> > > +
> > > + br_write_lock(vfsmount_lock);
> > > + list_add_tail(&mnt->mnt_instance, &mnt->mnt_sb->s_mounts);
> > > + br_write_unlock(vfsmount_lock);
> >
> > Ditto. If you expect to be able to find *all* vfsmounts over given sb,
> > this locking is simply wrong.
>
> I don't understand. All accesses to mnt_instance/s_mounts are protected
> by vfsmount_lock. What else is needed?
I guess Al meant that sb_prepare_remount_readonly() from the next patch
could race with new mountpoint being added to the list and the check is
thus still unreliable? Quickly checking the locking seems to confirm that
since e.g. clone_mnt() does not hold s_umount semaphore (only
namespace_sem?) and do_remount_sb() has it the other way around...
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2011-08-04 9:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 10:48 [PATCH v5 0/4] read-only remount race fix Miklos Szeredi
2011-08-03 10:48 ` [PATCH 1/4] vfs: ignore error on forced remount Miklos Szeredi
2011-08-03 10:49 ` Christoph Hellwig
2011-08-03 16:15 ` Miklos Szeredi
2011-08-03 10:48 ` [PATCH 2/4] vfs: keep list of mounts for each superblock Miklos Szeredi
2011-08-03 21:53 ` Christoph Hellwig
2011-08-03 22:17 ` Al Viro
2011-08-04 9:10 ` Miklos Szeredi
2011-08-04 9:46 ` Jan Kara [this message]
2011-08-04 9:58 ` Miklos Szeredi
2011-08-03 10:48 ` [PATCH 3/4] vfs: protect remounting superblock read-only Miklos Szeredi
2011-08-03 10:48 ` [PATCH 4/4] vfs: fs_may_remount_ro: turn unnecessary check into a WARN_ON Miklos Szeredi
[not found] <1314191791-29218-1-git-send-email-miklos@szeredi.hu>
2011-08-24 13:22 ` [PATCH 2/4] vfs: keep list of mounts for each superblock Miklos Szeredi
-- strict thread matches above, loose matches on Subject: below --
2010-10-26 14:16 [PATCH 0/4] read-only remount fixes Miklos Szeredi
2010-10-26 14:16 ` [PATCH 2/4] vfs: keep list of mounts for each superblock Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110804094616.GC17196@quack.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mszeredi@suse.cz \
--cc=toshi.okajima@jp.fujitsu.com \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).