LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org
Cc: jack@suse.cz, bart.vanassche@wdc.com, ming.lei@redhat.com,
	rjw@rjwysocki.net, mguzik@redhat.com, linux-pm@vger.kernel.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Luis R. Rodriguez" <mcgrof@kernel.org>
Subject: [PATCH 3/3] fs: fix corner case race on freeze_bdev() when sb disappears
Date: Fri, 20 Apr 2018 16:59:04 -0700	[thread overview]
Message-ID: <20180420235904.27496-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20180420235904.27496-1-mcgrof@kernel.org>

freeze_bdev() will bail but leave the bd_fsfreeze_count incremented
if the get_active_super() does not find the superblock on our
super_blocks list to match.

This issue has been present since v2.6.29 during the introduction of the
ioctl_fsfreeze() and ioctl_fsthaw() via commit fcccf502540e3 ("filesystem
freeze: implement generic freeze feature").

I am not aware of any existing races which have triggered this
situation, however, if it does trigger it could mean leaving a
superblock with bd_fsfreeze_count always positive.

Fixes: fcccf502540e3 ("filesystem freeze: implement generic freeze feature")
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 fs/block_dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index b54966679833..7a532aa58c07 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -507,8 +507,10 @@ struct super_block *freeze_bdev(struct block_device *bdev)
 	}
 
 	sb = get_active_super(bdev);
-	if (!sb)
+	if (!sb) {
+		bdev->bd_fsfreeze_count--;
 		goto out;
+	}
 	if (sb->s_op->freeze_super)
 		error = sb->s_op->freeze_super(sb);
 	else
-- 
2.16.3

  parent reply	other threads:[~2018-04-20 23:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 23:59 [PATCH 0/3] fs: minor fs thaw fixes and adjustments Luis R. Rodriguez
2018-04-20 23:59 ` [PATCH 1/3] fs: move documentation for thaw_super() where appropriate Luis R. Rodriguez
2018-04-21  0:01   ` Bart Van Assche
2018-04-21  0:07     ` Luis R. Rodriguez
2018-04-21  0:09       ` Randy Dunlap
2018-05-03 14:53   ` Jan Kara
2018-04-20 23:59 ` [PATCH 2/3] fs: make thaw_super_locked() really just a helper Luis R. Rodriguez
2018-05-03 15:07   ` Jan Kara
2018-04-20 23:59 ` Luis R. Rodriguez [this message]
2018-05-03 15:02   ` [PATCH 3/3] fs: fix corner case race on freeze_bdev() when sb disappears Jan Kara
2018-04-21  0:02 ` [PATCH 0/3] fs: minor fs thaw fixes and adjustments Luis R. Rodriguez

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=20180420235904.27496-4-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=bart.vanassche@wdc.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mguzik@redhat.com \
    --cc=ming.lei@redhat.com \
    --cc=rjw@rjwysocki.net \
    --cc=viro@zeniv.linux.org.uk \
    --subject='Re: [PATCH 3/3] fs: fix corner case race on freeze_bdev() when sb disappears' \
    /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

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).