]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hfsplus: don't use BUG_ON() in hfsplus_create_attributes_file()
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tue, 15 Jul 2025 05:17:56 +0000 (14:17 +0900)
committerViacheslav Dubeyko <slava@dubeyko.com>
Fri, 25 Jul 2025 22:22:00 +0000 (15:22 -0700)
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 <syzbot+1107451c16b9eb9d29e6@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=1107451c16b9eb9d29e6
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
Link: https://lore.kernel.org/r/7b587d24-c8a1-4413-9b9a-00a33fbd849f@I-love.SAKURA.ne.jp
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
fs/hfsplus/xattr.c

index 9a1a93e3888b9297e4d8b7b21dfe3612d1eb9ed4..18dc3d254d218ccfa2800fdb7dd5d262953e0aa7 100644 (file)
@@ -172,7 +172,11 @@ check_attr_tree_state_again:
                return PTR_ERR(attr_file);
        }
 
-       BUG_ON(i_size_read(attr_file) != 0);
+       if (i_size_read(attr_file) != 0) {
+               err = -EIO;
+               pr_err("detected inconsistent attributes file, running fsck.hfsplus is recommended.\n");
+               goto end_attr_file_creation;
+       }
 
        hip = HFSPLUS_I(attr_file);