67 lines
2.3 KiB
Markdown
67 lines
2.3 KiB
Markdown
# Test Case: Superblock CRC32C Validation
|
|
|
|
**Test ID**: TC002-superblock-crc32c
|
|
**Category**: Filesystem Metadata
|
|
**Priority**: Critical
|
|
|
|
## Objective
|
|
|
|
Verify the real EROFS superblock checksum field and both equivalent checksum
|
|
ranges, then prove that a valid image mounts while an equal-length image with
|
|
one covered byte changed and no checksum update is rejected.
|
|
|
|
## Fixture Qualification
|
|
|
|
Run from the repo22 root with erofs-utils 1.8.6:
|
|
|
|
```sh
|
|
work=$(mktemp -d /tmp/repo22-tc002.XXXXXX)
|
|
tests/prepare_error_fixtures.sh "$work/fixtures"
|
|
python3 tests/erofs_fixture.py inspect "$work/fixtures/valid-plain.erofs"
|
|
python3 tests/erofs_fixture.py inspect "$work/fixtures/bad-super-crc.erofs"
|
|
grep '^bad-super-crc ' "$work/fixtures/fixture-evidence.txt"
|
|
(cd "$work/fixtures" && sha256 -c SHA256SUMS)
|
|
```
|
|
|
|
For a 4096-byte block, the canonical calculation clears the little-endian
|
|
checksum at absolute byte 1028 and calculates CRC32C over bytes `[1024,4096)`
|
|
with initial value `0xffffffff`. The production verifier uses seed
|
|
`0x5045b54a` over `[1032,4096)`. The helper must print identical canonical and
|
|
kernel values, `equivalent=True`, and `valid=True` for the control. The bad
|
|
image changes byte 1088, preserves provider length, does not recompute CRC, and
|
|
must print `valid=False`.
|
|
|
|
## FreeBSD Procedure
|
|
|
|
```sh
|
|
mkdir "$work/mnt"
|
|
unit=$(mdconfig -a -t vnode -f "$work/fixtures/valid-plain.erofs")
|
|
mount -t erofs -o ro "/dev/$unit" "$work/mnt"
|
|
cmp "$work/fixtures/source/control.txt" "$work/mnt/control.txt"
|
|
umount "$work/mnt"
|
|
mdconfig -d -u "${unit#md}"
|
|
|
|
unit=$(mdconfig -a -t vnode -f "$work/fixtures/bad-super-crc.erofs")
|
|
set +e
|
|
mount -t erofs -o ro "/dev/$unit" "$work/mnt" \
|
|
>"$work/bad-mount.out" 2>"$work/bad-mount.err"
|
|
mount_status=$?
|
|
set -e
|
|
printf 'mount_status=%s\n' "$mount_status"
|
|
test "$mount_status" -ne 0
|
|
set +e
|
|
truss -o "$work/bad-mount.truss" mount -t erofs -o ro "/dev/$unit" \
|
|
"$work/mnt" >/dev/null 2>&1
|
|
set -e
|
|
grep -E 'nmount.*ERR#97' "$work/bad-mount.truss"
|
|
! mount -p | awk -v path="$work/mnt" '$2 == path { found=1 }
|
|
END { exit found ? 0 : 1 }'
|
|
mdconfig -d -u "${unit#md}"
|
|
```
|
|
|
|
## Expected Results
|
|
|
|
The control mounts and reads exactly. The bad image fails with FreeBSD errno
|
|
97 (`EINTEGRITY`) and no mount remains. Record both image hashes, provider
|
|
lengths, checksum values/ranges, command status, new dmesg lines, and cleanup.
|