startup: reject a writable range whose size wraps the address space #1517
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1524"
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 RenzoWit35 on 2026-11-24T13:37:50Z.
Change
x2w_local::accessibleinsrc/startup_stubs/local_log.h(behindreadableandwritable) checked the write path withstart + bytes > end, whereendis the end of the regionVirtualQueryreturned. For a size nearSIZE_MAXthe sum wraps belowend, so the check passed andwritable(p, SIZE_MAX - 8)returned true for something that is not a range. No earlier guard catches it: only a start below 0x10000, a start above the user limit and a zero size are rejected.The read path was not affected.
probe_readablecomputes its ownend = start + bytes, which wraps too, so its loop does not run and it reports zero bytes.The comparison is now
bytes > end - start.startlies inside the queried region, so that difference cannot wrap. Nothing else in the header changes.This builds on the test added in #1477:
tests/startup_local_log_check.cppgains three wrapping-size checks next to its other boundary cases. No new test target.Verification
Windows 11, MSVC 14.51.36231,
cmake --preset dev, baseorigin/main60c72330.Negative control, with
local_log.hfrommainand the three new checks:With the fix:
startup_local_logPassed andstartup_local_log_guard_drop_controlPassed (2/2).Not run: the other startup tests, GPU tests and the full suite. I did not search for a caller that passes such a size today; the change makes the helper's answer correct for any size.
Evidence and follow-up
The inputs are sizes computed in the test against pages it allocates itself; no external data.
AI-assisted.