mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "kartikey406@gmail.com" <kartikey406@gmail.com>
Cc: "glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
	"frank.li@vivo.com" <frank.li@vivo.com>,
	"slava@dubeyko.com" <slava@dubeyko.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"syzbot+d80abb5b890d39261e72@syzkaller.appspotmail.com"
	<syzbot+d80abb5b890d39261e72@syzkaller.appspotmail.com>
Subject: RE: [PATCH] hfsplus: fix uninit-value in hfsplus_strcasecmp
Date: Mon, 26 Jan 2026 20:37:28 +0000	[thread overview]
Message-ID: <31dcca48613697b220c92367723f16dad7b1b17a.camel@ibm.com> (raw)
In-Reply-To: <CADhLXY6fMO51pxc1P00F3g9PccNvXwOPd+g0FxeHq1FYGR3Xng@mail.gmail.com>

On Sat, 2026-01-24 at 08:16 +0530, Deepanshu Kartikey wrote:
> On Sat, Jan 24, 2026 at 4:51 AM Viacheslav Dubeyko
> <Slava.Dubeyko@ibm.com> wrote:
> > 
> > 
> > If the whole fix will be small, then one patch is better to have. Otherwise,
> > patchset could be more better for the review.
> > 
> 
> Hi Slava,
> 
> Thank you for the guidance! Based on your feedback and the debug output showing
> the partial read (26 bytes read, 520 expected), here's my proposed fix.
> 
> I'd appreciate your review before I send the formal patch.
> 
> ---
> 
> The fix includes two changes:
> 
> 1. Add validation in hfs_brec_read() to reject partial reads:
> 
> int hfs_brec_read(struct hfs_find_data *fd, void *rec, u32 rec_len)
> {
> int res;
> 
> res = hfs_brec_find(fd, hfs_find_rec_by_key);
> if (res)
> return res;
> if (fd->entrylength > rec_len)
> return -EINVAL;
> ++ if (fd->entrylength < rec_len) {

It looks like we can simply combined to check into one:

if (fd->entrylength != rec_len)

However, I am not completely sure that it's completely correct fix. Because, for
example, hfs_cat_find_brec() tries to read hfs_cat_rec union:

	hfs_cat_build_key(sb, fd->search_key, cnid, NULL);
	res = hfs_brec_read(fd, &rec, sizeof(rec));
	if (res)
		return res;

It means that we provide the bigger length that it is required for struct
hfs_cat_file or struct hfs_cat_dir. It sounds to me that the reading of these
records will be rejected. Am I wrong here? 

> ++ pr_err("hfsplus: incomplete catalog record (got %u, expected %u)\n",
> ++        fd->entrylength, rec_len);

It doesn't need to mention "hfsplus:" in error message.

> ++ return -EINVAL;
> ++ }
> hfs_bnode_read(fd->bnode, rec, fd->entryoffset, fd->entrylength);
> return 0;
> }
> 
> 2. Initialize tmp in hfsplus_find_cat() as defensive programming:
> 
> int hfsplus_find_cat(struct super_block *sb, u32 cnid,
>      struct hfs_find_data *fd)
> {
> -- hfsplus_cat_entry tmp;
> ++ hfsplus_cat_entry tmp = {0};
> int err;
> u16 type;
> ...
> }
> 
> ---
> 
> Does this look correct to you? Should I proceed with this approach, or would
> you suggest any modifications?
> 
> 

Please, see my comments above.

Thanks,
Slava.

[1] https://elixir.bootlin.com/linux/v6.19-rc5/source/fs/hfs/catalog.c#L194

  reply	other threads:[~2026-01-26 20:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20  5:11 Deepanshu Kartikey
2026-01-20 22:29 ` Viacheslav Dubeyko
2026-01-21  6:26   ` Deepanshu Kartikey
2026-01-21 20:11     ` Viacheslav Dubeyko
2026-01-23  1:48       ` Deepanshu Kartikey
2026-01-23 23:21         ` Viacheslav Dubeyko
2026-01-24  2:46           ` Deepanshu Kartikey
2026-01-26 20:37             ` Viacheslav Dubeyko [this message]
2026-01-27  8:20               ` Deepanshu Kartikey
2026-01-27 23:21                 ` Viacheslav Dubeyko
2026-01-28  4:29                   ` Deepanshu Kartikey
2026-01-29 20:56                     ` 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=31dcca48613697b220c92367723f16dad7b1b17a.camel@ibm.com \
    --to=slava.dubeyko@ibm.com \
    --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+d80abb5b890d39261e72@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®