reject SOHM list message count exceeding list_max#6499
Open
naruto-lgtm wants to merge 3 commits into
Open
Conversation
Contributor
lrknox
requested changes
Jul 2, 2026
lrknox
left a comment
Collaborator
There was a problem hiding this comment.
A test should be included if possible.
mattjala
previously approved these changes
Jul 2, 2026
Create a file with a shared-message list index, corrupt the on-disk message count so it exceeds list_max (repairing the table checksum), and confirm reopening rejects the file instead of overrunning the list image buffer and message array.
Author
|
Added a test in tsohm.c (test_sohm_reject_bad_count). It creates a file with a list-index SOHM, pushes the on-disk message count past list_max and repairs the table checksum, then reopens and shares a message so the list gets protected. With the fix that load is rejected cleanly; on the pre-fix code the same path is the heap-buffer-overflow read in H5F_get_checksums via H5SM__cache_list_verify_chksum, so it trips under ASan. It's guarded to the default sec2 driver since it edits the file image directly. |
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
When a shared object header message index is stored as a list, both
H5SM__cache_list_verify_chksum()andH5SM__cache_list_deserialize()take thenum_messagescount straight from the on-disk index header. The image buffer and thelist->messagesarray are both sized forlist_maxentries, so a file whosenum_messagesis larger thanlist_maxmakes verify_chksum size the checksum region past the buffer and makes the deserialize loop write past the array and read past the buffer. A list holds at mostlist_maxmessages on disk before it is promoted to a B-tree, so any file that violates that is corrupt.Reject
num_messages > list_maxat both callbacks before the count is used to size a read or index the array. That header field is the trust boundary here, and the rest of the SOHM code already assumes the count fits withinlist_max, so validating it once at load time keeps every laterlist->messagesaccess sound.Issue ticket number (GitHub or JIRA)
#6501
Checklist before requesting a review