ext4: detect invalid INLINE_DATA + EXTENTS flag combination
Zhang Yi,
Thank you for the review. Regarding the placement after ext4_set_inode_flags() - this would be too early. My debug shows that i_inline_off changes during inode initialization:
After ext4_set_inode_flags(): flag=1, i_inline_off=0, has_inline=0 Before my patch validation check: flag=1, i_inline_off=164, has_inline=1
At the earlier point, ext4_has_inline_data() returns false, so we wouldn't catch the corruption. The check needs to be after all inode fields are initialized.
I'll fix the alignment and use function/line variables as you suggested, but keep the check after "ret = 0;" where all inode fields are populated.
I'll send v3 with these fixes shortly.
Best regards,
Deepanshu
Quoted 6 lines · Deepanshu Kartikey
Zhang Yi,
Thank you for the review. Regarding the placement after
ext4_set_inode_flags()- this would be too early. My debug shows thati_inline_offchanges during inode initialization:
Quoted 6 lines
After
ext4_set_inode_flags(): flag=1, i_inline_off=0, has_inline=0 Before my patch validation check: flag=1, i_inline_off=164, has_inline=1At the earlier point,
ext4_has_inline_data()returns false, so we wouldn't catch the corruption. The check needs to be after all inode fields are initialized.
The return value of ext4_has_inline_data() changed since ext4_iget_extra_inode() initialize the i_inline_off parameter from the ondisk inline xattr. However, in your v2 patch, you checked the EXT4_INODE_INLINE_DATA flags directly instead of the return value of ext4_has_inline_data(). The flags will not change, so it's safe to move this check eralier, and it is more reasonable to directly check the flags after getting flags from the disk and before checking inline xattr.
Thanks,
Yi.
Quoted 8 lines
I'll fix the alignment and use function/line variables as you suggested, but keep the check after "ret = 0;" where all inode fields are populated.
I'll send v3 with these fixes shortly.
Best regards,
Deepanshu