pe_v1: recognize own search pages instead of re-racing them as lost races - #990
Open
kolbicz wants to merge 1 commit into
Open
pe_v1: recognize own search pages instead of re-racing them as lost races#990kolbicz wants to merge 1 commit into
kolbicz wants to merge 1 commit into
Conversation
…aces The search-mapping pages are stamped with randomMarker, which is also the lost-race sentinel in physical_oob_read_mo. So a successful OOB read that lands on one of our own search pages reads back randomMarker, is judged a lost race, and is re-raced up to the retry cap before the scan skips it -- an own page can never hold a sprayed PCB, so that work is redundant. Stamp the search pages with a distinct randomMarker ^ K so an own-page read is recognized on the first attempt and the scan advances. The lost-race sentinel and the physically-contiguous-mapping stamp are unchanged. Optimization only; acquisition behaviour is unchanged (verified: ClearSword jailbreaks an A10X device end-to-end; DarkSword acquires identically with the own-page reads going from unrecognized to recognized). Applies to both the arm64e (DarkSword) and arm64 (ClearSword) scan paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pe_v1stamps its own search-mapping pages withrandomMarker— the same valuephysical_oob_read_mouses as its lost-race sentinel. A successful OOB read thatlands on one of our own search pages therefore reads back
randomMarker, isjudged a lost race, and is re-raced up to the retry cap before the scan skips the
page. An own page is a known, safe value that can never hold a sprayed PCB, so
that work is redundant.
This stamps the search pages with a distinct marker (
randomMarker ^ K) so anown-page read is recognized on the first attempt and the scan advances. The
lost-race sentinel and the physically-contiguous-mapping stamp are unchanged;
only the search-mapping stamp moves.
This is an optimization, not a bug fix. Acquisition behaviour is unchanged
apart from a negligible marker-collision possibility: a sprayed PCB whose first
64 bits happen to equal
randomMarkerOwnedwould now be skipped by the newbranch. The scan already has the same class of collision against the lost-race
sentinel (
randomMarker) insidephysical_oob_read_mo; this adds one moredistinct point, so the probability of missing a real PCB goes from ~2⁻⁶⁴ to
~2⁻⁶³ — both cryptographically negligible, but not literally zero.
Background
We stumbled on this while looking for scan-efficiency wins on A18 — where
fragmented search pools make own-page reads frequent enough to matter — but the
change stands on logical grounds for every device that runs
pe_v1: theown-page/sentinel collision is in the scan logic itself, independent of hardware.
The collision
physical_oob_read_mopre-stamps the buffer/target withrandomMarkerandtreats a read that still returns
randomMarkeras a lost race → retry(
if (marker != randomMarker) readRaceSucceeded = true;).randomMarker.lost race and is re-raced up to the cap.
The change
Add
randomMarkerOwned = randomMarker ^ 0x9e3779b97f4a7c15, stamp the searchpages with it, and recognize it in the scan loop (own page → skip). Because it
differs from
randomMarker,physical_oob_read_moreturns success on the firstread of an own page instead of exhausting the retry budget.
Both kernel exploits share this scan logic, so the change touches both; no
post-exploitation path is affected:
Exploits/DarkSword/DarkSword.m(arm64e)Exploits/ClearSword/exploit/{common.h,poc.c}(arm64)Verification (on device)
own=0) to recognized (own>0); acquires identicallyThe DarkSword figure was measured in a separate build of the same scan code
instrumented with an own-page counter; the change here adds no logging. The size
of the saving scales with how often the scan lands on its own pages — larger on
fragmented / memory-shaped pools, negligible on standard geometry. No wall-clock
speedup is claimed on the standard path.