From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
syzbot <syzbot+1107451c16b9eb9d29e6@syzkaller.appspotmail.com>,
Viacheslav Dubeyko <slava@dubeyko.com>,
Sasha Levin <sashal@kernel.org>,
frank.li@vivo.com, linux-fsdevel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.1 04/16] hfsplus: don't use BUG_ON() in hfsplus_create_attributes_file()
Date: Sun, 3 Aug 2025 17:21:14 -0400 [thread overview]
Message-ID: <20250803212127.3548367-4-sashal@kernel.org> (raw)
In-Reply-To: <20250803212127.3548367-1-sashal@kernel.org>
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
[ Upstream commit c7c6363ca186747ebc2df10c8a1a51e66e0e32d9 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
**Backport Status: YES**
This commit should be backported to stable kernel trees for the
following reasons:
1. **Fixes a Critical Bug**: The commit replaces a `BUG_ON()` that could
crash the entire system with proper error handling. The original code
at line 175 had `BUG_ON(i_size_read(attr_file) != 0);` which would
trigger a kernel panic when the HFS+ filesystem metadata is corrupted
or inconsistent.
2. **Real-World Issue**: This was reported by syzbot (a kernel fuzzer),
indicating it's a reachable code path that can be triggered with
malformed filesystem data. The bug report link confirms this is a
reproducible issue.
3. **Simple and Contained Fix**: The change is minimal - it replaces the
BUG_ON with:
```c
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;
}
```
This is a straightforward conversion that maintains the same logic but
handles the error gracefully.
4. **Prevents System Crashes**: BUG_ON() causes a kernel panic, which is
particularly severe. Converting it to return -EIO allows the system
to continue running and provides users with actionable guidance (run
fsck.hfsplus).
5. **Low Risk of Regression**: The change only affects error handling
when filesystem corruption is detected. It doesn't alter normal
operation paths and follows established error handling patterns in
the kernel.
6. **Follows Stable Tree Rules**: This is a classic example of a stable-
worthy fix:
- Fixes a real bug (system crash on corrupted filesystem)
- Small, easily reviewable change
- No new features or architectural changes
- High benefit (prevents crashes) with minimal risk
The commit message clearly indicates this addresses filesystem
corruption scenarios where "the volume header contains erroneous values
that do not reflect the actual state of the filesystem," making it an
important robustness improvement for stable kernels.
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 2b0e0ba58139..beedc1a2237a 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);
+ 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);
--
2.39.5
next prev parent reply other threads:[~2025-08-03 21:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-03 21:21 [PATCH AUTOSEL 6.1 01/16] hfs: fix slab-out-of-bounds in hfs_bnode_read() Sasha Levin
2025-08-03 21:21 ` [PATCH AUTOSEL 6.1 02/16] hfsplus: fix slab-out-of-bounds in hfsplus_bnode_read() Sasha Levin
2025-08-03 21:21 ` [PATCH AUTOSEL 6.1 03/16] hfsplus: fix slab-out-of-bounds read in hfsplus_uni2asc() Sasha Levin
2025-08-03 21:21 ` Sasha Levin [this message]
2025-08-03 21:21 ` [PATCH AUTOSEL 6.1 09/16] hfs: fix not erasing deleted b-tree node issue Sasha Levin
2025-08-03 21:21 ` [PATCH AUTOSEL 6.1 10/16] better lockdep annotations for simple_recursive_removal() Sasha Levin
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=20250803212127.3548367-4-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=frank.li@vivo.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=slava@dubeyko.com \
--cc=stable@vger.kernel.org \
--cc=syzbot+1107451c16b9eb9d29e6@syzkaller.appspotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).