Skip to content

Reject driver info blocks that extend past the end of file - #6683

Open
mattjala wants to merge 7 commits into
HDFGroup:developfrom
mattjala:drvinfo_block_bounds
Open

mattjala wants to merge 7 commits into
HDFGroup:developfrom
mattjala:drvinfo_block_bounds

Conversation

@mattjala

Copy link
Copy Markdown
Contributor

The length of the driver info block in a version 0/1 superblock was used to extend the EOA without being checked against the file's stored EOF. If a malformed file declared a block extending past the EOF, it would be loaded and pinned in the metadata cache, then left beyond the EOA after the EOA was reset to the stored EOF.

For files opened read-write, closing the file would then fail to write the driver info block back, so H5Fclose() failed and the file's metadata cache was leaked, leaving the library unable to shut down cleanly.

The library now validates that the block lies within the stored EOF when decoding its prefix, so such files fail to open.

Resolves #6677

The length of the driver info block in a version 0/1 superblock was
used to extend the EOA without being checked against the file's stored
EOF. If a malformed file declared a block extending past the EOF, it
would be loaded and pinned in the metadata cache, then left beyond the
EOA after the EOA was reset to the stored EOF.

For files opened read-write, closing the file would then fail to write
the driver info block back, so H5Fclose() failed and the file's
metadata cache was leaked, leaving the library unable to shut down
cleanly.

The library now validates that the block lies within the stored EOF
when decoding its prefix, so such files fail to open.

Resolves HDFGroup#6677
@mattjala mattjala added this to the HDF5 2.x.x milestone Sep 23, 2026
Copilot AI lite review requested due to automatic review settings September 23, 2026 15:51
@mattjala mattjala added the Component - C Library Core C library issues (usually in the src directory) label Sep 23, 2026
@github-project-automation github-project-automation Bot moved this to To be triaged in HDF5 - TRIAGE & TRACK Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs a sign-off
from its listed owners before merging.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Add regression coverage for version-1 superblocks, including valid and rejected extents.

Review effort: Lite
Findings: None

What changed in this PR

This PR rejects legacy driver-info blocks extending beyond the stored EOF, preventing metadata-cache leaks during close.

Changes:

  • Passes stored EOF into driver-info decoding.
  • Rejects out-of-bounds driver-info blocks.
  • Adds regression coverage and changelog documentation.
File Changes
test/​tfile.c Adds malformed-file regression tests; version-1 coverage is still needed.
src/​H5Fsuper.c Supplies stored EOF to driver-info loading.
src/​H5Fsuper_cache.c Validates driver-info block bounds.
src/​H5Fpkg.h Extends cache callback metadata.
release_docs/​CHANGELOG.md Documents the fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

lrknox
lrknox previously approved these changes Sep 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component - C Library Core C library issues (usually in the src directory)

Projects

Status: To be triaged

Development

Successfully merging this pull request may close these issues.

Malformed file leaves library shutdown unable to converge ("infinite loop closing library"), ~1.6MB leaked

3 participants