Linux-Fsdevel Archive on
help / color / mirror / Atom feed
From: Sasha Levin <>
Cc: David Howells <>,
	Lukas Czerner <>, Ian Kent <>,
	Al Viro <>,
	Linus Torvalds <>,
	Sasha Levin <>,
Subject: [PATCH AUTOSEL 5.6 38/50] Fix use after free in get_tree_bdev()
Date: Thu,  7 May 2020 10:27:14 -0400	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

From: David Howells <>

[ Upstream commit dd7bc8158b413e0b580c491e8bd18cb91057c7c2 ]

Commit 6fcf0c72e4b9, a fix to get_tree_bdev() put a missing blkdev_put() in
the wrong place, before a warnf() that displays the bdev under
consideration rather after it.

This results in a silent lockup in printk("%pg") called via warnf() from
get_tree_bdev() under some circumstances when there's a race with the
blockdev being frozen.  This can be caused by xfstests/tests/generic/085 in
combination with Lukas Czerner's ext4 mount API conversion patchset.  It
looks like it ought to occur with other users of get_tree_bdev() such as
XFS, but apparently doesn't.

Fix this by switching the order of the lines.

Fixes: 6fcf0c72e4b9 ("vfs: add missing blkdev_put() in get_tree_bdev()")
Reported-by: Lukas Czerner <>
Signed-off-by: David Howells <>
cc: Ian Kent <>
cc: Al Viro <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Sasha Levin <>
 fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/super.c b/fs/super.c
index cd352530eca90..a288cd60d2aed 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1302,8 +1302,8 @@ int get_tree_bdev(struct fs_context *fc,
 	if (bdev->bd_fsfreeze_count > 0) {
-		blkdev_put(bdev, mode);
 		warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev);
+		blkdev_put(bdev, mode);
 		return -EBUSY;

       reply	other threads:[~2020-05-07 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <>
2020-05-07 14:27 ` Sasha Levin [this message]
2020-05-07 14:27 ` [PATCH AUTOSEL 5.6 42/50] fibmap: Warn and return an error in case of block > INT_MAX Sasha Levin
2020-05-07 14:27 ` [PATCH AUTOSEL 5.6 45/50] io_uring: use cond_resched() in io_ring_ctx_wait_and_kill() Sasha Levin

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH AUTOSEL 5.6 38/50] Fix use after free in get_tree_bdev()' \

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