From: Al Viro <viro@ZenIV.linux.org.uk>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: dave@linux.vnet.ibm.com, akpm@linux-foundation.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 7/9 updated] vfs: protect remounting superblock read-only
Date: Sat, 23 Oct 2010 17:19:48 +0100 [thread overview]
Message-ID: <20101023161948.GP19804@ZenIV.linux.org.uk> (raw)
In-Reply-To: <E1P9KFl-0005ZK-0q@pomaz-ex.szeredi.hu>
On Fri, Oct 22, 2010 at 06:14:01PM +0200, Miklos Szeredi wrote:
> @@ -1782,6 +1844,14 @@ int do_add_mount(struct vfsmount *newmnt
>
> mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL);
Obviously not enough - you've just added a new flag that needs to be
trimmed from mnt_flags.
> + /* Locking is necessary to prevent racing with remount r/o */
> + down_read(&newmnt->mnt_sb->s_umount);
> + if (newmnt->mnt_sb->s_flags & MS_RDONLY)
> + mnt_flags |= MNT_READONLY;
> +
> + newmnt->mnt_flags = mnt_flags;
> + up_read(&newmnt->mnt_sb->s_umount);
FWIW, I really don't like the way you are doing that; what we really need
there is a per-sb analog of mnt_want_write()/mnt_drop_write(). With
mnt_want_write() bumping per-sb write count, which would solve all these
problems quite nicely.
NOTE: vfsmount being ro and sb being ro are *independent* things; either
is enough to deny writes. Having remount ro + remount rw lose the state
of other vfsmounts is a Bad Thing(tm).
Another thing:
"If clone_mnt() happens while mnt_make_readonly() is running, the
cloned mount might have MNT_WRITE_HOLD flag set, which results in
mnt_want_write() spinning forever on this mount."
actually means
"neither clone_mnt() nor remounts should ever be done without
namespace_sem held exclusive; if that ever happens, we have a serious
bug that can lead to any number of bad things happening".
Do you actually see such places? If so, that's what needs fixing.
next prev parent reply other threads:[~2010-10-23 16:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 10:31 [PATCH 0/9] read-only remount fixes Miklos Szeredi
2010-10-05 10:31 ` [PATCH 1/9] vfs: fix infinite loop caused by clone_mnt race Miklos Szeredi
2010-10-05 10:49 ` Miklos Szeredi
2010-10-05 10:31 ` [PATCH 2/9] vfs: ignore error on forced remount Miklos Szeredi
2010-10-05 10:31 ` [PATCH 3/9] vfs: fix per mount read-write Miklos Szeredi
2010-10-05 10:31 ` [PATCH 4/9] vfs: add sb_force_remount_readonly() helper Miklos Szeredi
2010-10-05 10:31 ` [PATCH 5/9] vfs: allow mnt_want_write() to sleep Miklos Szeredi
2010-10-05 10:31 ` [PATCH 6/9] vfs: keep list of mounts for each superblock Miklos Szeredi
2010-10-05 10:31 ` [PATCH 7/9] vfs: protect remounting superblock read-only Miklos Szeredi
2010-10-22 6:46 ` Al Viro
2010-10-22 12:25 ` Miklos Szeredi
2010-10-22 16:10 ` Miklos Szeredi
2010-10-22 16:14 ` [PATCH 7/9 updated] " Miklos Szeredi
2010-10-23 16:19 ` Al Viro [this message]
2010-10-23 19:35 ` Miklos Szeredi
2010-10-23 21:42 ` Al Viro
2010-10-25 12:36 ` Miklos Szeredi
2010-10-05 10:31 ` [PATCH 8/9] vfs: fs_may_remount_ro: turn unnecessary check into a WARN_ON Miklos Szeredi
2010-10-05 10:31 ` [PATCH 9/9] vfs: mark mounts read-only on forced remount 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=20101023161948.GP19804@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.