validate trace packet header fields against payload size#9220
Open
soma0212 wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9220 +/- ##
=======================================
Coverage ? 69.77%
=======================================
Files ? 255
Lines ? 78580
Branches ? 18790
=======================================
Hits ? 54833
Misses ? 18176
Partials ? 5571 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
I'm going to hold off on this one while some other in-flight work on the tracing system gets resolved. There's a good chance we delete these files in a month anyway and I don't want merge conflicts for my intern. |
Contributor
Author
|
Makes sense, no rush. If the rework keeps these packet readers in some form the header-vs-payload check is small enough to port over, and if the files go away entirely, feel free to close this. |
alexreinking
approved these changes
Jul 19, 2026
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.
the trace tools read binary packets whose header carries a size field along with dimensions and a halide_type_t, but both readers only bound payload_size against the fixed 4096-byte payload buffer and never check the header agrees with the bytes actually read. PacketAndPayload::read in HalideTraceViz and Packet::read_from_filedesc in HalideTraceUtils then hand the packet straight to coordinates(), value(), func() and trace_tag(), which derive their pointers from dimensions and type.lanes, so a crafted trace whose size covers only the header while dimensions is in the thousands makes coordinates()[i] and the func/trace_tag string walks run far past the payload. reject a packet up front when dimensions is negative, when the coordinate and value bytes exceed payload_size, or when the two trailing nul terminators fall outside it, which is exactly the layout the runtime tracer always writes.
Checklist