Repository navigation
feat(recorded-crash): decode AArch64 core register notes - #2505
Conversation
The recorded-crash contract admitted only ELF64 x86-64 cores: the bridge refused every other e_machine and the domain schema pinned one architecture literal, so legitimate recorded Linux AArch64 crashes could not be inspected at all. Interpret a second profile from unchanged pwntools 4.15.0 elf_prstatus_aarch64 and user_regs_struct_aarch64 structures. The ABI facts now have one owner, the domain profile, which the bridge mirrors: AArch64 binds 34 uint64 registers at descriptor offset 112 within a 392-byte PRSTATUS, while x86-64 keeps its 27-register 336-byte window. Any other machine is still refused before note interpretation.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Tip For best results, initiate chat on the files or code changes.
You are interacting with an AI system. |
|
@greptileai review |
|
…he profile Review found two places where the AArch64 profile stopped at the bridge: - validateRecordedCrashStructure still refused every e_machine but 62, so an AArch64 core died inside PwntoolsRecordedCrashProvider before the widened register checks ran. It now compares the header against RECORDED_LINUX_CORE_PROFILES[report.architecture].machine, so the accepted machine stays bound to the architecture the reply actually claims. - RecordedCrashService stamped "x86_64" on every created Evidence. The profile table now owns the CPU family as evidenceArchitecture and the service reads it, so an AArch64 report publishes arm64 instead of two conflicting names. Tests added: both recorded profiles are admitted by their own e_machine, and each is rejected when the header carries the other profile's machine; created Evidence is pinned to x86_64 / arm64; and an AArch64 core now runs through the full provider pipeline. Refs morluto#2353
…o table The first version of that case restated the provider's bridge stub, and jscpd counts clones repo-wide: this branch went to 3.01% duplicated lines against a 3.0% budget, so `Static checks` failed at `npm run check:ci` -> jscpd. Coverage is unchanged - `success-aarch64` is now a row of the existing scenario table, which already drives a reply through the structure, source and register bindings. Locally `npm run jscpd` is back at the `6055dc26` baseline (1429 clones, 2.98%), and with the pwntools host check and this file's `runIf` temporarily opened the provider file is 35 passed / 0 failed. Reverting the `e_machine` fix still kills `success-aarch64` with `Reported core structure differs from its original ELF/note headers.`
|
The remaining Same step (
All three print On my own share of it: my intermediate commit duplicated Happy to rebase once the budget is back under 3.0%, and equally happy to trim the +2 here if you would rather this branch contribute nothing to the count — say which and I will do it. |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. The canonical inspect_recorded_crash description still named only amd64 targets. It now names amd64 and AArch64 little-endian ELF64 cores while separately retaining the Linux x64 host profile and the existing BYO dependencies/authority. The guide's register-set wording also now distinguishes the schema's 27-register amd64 and 34-register AArch64 layouts. Generated catalogs and provider checks were not run at the user's request. Source fix: 7fea123. Tests and checks were skipped at the user's explicit request; this assessment is based on source inspection. |
Summary
inspect_recorded_crashonly ever admitted ELF64 x86-64 cores: the bridge refused every othere_machineand the domain schema pinnedarchitectureto a single literal, so a legitimately recorded Linux AArch64 crash could not be inspected at all.This adds the AArch64 profile from unchanged pwntools 4.15.0 structures — no locally re-declared ABI — and turns the previously amd64-only constants into one owned profile table.
Fixes #2353
ABI facts, measured not assumed
Read directly out of
pwnlib/elf/datatypes.pyfrom the officialpwntools-4.15.0wheel viactypes:e_machineelf_prstatussizepr_regoffsetpr_cursig/pr_pid0x150)c_uint640x188)c_uint64(x0…x30,sp,pc,pstate)The AArch64 register order is
user_regs_struct_aarch64._fields_order, which is the order the bridge already uses to emit registers, so the domain list and the bridge cannot drift silently. The amd64 list in the domain file was verified the same way (it matches_fields_exactly), which is also what proves the existing profile was not accidentally reinterpreted here.What changed
src/domain/native/recordedCrash.ts— one owned profile tableRECORDED_LINUX_CORE_PROFILES(machine id, register order, register width, register offset, PRSTATUS size) plusRECORDED_LINUX_CORE_ARCHITECTURES.architecturebecomesz.enumover that list, and thread validation now checks each register name, count and width against the reported architecture's profile instead of a hardcoded amd64 list.bridge/pwntools/recorded_crash_impl.py—CORE_MACHINES = (62, 183); the profile selectself_prstatus_aarch64/user_regs_struct_aarch64and thearchitecturelabel. Truncation messages name the selected profile. Theunsupported-targetrefusal now reports the observede_machineinstead of only saying "requires x86-64".src/native/pwntools/RecordedCrashSourceBindings.ts— register source offsets and the minimum descriptor length now come from the same profile table, so a 34-register/392-byte AArch64 thread is bound slot by slot exactly like amd64's 27/336.tests/fixtures/binaryDiagnostics/recordedCrash.ts— the source-owned fixtures derive note, owner and descriptor ranges from the profile (identical bytes to today for x86-64:0x80/0x8c/0x94,0x164,0x150) and now stamp the matchinge_machine.docs/recorded-crashes.md— states both profiles and that any other machine is refused before note interpretation.Verification
Real decode, run locally. I assembled the decoder's actual dependencies and ran the repo's
recorded_crash_impl.pyunchanged against crafted cores:architecture = aarch64-little-endian, 34 registers namedx0…x30, sp, pc, pstate, every reported register offset equal todescriptor + 112 + index*8, all values round-tripped, PID and cursor signal recovered frompr_pid@32/pr_cursig@12, and the SIGSEGV fault address decoded fromNT_SIGINFO.x86_64-little-endian, same offsets.format: Linux AArch64 NT_PRSTATUS descriptor is truncated.e_machine = 243(RISC-V) →unsupported-targetnaming the observed machine.Honest limits of that harness:
pyelftools 0.33is the real package andpwnlib/elf/datatypes.pyis the verbatim file from the official 4.15.0 wheel, butunicorn 2.1.2is satisfied by a metadata stub because no macOS arm64 wheel builds here — the recorded-crash path never imports unicorn, only the version preflight reads it. The harness lives in/tmpand is not part of the commit. If you want it in-repo I will add it as aunittestthat skips when pwntools 4.15.0 is not importable, sotest:pythonstays green without the dependency.TypeScript. New
src/native/pwntools/RecordedCrashSourceBindings.test.ts(7 cases) binds every register for both profiles, pins each profile's numbers against the ABI table above rather than only using them consistently, asserts the crafted core'se_machineequals its profile's machine, and rejects: a register bound one slot off, a descriptor shorter than the profile size, an amd64 name inside an AArch64 window, and a reported PID that differs from the source bytes.src/domain/native/recordedCrash.test.tsgains 6 cases: the full AArch64 window accepted, its note ranges inside the segment, and rejection of an amd64 name, the amd64 count, a 4-byte register source, and an architecture outside the profiles.vitest --project domain --project services --project adapterstsc --noEmit -p tsconfig.jsonoxfmt --checknpx knipoxlintorigin/mainfor the same filesThe provider suite for this lane (
tests/boundary/binaryDiagnostics/recordedCrashProvider.test.ts, 34 cases) isrunIf(linux && x64)and the adapter itself refuses non-Linux hosts, so to check my fixture rewrite I temporarily bypassed both gates, ran all 34 green, then reverted both. The committed diff contains no bypass;git difffor that test file is empty.npx vitest --project boundaryon this machine shows 8 failures in four files (setupSkill, twoinspector/javascriptRuntime*,nativeDmgArtifactReader). None of them read recorded-crash code, and on untouchedorigin/mainat the same commit the same four files fail 14 cases — after normalizing names, my failure set is a strict subset with zero cases unique to this diff. So these are macOS host/pre-existing failures, not regressions here.Mutation arms (each run, each killed)
machine not in CORE_MACHINES→machine != 62prstatusBytes: 392→336registerOffset: 112→120Deliberately not in this PR
docs/recorded-crashes.md's "Bounds and verification" paragraph is untouched on purpose: my own fix(pwntools): let callers widen the artifact input bound #2486 rewrites that exact paragraph, and editing it twice would guarantee a conflict between the two PRs.real-recorded-crash.ymllane builds its fixture withgcconubuntu-24.04, so it can only ever produce x86-64 cores; an AArch64 recording needs an arm64 runner or qemu and is a CI decision, not a decoder change. The acceptance criteria here are met with profile-bound synthetic bytes plus the real decode above.Collision surface
I indexed the changed files of all 202 open PRs earlier in this session: all seven files this PR touches were free of any in-flight PR. That index is a snapshot, so a rebase before merge is still worth doing; the branch is currently rebased onto
c74142e6with one commit.Base:
c74142e6. Head: 3 commits, 12 files, +529 −88. Trunk has moved 58 commits since that base andgit log HEAD..origin/main -- <these twelve paths>returns 0 hits (positive control: the same command finds 3 hits for a file trunk did change), so nothing has been rewritten under this branch. The round-1 files (RecordedCrashStructureBindings.ts,RecordedCrashService.tsand its test) were not in the 202-PR index above, so that snapshot does not cover them; a re-scan or rebase before merge is still worth doing.Review round 1 (Greptile P1 ×2)
Both findings were correct: the AArch64 profile reached the bridge and the domain, but two downstream consumers still pinned amd64, so nothing actually arrived. Fixed in the second commit.
src/native/pwntools/RecordedCrashStructureBindings.tsheader.readUInt16LE(18) !== 62, soPwntoolsRecordedCrashProviderrefused an AArch64 core before the widened register checks ranRECORDED_LINUX_CORE_PROFILES[report.architecture].machinesrc/application/binaryDiagnostics/RecordedCrashService.tsarchitecture: "x86_64"on every created EvidenceRECORDED_LINUX_CORE_PROFILES[value.architecture].evidenceArchitecturesrc/domain/native/recordedCrash.tsevidenceArchitecture: BinaryArchitecture(x86_64/arm64)New cases: each profile is admitted by its own
e_machineand rejected when the header carries the other profile's machine; created Evidence is pinned per profile; andsuccess-aarch64runs an AArch64 core through the full provider pipeline as a row of the existing scenario table.Mutation arms (each run, then reverted from backup and
cmp-verified)6262or183regardless of the reported profile"x86_64"armsuccess-aarch64fails withReported core structure differs from its original ELF/note headers.How the host-gated provider case was executed here
tests/boundary/binaryDiagnostics/recordedCrashProvider.test.tsis.runIf(process.platform === "linux" && process.arch === "x64")andPwntoolsDecoderrefuses any other host, so all 35 of its cases skip on macOS. To run them I temporarily (1) turned that host check intoif (false)and (2) set the test file'shostconstant totrue, ran the file — 35 passed / 0 failed — then restored both files from backup and re-verified withcmpplusgrep -c= 0 for each marker. The bridge is stubbed by the test's own launcher, so no pwntools/Python executed in that experiment; the Linux CI lane still covers the real decode.Local gates for this commit
tsc --noEmitclean.oxfmt --checkclean on all six changed files.oxlinton those six: 0 errors, 4 warnings — the same four warnings as at6055dc26, verified by linting both trees, so no new warning is introduced. Platform-independent selection: structure bindings 8,RecordedCrashService12, domain 29, source bindings 8 passed; the MCP + CLI-cleanup + stage-retirement selection passed 11 with 35 skipped (only the host-gated provider file).Static checks round (jscpd)
34dfab14failed one CI lane:Static checks→ stepRun npm run check:ci→jscpd, withERROR: jscpd found too many duplicates (3.0%) over threshold (3.0%)— 2368 files, 1484 clones, 3.01% duplicatedlines against a 3.0% budget. The clone was mine: the standalone AArch64 case restated that file's own bridge stub
(
recordedCrashProvider.test.tslines 91:68–101:14 ↔ 153:5–163:14 and 109:20–121:28 ↔ 169:35–181:28).39c82c17drops the second copy and makessuccess-aarch64a row of the scenario table that already drives a replythrough the structure, source and register bindings, so the assertion set is the same one its sibling scenarios in that table run,
plus
expect(result.value.architecture).toBe(architecture).Measured locally with
npm run jscpdon the same.jscpd.json:6055dc26= 1429 clones / 2.98%,34dfab14= 1431clones / 2.99%,
39c82c17= 1429 clones / 2.98% — back on the baseline the previously-green commit sat at, andjscpd:detailsno longer lists this file. Local totals differ slightly from CI's (CI counts generated files too), sothe claim is the delta, not the absolute.
tsc --noEmit,oxfmt --checkand the platform-independent suites areunchanged by this commit.