From: Viacheslav Dubeyko <vdubeyko@redhat.com>
To: Deepanshu Kartikey <kartikey406@gmail.com>,
slava@dubeyko.com, glaubitz@physik.fu-berlin.de,
frank.li@vivo.com
Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+c0ba772a362e70937dfb@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] hfsplus: fix ignored error return in hfsplus_delete_cat
Date: Tue, 14 Apr 2026 12:29:29 -0700 [thread overview]
Message-ID: <f2707a743d06df045daa314bcd1564257b4f83a5.camel@redhat.com> (raw)
In-Reply-To: <20260414015630.65081-1-kartikey406@gmail.com>
On Tue, 2026-04-14 at 07:26 +0530, Deepanshu Kartikey wrote:
> hfsplus_delete_cat() calls hfsplus_delete_all_attrs() to remove all
> extended attributes associated with a catalog entry, but silently
> discards its return value.
>
> When the xattr deletion fails on a corrupt filesystem image (as
> triggered by syzbot), hfsplus_delete_cat() incorrectly returns 0
> (success) to its callers, allowing execution to continue with the
> filesystem in an inconsistent state and eventually triggering a
> general protection fault in hfsplus_cat_write_inode().
>
> Fix this by capturing the return value of hfsplus_delete_all_attrs()
> and propagating genuine errors back to the caller. -ENOENT is
> excluded since it signals normal loop termination (no more xattrs
> left to delete) and is not an error condition.
>
Frankly speaking, I don't quite follow how your fix relates to the initial
problem?
vfs_unlink+0x272/0x6d0 fs/namei.c:5476
error = dir->i_op->unlink(dir, dentry);
hfsplus_unlink+0x57a/0x930 fs/hfsplus/dir.c:435
res = hfsplus_cat_write_inode(sbi->hidden_dir);
RIP: 0010:hfsplus_cat_write_inode+0xbe/0x8f0 fs/hfsplus/inode.c:637
struct hfs_btree *tree = HFSPLUS_SB(inode->i_sb)->cat_tree;
It looks like that sbi->hidden_dir is NULL and this is why crash here.
But how have it happened at first place?
> Changes in v2:
> - Fixed commit message: hfsplus_delete_cat() is called from multiple
> callers (hfsplus_unlink, hfsplus_rmdir, hfsplus_rename,
> hfsplus_evict_inode, hfsplus_fill_super), not just hfsplus_unlink()
> as incorrectly stated in v1.
>
> Fixes: 324ef39a8a4f ("hfsplus: add support of manipulation by attributes file")
> Reported-by: syzbot+c0ba772a362e70937dfb@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=c0ba772a362e70937dfb
> Tested-by: syzbot+c0ba772a362e70937dfb@syzkaller.appspotmail.com
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
> fs/hfsplus/catalog.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
> index 02c1eee4a4b8..adbaeabc06ab 100644
> --- a/fs/hfsplus/catalog.c
> +++ b/fs/hfsplus/catalog.c
> @@ -421,8 +421,15 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str)
> hfsplus_mark_inode_dirty(dir, HFSPLUS_I_CAT_DIRTY);
>
> if (type == HFSPLUS_FILE || type == HFSPLUS_FOLDER) {
> - if (HFSPLUS_SB(sb)->attr_tree)
> - hfsplus_delete_all_attrs(dir, cnid);
> + if (HFSPLUS_SB(sb)->attr_tree) {
> + int attr_err = hfsplus_delete_all_attrs(dir, cnid);
It looks like that this code is generated by Claude AI or something like this.
Thanks,
Slava.
> +
> + if (attr_err && attr_err != -ENOENT) {
> + pr_err("hfsplus: failed to delete xattrs for cnid %u: %d\n",
> + cnid, attr_err);
> + err = attr_err;
> + }
> + }
> }
>
> out:
next prev parent reply other threads:[~2026-04-14 19:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 1:56 Deepanshu Kartikey
2026-04-14 19:29 ` Viacheslav Dubeyko [this message]
2026-04-15 1:40 ` Deepanshu Kartikey
2026-04-15 21:20 ` Viacheslav Dubeyko
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=f2707a743d06df045daa314bcd1564257b4f83a5.camel@redhat.com \
--to=vdubeyko@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=kartikey406@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=slava@dubeyko.com \
--cc=syzbot+c0ba772a362e70937dfb@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
all inboxes | Powered by JetHome®