Skip to content

Commit c7c6363

Browse files
Tetsuo Handadubeyko
authored andcommitted
hfsplus: don't use BUG_ON() in hfsplus_create_attributes_file()
When the volume header contains erroneous values that do not reflect the actual state of the filesystem, hfsplus_fill_super() assumes that the attributes file is not yet created, which later results in hitting BUG_ON() when hfsplus_create_attributes_file() is called. Replace this BUG_ON() with -EIO error with a message to suggest running fsck tool. Reported-by: syzbot <[email protected]> Closes: https://syzkaller.appspot.com/bug?extid=1107451c16b9eb9d29e6 Signed-off-by: Tetsuo Handa <[email protected]> Reviewed-by: Viacheslav Dubeyko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Viacheslav Dubeyko <[email protected]>
1 parent 4c6a567 commit c7c6363

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/hfsplus/xattr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ static int hfsplus_create_attributes_file(struct super_block *sb)
172172
return PTR_ERR(attr_file);
173173
}
174174

175-
BUG_ON(i_size_read(attr_file) != 0);
175+
if (i_size_read(attr_file) != 0) {
176+
err = -EIO;
177+
pr_err("detected inconsistent attributes file, running fsck.hfsplus is recommended.\n");
178+
goto end_attr_file_creation;
179+
}
176180

177181
hip = HFSPLUS_I(attr_file);
178182

0 commit comments

Comments
 (0)