validate free space section type during sinfo decode#6476
Open
naruto-lgtm wants to merge 1 commit into
Open
Conversation
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Repro: open a file whose free space section info block carries a section type byte >= the number of registered section classes (the file FSM registers 3: simple/small/large).
Cause: H5FS__cache_sinfo_deserialize() reads the one-byte type and indexes fspace->sect_cls[sect_type], then calls the class deserialize callback through it. The only guard is an assert(), which is compiled out in release builds, so the type is unvalidated there.
Fix: reject sect_type that is not less than fspace->nclasses before the array is indexed, the same way the header decode already rejects a class count past fspace->nclasses.
Without the check a corrupted file drives an out-of-bounds read of the class array and an indirect call through whatever function pointer lands at that offset. Keeping the validation at the decode site is the right layer because that byte is the trust boundary; every later sect_cls[type] use operates on sections whose type was already accepted here.
Issue ticket number (GitHub or JIRA)
Checklist before requesting a review