Re: [PATCH v3] ntfs: validate non-resident attribute offsets
From: Hongling Zeng
Date: Thu Aug 06 2026 - 21:59:30 EST
在 2026年08月06日 21:17, Namjae Jeon 写道:
You're absolutely correct, Thanks for the guidance and applied the patch . I now understand that ATTR_COMPRESSION_MASK+ /* Ensure there's room for the compressed_size field if needed. */Sorry for the confusion. I rechecked the code and realized that
+ if (!(a->flags & ATTR_IS_SPARSE) &&
+ !(a->flags & ATTR_IS_COMPRESSED) &&
+ attr_len - mp_offset < sizeof(a->data.non_resident.compressed_size))
+ return false;
ATTR_COMPRESSION_MASK is correct here. It covers the entire
compression field, while ATTR_IS_COMPRESSED checks only the 0x0001
bit. Since this validation checks whether the attribute layout
includes compressed_size, it should use the mask, consistent with the
existing min_len check. So I have applied the previously attached
patch.
Thanks!
(0x00ff) is the correct choice—it covers all compression cases, not just the 0x0001 flag.