Repository navigation
SWF(bug): cap GGUF metadata array nesting - #93
Merged
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
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.
Summary
Malformed GGUF metadata arrays no longer recurse without bound:
read_valuenow tracks array nesting and rejects metadata deeper than 128 levels with a normal parse error. The cap is far above the shallow nested arrays used by valid GGUF metadata, so existing nested-array parsing is unchanged.Root cause:
MetaValue::Arraydecoding recursively calledread_valuefor element type 9. A crafted file could nest arrays once per ~12 bytes, soGgufFile::parseoverflowed the stack before tensor validation.Test plan
Try it (CPU):
ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 RUST_MIN_STACK=2097152 cargo test -p spark-runtime --lib weights::gguf::container::tests::rejects_excessively_nested_metadata_arrays -- --exact --nocapturemain(5938b448) aborted withthread 'weights::gguf::container::tests::rejects_excessively_nested_metadata_arrays' has overflowed its stack/SIGABRT.1 passed; container tests →8 passed; fullATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-runtime --lib→585 passed; 0 failed; 11 ignored.cargo fmt --all -- --checkATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests -- -Dwarningsbash scripts/check-license-headers.sh(4283files checked,0invalid)typosNotes for reviewers
The existing
nested_array_of_arraystest still passes, covering valid nested metadata. The 128-level cap is generous for real GGUF metadata while keeping recursion bounded well below stack limits.CLA
Implemented in session Cap GGUF metadata array nesting depth
Review with Devin · Open in Devin Desktop