From: Christian Brauner <brauner@kernel.org>
To: Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@lst.de>
Cc: reiserfs-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
syzbot+062317ea1d0a6d5e29e7@syzkaller.appspotmail.com,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH 4/4] reiserfs: fix journal device opening
Date: Mon, 09 Oct 2023 14:33:41 +0200 [thread overview]
Message-ID: <20231009-vfs-fixes-reiserfs-v1-4-723a2f1132ce@kernel.org> (raw)
In-Reply-To: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org>
We can't open devices with s_umount held without risking deadlocks.
So drop s_umount and reacquire it when opening the journal device.
Reported-by: syzbot+062317ea1d0a6d5e29e7@syzkaller.appspotmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/reiserfs/journal.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index e001a96fc76c..0c680de72d43 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -2714,7 +2714,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
struct reiserfs_journal_header *jh;
struct reiserfs_journal *journal;
struct reiserfs_journal_list *jl;
- int ret;
+ int ret = 1;
journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal));
if (!journal) {
@@ -2727,6 +2727,13 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
INIT_LIST_HEAD(&journal->j_working_list);
INIT_LIST_HEAD(&journal->j_journal_list);
journal->j_persistent_trans = 0;
+
+ /*
+ * blkdev_put() can't be called under s_umount, see the comment
+ * in get_tree_bdev() for more details
+ */
+ up_write(&sb->s_umount);
+
if (reiserfs_allocate_list_bitmaps(sb, journal->j_list_bitmap,
reiserfs_bmap_count(sb)))
goto free_and_return;
@@ -2891,8 +2898,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
goto free_and_return;
}
- ret = journal_read(sb);
- if (ret < 0) {
+ if (journal_read(sb) < 0) {
reiserfs_warning(sb, "reiserfs-2006",
"Replay Failure, unable to mount");
goto free_and_return;
@@ -2900,10 +2906,14 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
INIT_DELAYED_WORK(&journal->j_work, flush_async_commits);
journal->j_work_sb = sb;
- return 0;
+ ret = 0;
+
free_and_return:
- free_journal_ram(sb);
- return 1;
+ if (ret)
+ free_journal_ram(sb);
+
+ down_write(&sb->s_umount);
+ return ret;
}
/*
--
2.34.1
next prev parent reply other threads:[~2023-10-09 12:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 12:33 [PATCH 0/4] reiserfs: fixes Christian Brauner
2023-10-09 12:33 ` [PATCH 1/4] reiserfs: user superblock as holder for journal device Christian Brauner
2023-10-09 14:12 ` Jan Kara
2023-10-09 12:33 ` [PATCH 2/4] reiserfs: centralize freeing of reiserfs info Christian Brauner
2023-10-09 14:15 ` Jan Kara
2023-10-09 12:33 ` [PATCH 3/4] reiserfs: centralize journal device closing Christian Brauner
2023-10-09 14:20 ` Jan Kara
2023-10-09 12:33 ` Christian Brauner [this message]
2023-10-09 14:25 ` [PATCH 4/4] reiserfs: fix journal device opening Jan Kara
2023-10-09 16:16 ` Christian Brauner
2023-10-09 16:33 ` Jan Kara
[not found] ` <CAHrFyr6sjz+MM4vAzwHKwasuQi=_dhGM+3JAJkp8A0Hu4gDtbg@mail.gmail.com>
2023-10-10 12:41 ` Jan Kara
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=20231009-vfs-fixes-reiserfs-v1-4-723a2f1132ce@kernel.org \
--to=brauner@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=reiserfs-devel@vger.kernel.org \
--cc=syzbot+062317ea1d0a6d5e29e7@syzkaller.appspotmail.com \
/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).