Re: [syzbot] [hfs?] possible deadlock in hfsplus_file_extend (2)

From: Edward Adam Davis
Date: Mon Nov 11 2024 - 08:17:02 EST


AA lock, unlock for hfs_bmap_reserve.

#syz test

diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index a6d61685ae79..1742e43ece58 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -101,7 +101,9 @@ static int __hfsplus_ext_write_extent(struct inode *inode,
if (res != -ENOENT)
return res;
/* Fail early and avoid ENOSPC during the btree operation */
+ mutex_unlock(&hip->extents_lock);
res = hfs_bmap_reserve(fd->tree, fd->tree->depth + 1);
+ mutex_lock(&hip->extents_lock);
if (res)
return res;
hfs_brec_insert(fd, hip->cached_extents,