Repository navigation
hid: bound fixed-size sequencer header reads - #91
Conversation
|
Thanks for the header-read bounds guards. Two independent review passes and direct reproduction found a deterministic failure in the new test, plus an ordering-coverage gap. I did not find a demonstrated introduced runtime defect in the guards themselves. Reviewed head: Medium — new source test fails on the PR head
Both forward searches return
Suggested direction: isolate each actual function body rather than relying on guessed successor names, and rerun the full host gate. This is a local test-gate regression, not a claim that remote CI ran or that the device overflows at runtime. Low — ordering assertion misses
|
|
Thanks — both test issues were valid. I changed the test, not the driver guards/read lengths. Current head:
So a missing read can no longer produce a vacuous I also kept an explicit negative mutation: the test moves the guard marker after the real read in each isolated function and requires the ordering predicate to reject it. I separately audited the current source positions and all three guards precede their actual read call. The upstream PR CI is still |
Summary
Add fail-closed bounds checks at the three sequencer call sites that read into fixed
u8 hdr[16]stack buffers.There is no current overflow in upstream:
spi_hid_hdr_len()currently returns 9. This is defensive hardening so a future experimental/header-protocol change cannot accidentally turn a larger requested read into a kernel stack overwrite.Changes
Before each
spi_hid_seq_read(shid, hdr, hdr_len)using a fixed 16-byte header buffer:hdr_len > sizeof(hdr);WARN_ON_ONCE;No normal-path wire behavior changes while
hdr_len <= 16.Tests
Adds
tests/header_read_bounds_test.pytomake -C tests test.The test pins:
spi_hid_hdr_len()at <= 16;This PR is independent of the functional touchscreen changes in #87/#88 and the tooling PRs #89/#90.
Project provenance
This defensive hardening came out of the same transport experimentation used to reproduce the Windows MSHW0231 behavior. Background and evidence for that work are here:
The current header length is safe; this PR simply makes future transport experiments fail closed if they ever request more bytes than the fixed sequencer header buffers can hold.
Review follow-up
The source test no longer guesses function boundaries using successor names. It brace-isolates each actual target function, requires the expected read call to exist, recognizes the descriptor poller's
spi_hid_seq_read_reg(...)separately from the twospi_hid_seq_read(...)sites, and verifies the guard occurs before that concrete read. A negative in-memory mutation moves the guard after the read and must be rejected.The driver guards/read lengths themselves were left unchanged.