]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commit
fs/super.c: fix race between freeze_super() and thaw_super()
authorOleg Nesterov <oleg@redhat.com>
Mon, 26 Sep 2016 16:07:48 +0000 (18:07 +0200)
committerIshan Mittal <imittal@nvidia.com>
Fri, 6 Jan 2017 10:15:49 +0000 (15:45 +0530)
commite857e52b05c54aab922577a821c0a6493acb463d
tree3e05d1d2fc5a050eabc8c58297e53f26493776a8
parent691b53246f0c13a14adebbad5db666960afc94ad
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>
fs/super.c