Skip to content

ext4: fix extent skip condition in Read/Write causing panic - #430

Merged
deitch merged 2 commits into
diskfs:masterfrom
Morolis:ext4-fix-extent-skip-condition
Aug 30, 2026
Merged

deitch merged 2 commits into
diskfs:masterfrom
Morolis:ext4-fix-extent-skip-condition

Conversation

@Morolis

@Morolis Morolis commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

An extent covers file blocks [fileBlock, fileBlock+count). The skip condition used a strict <, so an extent ending exactly at the current read/write start block was not skipped. With a non-block-aligned offset this made leftInExtent negative and make([]byte, n) panicked with "makeslice: len out of range".
Use <= in both Read and Write

Fixes #429

An extent covers file blocks [fileBlock, fileBlock+count). The skip
condition used a strict <, so an extent ending exactly at the current
read/write start block was not skipped. With a non-block-aligned offset
this made leftInExtent negative and make([]byte, n) panicked with
"makeslice: len out of range".
Use <= in both Read and Write

@deitch deitch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you used the reproduction from the issue you opened in the test; thank you for doing so.

@deitch
deitch merged commit 89233fe into diskfs:master Aug 30, 2026
20 checks passed
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.

ext4: File.Read/Write panic (makeslice: len out of range) on fragmented files at unaligned offsets

2 participants