All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeongjun Park <aha310510@gmail.com>
To: syzbot+d472c32c5dd4cd2fb5c5@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [udf?] possible deadlock in udf_free_blocks
Date: Wed, 16 Apr 2025 00:42:54 +0900	[thread overview]
Message-ID: <20250415154254.15330-1-aha310510@gmail.com> (raw)
In-Reply-To: <67290b04.050a0220.2edce.14f8.GAE@google.com>

#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

---
 fs/udf/balloc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 807c493ed0cd..f70d13eaedce 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -657,8 +657,10 @@ void udf_free_blocks(struct super_block *sb, struct inode *inode,
 		     uint32_t count)
 {
 	uint16_t partition = bloc->partitionReferenceNum;
-	struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
+	struct udf_sb_info *sbi = UDF_SB(sb);
+	struct udf_part_map *map = &sbi->s_partmaps[partition];
 	uint32_t blk;
+	bool islocked = false;
 
 	if (check_add_overflow(bloc->logicalBlockNum, offset, &blk) ||
 	    check_add_overflow(blk, count, &blk) ||
@@ -670,6 +672,11 @@ void udf_free_blocks(struct super_block *sb, struct inode *inode,
 		return;
 	}
 
+	islocked = mutex_is_locked(&sbi->s_alloc_mutex);
+
+	if (islocked)
+		mutex_unlock(&sbi->s_alloc_mutex);
+
 	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
 		udf_bitmap_free_blocks(sb, map->s_uspace.s_bitmap,
 				       bloc, offset, count);
@@ -678,6 +685,9 @@ void udf_free_blocks(struct super_block *sb, struct inode *inode,
 				      bloc, offset, count);
 	}
 
+	if (islocked)
+		mutex_lock(&sbi->s_alloc_mutex);
+
 	if (inode) {
 		inode_sub_bytes(inode,
 				((sector_t)count) << sb->s_blocksize_bits);
--

  parent reply	other threads:[~2025-04-15 15:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04 17:57 [syzbot] [udf?] possible deadlock in udf_free_blocks syzbot
2024-12-03  3:56 ` syzbot
2024-12-03 12:41 ` syzbot
2024-12-03 13:01   ` Jan Kara
2024-12-11  4:53 ` syzbot
2025-04-15 15:12 ` Jeongjun Park
2025-04-15 15:36   ` syzbot
2025-04-15 15:42 ` Jeongjun Park [this message]
2025-04-15 18:33   ` syzbot

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=20250415154254.15330-1-aha310510@gmail.com \
    --to=aha310510@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+d472c32c5dd4cd2fb5c5@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.