Repository navigation
fix(ext4): Prevent group descriptor checksum mismatch for large filesystems - #463
Conversation
deitch
left a comment
There was a problem hiding this comment.
Solid catch, thank you for fixing. I dug in to see if I can figure out how that ended up as a uint16 (there must have been some reason), but I could not find it.
|
linting error. |
Fix group descriptor checksum verification for EXT4 filesystems with more than 65536 block groups. Previously, group numbers were truncated to uint16, causing checksum mismatches starting at group 65536. Use uint32 consistently and add regression tests covering the uint16 overflow boundary and the full uint32 range.
57a5094 to
b702027
Compare
Thanks, happy to help!
Yeah, I know this feeling... 🙂
Sorry for inconvenience, should be fixed now. I also updated the BTW, the linter install-script URL in the Makefile points to an obsoleted golangci-lint |
Ah oops. That should be updated. |
Issue Description
According to ext4 format description, there is a hard limit for the number of ext4 block groups, which is 2^32. Also in the Linux kernel source, the data-type for ext4 meta block group numbers is
unsigned intand in the group descriptor checksum computation, the__le32data-type is used.However, in go-diskfs, group descriptor number is defined as
uint16in thegroupDescriptorstruct. In the checksum computation,uint16is used as well.This limits the go-diskfs implementation to 2^16 = 65,536 block groups. Assuming 32,768 blocks per group and block size of 4,096 B, this effectively means that go-diskfs is unable to read ext4 file-systems exceeding 8 TiB in size.
This issue results in the group descriptor checksum mismatch error, when trying to read ext4 file-system larger than 8 TiB using the
ext4.Readfunction:as when the checksum computation reaches block group number 65,536, it overflows to 0.
How to reproduce
First, gather a beefy server with a storage exceeding 8 TiB in total:
And make sure the block device is initialized with ext4:
Compile and run this code:
You'll get the error described above:
Fix
This PR suggests:
uint16touint32.