How are EXT4 metadata checksums within group descriptors calculated?
0
votes
1
answer
191
views
I'm looking at parsing raw EXT4-formatted block devices, just using Python, primarily as a learning exercise, but am having trouble manually generating the expected Group Descriptor checksums - there appears to be some conflicting, missing or (seemingly) incorrect information when I search resources online. I am able to correctly calculate the expected block bitmap and inode bitmap checksums, using the following calculation:
as opposed to:
As most of the documentation suggests (though I don't understand why inverting it yields the expected checksum value). However, I am unable to calculate the expected group descriptor checksum. The documentation suggests this should be:
I have tried calculating it as the documentation suggests, inverting as before, with and without the block group number, using the full block as the group descriptor, using the 64 byte descriptor, using only 32 bytes as the descriptor. And I have tried all of these with zero-ing out the 16-bit checksum field, and skipping over that field in calculations. Nothing I try yields the expected checksum value.
For reference, both METADATA_CSUM and FLEX_BG feature flags are set, and maybe the
Can anyone provide more information on how to correctly calculate the group descriptor checksum within EXT4 group descriptors? Can anyone also advise why the bitmap checksums only yield the expected (correct) values when subtracted from
- (crc32c(s_uuid + bitmap_block))
as opposed to:
(s_uuid + bitmap_block)
As most of the documentation suggests (though I don't understand why inverting it yields the expected checksum value). However, I am unable to calculate the expected group descriptor checksum. The documentation suggests this should be:
(s_uuid + bg_num + group_desc) & 0xffff
I have tried calculating it as the documentation suggests, inverting as before, with and without the block group number, using the full block as the group descriptor, using the 64 byte descriptor, using only 32 bytes as the descriptor. And I have tried all of these with zero-ing out the 16-bit checksum field, and skipping over that field in calculations. Nothing I try yields the expected checksum value.
For reference, both METADATA_CSUM and FLEX_BG feature flags are set, and maybe the
part of the calculation that I am using is incorrect as a result of this.Can anyone provide more information on how to correctly calculate the group descriptor checksum within EXT4 group descriptors? Can anyone also advise why the bitmap checksums only yield the expected (correct) values when subtracted from
despite no documentation I've found suggesting that this is necessary?
Asked by genericuser99
(119 rep)
Jul 18, 2024, 10:40 AM
Last activity: Jul 23, 2024, 10:54 PM
Last activity: Jul 23, 2024, 10:54 PM