Re: [PATCH] ntfs: bound $AttrDef table walk to the loaded table size
From: Namjae Jeon
Date: Tue Aug 25 2026 - 01:28:25 EST
> @@ -1737,7 +1737,7 @@ static struct attr_def *ntfs_attr_find_in_attrdef(const struct ntfs_volume *vol,
> struct attr_def *ad;
>
> WARN_ON(!type);
> - for (ad = vol->attrdef; (u8 *)ad - (u8 *)vol->attrdef <
> + for (ad = vol->attrdef; (u8 *)(ad + 1) - (u8 *)vol->attrdef <=
I would prefer not to have ad + 1 check form a pointer beyond the end
of the buffer after the last entry.
How about this instead ?
(u8 *)ad - (u8 *)vol->attrdef <=
vol->attrdef_size - (s32)sizeof(*ad)
Thanks.
> vol->attrdef_size && ad->type; ++ad) {
> /* We have not found it yet, carry on searching. */
> if (likely(le32_to_cpu(ad->type) < le32_to_cpu(type)))