Skip to content

fix(vfs): guard EROFS block_size shift against out-of-range blkszbits#136

Merged
kernalix7 merged 1 commit into
mainfrom
fix/erofs-blkszbits-shift
Jun 23, 2026
Merged

fix(vfs): guard EROFS block_size shift against out-of-range blkszbits#136
kernalix7 merged 1 commit into
mainfrom
fix/erofs-blkszbits-shift

Conversation

@kernalix7

Copy link
Copy Markdown
Owner

ErofsSuperblock::block_size shifts 1u32 by blkszbits, an unvalidated on-disk byte (d[12], 0..=255). A crafted blkszbits >= 32 overflows the shift → panic (overflow-checks ON = ring-0 halt) on the read/mount path. Same shift-by-attacker-byte class as the adfs/minix/fs-verity fixes. Use checked_shl with a default 4 KiB fallback for out-of-range exponents; valid exponents (< 32) unchanged, keeping downstream blkaddr * block_size offset math bounded.

Found by a kimi/opencode agentic lane; verified + sibling-swept by hand (only shift site; line 120 is a constant right-shift).

ErofsSuperblock::block_size shifts 1u32 by blkszbits, an unvalidated
on-disk byte (d[12], 0..=255). A crafted blkszbits >= 32 overflows the
shift and panics (overflow-checks ON = ring-0 halt) on the read/mount
path. Use checked_shl and fall back to the default 4 KiB block size for
out-of-range exponents; valid exponents (< 32) are unchanged, which also
keeps the downstream blkaddr * block_size offset math bounded.
@kernalix7 kernalix7 merged commit 8f20a95 into main Jun 23, 2026
2 checks passed
@kernalix7 kernalix7 deleted the fix/erofs-blkszbits-shift branch June 23, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant