runtime: check the PnP key length against the buffer capacity #1531
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1538"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T13:45:56Z.
Change
adapter_identity::detail::key_length()(src/adapter_identity.{h,cpp}) accepts a PnP key only if it is a nonempty, terminated string that lies inside the buffer. It refuses a reported length past the capacity (written > capacity), and it refuses an embedded terminator (wcsnlen).xmem_gpu_usagerelies on this when it matches adapters.The existing
key_past_buffercase puts a second terminator inside the capacity, so the embedded-terminator check also rejects it. The capacity bound is never the only thing under test. Two mutants of that bound leftxmem_shim_working_set,_aggregationand_warppassing:written > capacity;written > capacity + 1.This adds one hand-worked row to
key_checks():key_terminator_past_buffer, a well-formed 32-character key in a 32-character buffer with a reported length of 33. Without the bound,key_lengthreturns 32; with it, the expected result is 0.Only
tests/xmem_shim_check.cppand one sentence in thexmem_shim_working_set_aggregationrow ofdocs/experiments.mdchange. There is no new CTest.Verification
Commit
309cfede(main) plus this change,devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0.tests/docs_links_check.py,tests/bidi_controls_check.pyandgit diff --checkpassed.Mutation probe
I applied each mutation to
src/adapter_identity.{h,cpp}alone, rebuiltxmem_shim_checkandxmem_shim, ran the three tests, then reverted. None of this is committed.same_devicecase-sensitivewritten > capacitykey_terminator_past_buffer length=32 MISMATCH)written > capacity + 1== CSTR_EQUAL→!= CSTR_LESS_THANwcsnlencheckquery(): partial device list keptquery(): software key requestedquery():lengthpassed as capacityNot covered on purpose:
\Device Parameters, so one key cannot be a proper prefix of another.query()mutants.query()calls D3DKMT directly, and no input can be injected without changingsrc/.Checklist
AI-assisted (Claude Code).