diff options
author | Oleg Nesterov <oleg@redhat.com> | 2016-09-26 18:07:48 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-10-12 09:18:03 +0200 |
commit | 7798893bcb2f565f03eecc1ded9eb79d57929b9e (patch) | |
tree | 0168b2b9f1b3f8736597d2266c15c5a3e6b0e4a1 /fs | |
parent | 9d3562bbfd343009c1541727e83fe7c1634b5722 (diff) | |
download | linux-rt-7798893bcb2f565f03eecc1ded9eb79d57929b9e.tar.gz |
fs/super.c: fix race between freeze_super() and thaw_super()
commit 89f39af129382a40d7cd1f6914617282cfeee28e upstream.
Change thaw_super() to check frozen != SB_FREEZE_COMPLETE rather than
frozen == SB_UNFROZEN, otherwise it can race with freeze_super() which
drops sb->s_umount after SB_FREEZE_WRITE to preserve the lock ordering.
In this case thaw_super() will wrongly call s_op->unfreeze_fs() before
it was actually frozen, and call sb_freeze_unlock() which leads to the
unbalanced percpu_up_write(). Unfortunately lockdep can't detect this,
so this triggers misc BUG_ON()'s in kernel/rcu/sync.c.
Reported-and-tested-by: Nikolay Borisov <kernel@kyup.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/super.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/super.c b/fs/super.c index eae088f6aaae..19fafe86071a 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1346,8 +1346,8 @@ int freeze_super(struct super_block *sb) } } /* - * This is just for debugging purposes so that fs can warn if it - * sees write activity when frozen is set to SB_FREEZE_COMPLETE. + * For debugging purposes so that fs can warn if it sees write activity + * when frozen is set to SB_FREEZE_COMPLETE, and for thaw_super(). */ sb->s_writers.frozen = SB_FREEZE_COMPLETE; up_write(&sb->s_umount); @@ -1366,7 +1366,7 @@ int thaw_super(struct super_block *sb) int error; down_write(&sb->s_umount); - if (sb->s_writers.frozen == SB_UNFROZEN) { + if (sb->s_writers.frozen != SB_FREEZE_COMPLETE) { up_write(&sb->s_umount); return -EINVAL; } |