Re: [PATCH] hfsplus: don't use BUG_ON() in hfsplus_create_attributes_file()

From: Yangtao Li
Date: Mon Jul 07 2025 - 10:23:10 EST


在 2025/7/1 01:18, Viacheslav Dubeyko 写道:
On Wed, 2025-06-25 at 19:10 +0900, Tetsuo Handa wrote:
syzkaller can mount crafted filesystem images.
Don't crash the kernel when we can continue.

Reported-by: syzbot <syzbot+1107451c16b9eb9d29e6@xxxxxxxxxxxxxxxxxxxxxxxxx>
Closes: https://syzkaller.appspot.com/bug?extid=1107451c16b9eb9d29e6
Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
---
fs/hfsplus/xattr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index 9a1a93e3888b..191767d4cf78 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -172,7 +172,11 @@ static int hfsplus_create_attributes_file(struct super_block *sb)
return PTR_ERR(attr_file);
}
- BUG_ON(i_size_read(attr_file) != 0);

So, it's something like unexpected situation here. Why do we have
i_size_read(attr_file) != 0 here? It looks like hfsplus_create_attributes_file()
was called in incorrect context. Probably, it's not the whole fix. Any ideas?

161 case HFSPLUS_VALID_ATTR_TREE:
162 return 0;
163 case HFSPLUS_FAILED_ATTR_TREE:
164 return -EOPNOTSUPP;
165 default:
166 BUG();
167 }

I haven't delved into the implementation details of xattr yet, but there is a bug in this function. It seems that we should convert the bug to return EIO in another patch?

Otherwise LGTM.

Reviewed-by: Yangtao Li <frank.li@xxxxxxxx>

Thx,
Yangtao