fix(relinker): reject unsigned address overflow for relative uleb128 unwind encodings #11991
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11991"
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 boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-10-27T15:41:54Z.
What
Extends the exception frame reader unsigned unwind pointer bounds checking to cover
DW_EH_PE_uleb128(encoding & 0x0F == 1). Unsigned relative unwind encodings cannot express negative displacements; when added to a base address wherevalue > std::numeric_limits<VirtualAddress>::max() - base, the reader now rejects the overflow withRelinkerException("Strict filter: unwind pointer address overflowed", field)rather than wrapping modulo 2^64.Also adds an unwind record test exercising relative
DW_EH_PE_uleb128overflow on high mapped addresses and updatesdocs/dev/debt/relinker.md.Tested
unwind_record_bounds(18 cases passed including DW_EH_PE_uleb128 relative overflow).strict_nid_filter).-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON).unwind_record_bounds_testspassed 18/18; negative control withEhFrameReader.cppreverted tomainverified failing.python tools/check_conventions.py --base upstream/main --head HEADpassed with 0 findings.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T01:58:21Z.
Review: COMMENTED
I reproduced this on macOS arm64 (relinker-only Release, head
ea7b82e58f, basee0cd1259a9).The new case discriminates.
unwind_record_bounds_testspasses 18/18 on head. With onlyEhFrameReader.cppreverted tomain, the same test binary fails (Unwind record validation failed). Full build OK; ctest 360/361. The one failure ispatch_advisor_unit, an environment issue on my side: I built under/tmp, which macOS resolves to/private/tmp. Your diff doesn't touch it.A consistency problem with the new rule. ULEB128 is not narrower than a pointer. It encodes the full 64-bit range (10 bytes). So it can carry the same modulo-2^64 backward displacement that
DW_EH_PE_absptr/DW_EH_PE_udata8carry, and the debt entry keeps those on purpose ("wraps modulo 2^64 to accommodate backward offsets, as standard DWARF unwinders add them"). Theudata2/udata4rejection works because a 16- or 32-bit value cannot reach the wrap. That argument doesn't carry over touleb128.Probe: the existing
belowPcrelUdata8fixture (pc-relative FDE begin pointing back to 0x800), with the begin field re-encoded asDW_EH_PE_pcrel|DW_EH_PE_uleb128(0x11) holding the same value0x800 - 0x1010:mainudata80x8000x800uleb1280x800unwind pointer address overflowedSo the PR now treats two encodings of the same pointer value differently. The new debt sentence also groups
uleb128with the narrow encodings for a reason (no negative displacements) that applies toudata8just as much. I see two consistent options:uleb128in the pointer-width wrapping group: no source change, and addDW_EH_PE_uleb128to the absptr/udata8 sentence in the debt entry. Or:udata8/absptr. That reverses the documented choice and breaks the existingbelowPcrelUdata8/belowDatarelUdata8fixtures, so it would need its own justification.Neither option is measured on the console. The debt entry says unwind validation for out-of-range displacements is unmeasured, so the current documented behaviour (wrap at pointer-width-capable encodings) looks like the safer default.
Minor:
pr_overlapreportsdocs/dev/debt/relinker.mdas not compared against #5021/#7173/#7531/#10861/#11192. #7173 and #7531 append lines right after this entry (@@ -47,3 +47,4 @@), so whichever lands second will probably need a rebase. #5021/#10861/#11192 touch other entries.AI-assisted: yes
Pull request closed