Repository navigation
feat(elf): decode Linux core dump process and memory mapping notes - #8830
Conversation
Inspect Linux core dump note tables and decode structured metadata without requiring external tools or debuggers: - NT_PRPSINFO (type 3): decode process ID, parent ID, process group, session, UID, GID, execution state, filename, and command line arguments bounded by the text budget. - NT_FILE (type 0x46494c45): decode mapped memory ranges (start_address, end_address, file_offset_pages) and mapped file paths with page size. - NT_SIGINFO (type 0x53494749): decode faulting signal number, errno, and code. - NT_AUXV (type 6): decode auxiliary vector pairs with known AT_* tag names. - Support both 32-bit and 64-bit, little-endian and big-endian targets. - Retain unknown core note types gracefully without partial success errors. - Add comprehensive unit tests, fixtures, acceptance tests, and documentation.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a792c5019c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const nullIdx = descriptor.indexOf(0, strPos); | ||
| if (nullIdx < 0) return null; | ||
| const pathBuf = descriptor.subarray(strPos, nullIdx); | ||
| const path = pathBuf.toString("utf8"); |
There was a problem hiding this comment.
Preserve non-UTF-8 mapping path bytes
For a Linux core whose NT_FILE filename contains bytes that are not valid UTF-8, which Linux pathnames may contain, this conversion replaces them with U+FFFD, so the emitted mapping path no longer identifies the original file and distinct byte paths can collapse. Preserve the path bytes losslessly or include their raw encoding alongside the display string.
AGENTS.md reference: AGENTS.md:L37-L37
Useful? React with 👍 / 👎.
| prpsinfo: null, | ||
| file: null, | ||
| siginfo: null, | ||
| auxv, |
There was a problem hiding this comment.
Reject unterminated or truncated AUXV vectors
When an NT_AUXV descriptor lacks an AT_NULL entry, ends in a partial pair, or has more than 128 non-null pairs, this loop stops at the available or capped prefix and still returns it as core.auxv. The caller receives no truncation or invalid marker, so a malformed or capped vector is presented as complete process state; verify the terminator and entry boundaries, or report the cap, before returning it.
AGENTS.md reference: AGENTS.md:L37-L37
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96ef6f6b31
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const pathBuf = descriptor.subarray(strPos, nullIdx); | ||
| const path = pathBuf.toString("latin1"); | ||
| const path_hex = pathBuf.toString("hex"); | ||
| chargeText(text, pathBuf.length); |
There was a problem hiding this comment.
Budget NT_FILE path hex expansion
For an accepted large NT_FILE descriptor with long paths, this charges only the path length even though the mapping also allocates and emits path_hex at twice that length. The returned mapping strings can therefore reach roughly three times the source path bytes while the shared text budget accounts for only one, allowing a file within max_file_bytes to produce much larger output and risk memory exhaustion during CLI/MCP serialization. Charge the hex expansion before constructing it or bound the raw field.
AGENTS.md reference: AGENTS.md:L91-L91
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b03ac1116
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const errno = i32(4); | ||
| const code = i32(8); |
There was a problem hiding this comment.
Decode SIGINFO with the target ELF ABI
On Linux MIPS cores, siginfo_t stores the prefix as signo, code, errno, but these reads interpret the latter fields as errno then code. A SIGSEGV/SEGV_MAPERR can therefore be reported as errno 1 and code 0; select the order from the ELF machine/ABI or leave it unknown when unsupported.
AGENTS.md reference: AGENTS.md:L27-L27
Useful? React with 👍 / 👎.
| start_address: hexWord(raw.start), | ||
| end_address: hexWord(raw.end), | ||
| file_offset_pages: hexWord(raw.offsetPages), |
There was a problem hiding this comment.
Budget NT_FILE address string expansion
With max_entries set to its allowed 256, an ELF can contain 256 NT_FILE notes with 4096 mappings each, within the parser's limits. These conversions create three up-to-18-character strings per mapping without charging them to TextBudget; roughly 25 MiB of short-path descriptors can therefore produce over a million retained mapping objects and a much larger inline CLI/MCP result. Charge this expansion or cap total mappings before building the arrays.
AGENTS.md reference: AGENTS.md:L91-L91
Useful? React with 👍 / 👎.
[Medium impact] The reviewed updates fix all three numbered findings and add no separate blocking finding. SummaryAdds Linux
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Selected ELF file"] --> B["Read declared note tables"]
B --> C["Keep source ranges and descriptor hashes"]
C --> D["Decode GNU and Linux CORE notes"]
D --> E["Apply shared text and scan allowances"]
E --> F["ElfNotes output contract"]
F --> G["CLI JSON"]
F --> H["MCP response"]
Reviews (3) · Last reviewed commit: "fix(elf): cache auxv padding scans, pre-..." · Reviewed by Greptile |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 359ecd49de
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| break; | ||
| } | ||
| const aVal = readWord(off + wordSize); | ||
| rawPairs.push({ aType, aVal }); |
There was a problem hiding this comment.
Charge AUXV entries before retaining them
With max_file_bytes raised to the allowed 512 MiB, a single NT_AUXV can contain tens of millions of non-null pairs; the max_entries cap counts notes, not pairs. This line retains every pair before the post-loop chargeText runs, so an over-budget vector can exhaust the CLI/MCP process instead of returning a bounded limit failure. Charge or cap the vector before retaining it.
AGENTS.md reference: AGENTS.md:L57-L58
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Thanks for adding Linux core-dump note decoding, @rishikeshgowdakk, and welcome to REA! The retained PRPSINFO, FILE, SIGINFO, and AUXV facts add process, mapping, signal, and auxiliary-vector context without launching a debugger; bounded strings and unparsed unsupported notes keep the limits visible. |
Summary
Expands
inspect_elf_notes/rea inspect-elf-notesto decode LinuxCOREdump note tables without executing the target or requiring external debuggers (GDB/LLDB). Parses process metadata (NT_PRPSINFO), memory-mapped file regions (NT_FILE), fault signals (NT_SIGINFO), and auxiliary vectors (NT_AUXV) across 32-bit and 64-bit, little-endian and big-endian targets within strict memory and text budgets.Problem and expected behavior
Upstream recently expanded
inspect_elf_notesto handle big-endian ABI tags (#8803) and validate non-allocated note boundaries. Whileinspect-elf-notesalready acceptedET_COREobject types (e_type === 4), all LinuxCOREnotes were previously reported astype_name: "unknown"withgnu: nulland raw descriptor hashes.For reverse engineers and agents analyzing crash artifacts, core dumps are among the most valuable native files. Extracting faulting signal codes, mapped libraries/binaries (
NT_FILE), process arguments (NT_PRPSINFO), and system capabilities (NT_AUXV) is essential to contextualize crashes before deep disassembly.With this change:
NT_PRPSINFO(type 3): Decodes PID, PPID, PGRP, SID, UID, GID, state, filename, and command line arguments bounded byTextBudget.NT_FILE(type 0x46494c45): Decodes memory mapping table (start_address,end_address,file_offset_pages,path) and page size.NT_SIGINFO(type 0x53494749): Decodes signal number, errno, and fault code.NT_AUXV(type 6): Decodes auxiliary vectors with well-knownAT_*symbolic names (AT_PAGESZ,AT_PHDR,AT_ENTRY, etc.).NT_PRSTATUS) and malformed descriptors remain safely unparsed (core: null) without partial success errors or uncaught exceptions.Change and scope
ElfNoteParser.tswith zero new external runtime dependencies.src/domain/native/elfNotes.tsusing Zod strict schemas with exact hexadecimal formatting.TextBudget.chargeTextto bound decoded string paths and arguments within existing memory limits.src/native/elf/ElfNoteParser.test.tsandsrc/native/elf/ElfNotes.fixture.ts.tests/acceptance/elfNotesCore.test.tscovering both the CLI (rea inspect-elf-notes --json) and the MCP server (inspect_elf_notes).docs/elf-notes.mdand tool contracts to document Linux core note observations.Contract and boundary impact
ElfNoteParser.ts) producingElfNotesdomain evidence consumed by CLI and MCP handlers.inspect_elf_notesstatic analysis capability without process execution or debugger invocation.inspect_elf_notesupdated with backward-compatible nullablecorenote field.sys/procfs.h,linux/elfcore.h). Portable across all supported Node.js host environments.Expected effects:
Evidence and regression coverage
src/native/elf/ElfNoteParser.test.ts: Added unit tests for 64-bit LE, 32-bit BE, and malformed core notes.tests/acceptance/elfNotesCore.test.ts: Added CLI and MCP acceptance test for core dump note decoding.src/native/elf/ElfNotes.fixture.ts: Added core note generation fixtures.type_name: "unknown",gnu: null.{ "owner": "CORE", "type": 1179208773, "type_name": "core_file", "gnu": null, "core": { "file": { "count": 2, "page_size": 4096, "mappings": [ { "start_address": "0x555555554000", "end_address": "0x555555558000", "file_offset_pages": "0x0", "path": "/opt/target-service" } ] } } }For evidence-bearing changes:
Validation performed
npm run check:fast— passed (0 errors, turbo typecheck & oxlint)npm run docs:check— passed (package, skill, product catalog, completion ledger, and readme consistency tests passed)npx vitest run src/native/elf/ElfNoteParser.test.ts src/native/elf/ElfNotesProvider.test.ts src/domain/native/elfNotes.test.ts tests/acceptance/elfNotesCore.test.ts tests/acceptance/elfNotesAbiEndian.test.ts tests/acceptance/elfNotesCli.test.ts tests/boundary/mcp/elfNotesMcp.test.ts tests/boundary/filesystem/elfNotes.test.ts— passed (8 test files, 84 tests passed)Compatibility, safety, and release
TextBudgetbounds.Author readiness
Human owner: @rishikeshgowdakk
Before merge
type(scope): outcome.