linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer@redhat.com>
To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org
Cc: raven@themaw.net
Subject: [patch] fs: fix use after free in get_tree_bdev
Date: Mon, 10 Feb 2020 13:10:15 -0500	[thread overview]
Message-ID: <x49a75q1fg8.fsf@segfault.boston.devel.redhat.com> (raw)

Commit 6fcf0c72e4b9 ("vfs: add missing blkdev_put() in get_tree_bdev()")
introduced a use-after-free of the bdev.  This was caught by fstests
generic/085, which now results in a kernel panic.  Fix it.

Cc: stable@vger.kernel.org # v5.4+
Fixes: 6fcf0c72e4b9 ("vfs: add missing blkdev_put() in get_tree_bdev()")
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

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


             reply	other threads:[~2020-02-10 18:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 18:10 Jeff Moyer [this message]
2020-02-11  9:52 ` [patch] fs: fix use after free in get_tree_bdev Ian Kent

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=x49a75q1fg8.fsf@segfault.boston.devel.redhat.com \
    --to=jmoyer@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=raven@themaw.net \
    --cc=viro@zeniv.linux.org.uk \
    /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 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).