Re: [PATCH v5] hfs: update sanity check of the root record
From: Tetsuo Handa
Date: Mon Mar 30 2026 - 21:14:09 EST
On 2026/03/31 6:45, Viacheslav Dubeyko wrote:
> I've already reviewed this patch. And I am not agree with this suggestion.
>
> We prepare the key with HFSPLUS_ROOT_CNID [1]:
>
> err = hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);
What we are talking about is not hfsplus but hfs.
I can't catch why you are talking about hfsplus function.
>
> The hfs_brec_read() executes the search of the record [2]:
>
> res = hfs_brec_find(fd);
> if (res)
> return res;
>
> The hfs_brec_find() should found the record for requested key. And if the found
> thread record contains not correct CNID, then we can check the found thread
> record and return error as the result of the search.
hfs_brec_read() indeed calls hfs_brec_find(). But I can't interpret how to extract
CNID as of returning from hfs_brec_find().
int hfs_brec_read(struct hfs_find_data *fd, void *rec, u32 rec_len)
{
int res;
res = hfs_brec_find(fd);
if (res)
return res;
if (fd->entrylength > rec_len)
return -EINVAL;
hfs_bnode_read(fd->bnode, rec, fd->entryoffset, fd->entrylength);
return 0;
}
Since hfs_brec_read() doesn't know which type of struct (one of "struct hfs_cat_file",
"struct hfs_cat_dir" or "struct hfs_cat_thread") does the caller of hfs_brec_read()
want to read, I don't think hfs_brec_read() can tell whether the CNID is correct.
I am waiting for your response on
https://lkml.kernel.org/r/9f66743b-70e0-4886-884e-5203f5c02ed8@xxxxxxxxxxxxxxxxxxx
where the caller of hfs_brec_read() can tell whether the CNID is correct. But such
change is a matter of preference.
You can respond with your patch which will be much faster.