Skip to content

validate trace packet header fields against payload size#9220

Open
soma0212 wants to merge 1 commit into
halide:mainfrom
soma0212:trace-packet-payload-bounds
Open

validate trace packet header fields against payload size#9220
soma0212 wants to merge 1 commit into
halide:mainfrom
soma0212:trace-packet-payload-bounds

Conversation

@soma0212

Copy link
Copy Markdown
Contributor

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

  • Tests added or updated (not required for docs, CI config, or typo fixes)
  • Documentation updated (if public API changed)
  • Python bindings updated (if public API changed)
  • Benchmarks are included here if the change is intended to affect performance.
  • Commits include AI attribution where applicable (see Code of Conduct)

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@0765408). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexreinking

Copy link
Copy Markdown
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.

@soma0212

Copy link
Copy Markdown
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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants