Repository navigation
feat(elf): decode FDO packaging and dlopen note metadata - #7237
Conversation
Name FDO notes within their owner's namespace: type 0xcafe1a7e is fdo_packaging_metadata and 0x407c0c0a is fdo_dlopen_metadata. One elfNoteTypeName(owner, type) replaces the GNU-only gnuNoteTypeName. Each entry gains an fdo field next to gnu. metadata holds the descriptor's JSON object (packaging) or array (dlopen) when it is NUL-terminated UTF-8 JSON followed only by NUL padding; otherwise metadata is null and issue names the broken rule, without failing the inspection. Each descriptor range is decoded once and its retained JSON text is charged to the shared note text budget per repeated entry. A limitation marks the metadata as a producer declaration. Fixes morluto#7235
Codex Review Summary: ✅ CompletedThis 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. |
[Medium impact] The follow-up appears safe to merge. SummaryAdds decoded FDO package and optional-library declarations to ELF note reports while preserving raw note facts when decoding is refused. The latest push updates the heap tests to use the shared JSON depth helper.
Reviews (6) · Last reviewed commit: "test(desktop): exercise the shared JSON ..." · Reviewed by Greptile |
The FDO decode cache was keyed by descriptor range only, but the note type selects the required JSON shape. Overlapping PT_NOTE and SHT_NOTE tables can give one descriptor range a packaging note and a dlopen note, and the second reused the first note's verdict. Include the type name in the key. Refs morluto#7235
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91f7791328
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The FDO decoder charged only descriptor source bytes before JSON.parse,
but a dense JSON value such as [{},{},...] decodes to about 50 times its
source size in heap before the service and Evidence copy it again. A
16 MiB descriptor took about 790 MiB of heap; one near the default
64 MiB file budget could exhaust the Node heap. Leave descriptors above
64 KiB undecoded with an issue naming the limit; real FDO notes are a
few hundred bytes.
Refs morluto#7235
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47c7c61520
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The 64 KiB FDO decode bound applied to each descriptor, so raising max_entries to 256 admitted 256 distinct dense 64 KiB notes: a 16 MiB file added about 700 MiB of heap before Evidence copied it again. Charge each distinct descriptor's size to one 64 KiB allowance per report; a range repeated by another table reuses its decode, and notes past the allowance keep their entry with an issue. Refs morluto#7235
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d83cf887c1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Refresh the contributor decoder against the current ELF note reader. Preserve raw descriptor evidence on refusal and bound exact JSON decoding and retained copies.
Summary
Fixes #7235
inspect-elf-notesdecoded only GNU notes. FDO notes, which declare a binary's package and its optionaldlopenlibraries, came back astype_name: "unknown"with a hash only, because their descriptors exceed the 64-byte hex preview. This PR names and decodes both FDO note kinds.Problem and expected behavior
readelf -n /usr/bin/lsprintsFDO_PACKAGING_METADATAwith{"type":"rpm","name":"coreutils",…}. Onmain, REA reports the same note asowner: "FDO",type_name: "unknown",descriptor.hex: null,gnu: null.Expected: the package and dlopen JSON defined by the UAPI package metadata and dlopen metadata specifications appears in the result. A malformed descriptor stays visible with a reason and does not fail the inspection.
Change and scope
elfNoteTypeName(owner, type)insrc/domain/native/elfNotes.tsreplaces the GNU-onlygnuNoteTypeName. A type number is named only within its owner's namespace: FDO0xcafe1a7e→fdo_packaging_metadata, FDO0x407c0c0a→fdo_dlopen_metadata.Metadata keeps the producer’s keys. Key-specific validation is outside this change.
Contribution scope: not applicable. This is static parsing of bytes the existing operation already reads.
Contract and boundary impact
ElfNoteParserproduces the decoded FDO facts; the domain contract owns owner-scoped type naming. The supersededgnuNoteTypeNameis removed.ElfNotesServicevalidation is unchanged, and no other consumer reads note type names.type_nameenum values and a nullablefdoentry field; the tool description mentions FDO metadata..agents/skills/.Expected effects:
Evidence and regression coverage
Tests added or updated:
ElfNoteParser.test.ts: both note kinds across PT_NOTE and SHT_NOTE, each malformed case (no terminator, data after terminator, invalid UTF-8, invalid JSON, wrong top-level shape for each kind), unknown FDO types staying undecoded, and one descriptor range shared by a PT_NOTE packaging note and an SHT_NOTE dlopen note decoding per type (from Greptile review), and the shared 64 KiB decode allowance: its boundary, distinct notes sharing it, and a PT_NOTE/SHT_NOTE repeat charged once (from Codex reviews).elfNotes.test.ts: owner-scoped naming.elfNotesCli.test.ts: public CLI output validated against the published contract.Base reproduction or other evidence (executed): a local sweep called
parseElfNoteson 5,276 ELF files from/usr/binand/usr/lib64on Fedora 44 x86_64. It decoded 9,294fdo_packaging_metadataand 166fdo_dlopen_metadataentries with noissue. The same 5,276 files parsed before and after the change. The 129 files that failed before still fail, with the existing note-alignment and entry-budget errors, unchanged by this PR.User-visible CLI output:
rea inspect-elf-notes /usr/bin/ls --jsonnow reports, for both tables:{ "owner": "FDO", "type_name": "fdo_packaging_metadata", "fdo": { "metadata": { "type": "rpm", "name": "coreutils", "version": "9.10-5.fc44", "architecture": "x86_64", "osCpe": "cpe:/o:fedoraproject:fedora:44" }, "issue": null } }A real dlopen note (
libnss_myhostname.so.2) decodes to[{"feature":"idn","description":"Support for internationalized domain names","priority":"suggested","soname":["libidn2.so.0"]}].Remaining proof gaps: only checked against Fedora-produced notes. No big-endian or ELF32 binaries carrying FDO notes were available, though the FDO decoder does not depend on byte order.
Boundary regressions: malformed input (each spec violation is kept, with a reason) and capacity (decoding shares the existing text budget and is cached per range). No lifecycle stages change.
For evidence-bearing changes:
Validation performed
npm run test:local -- src/native/elf/ElfNoteParser.test.ts src/domain/native/elfNotes.test.ts src/native/elf/ElfNotesProvider.test.ts src/application/binaryDiagnostics/ElfNotesService.test.ts: 67 passed on d83cf88; the shared-descriptor regression failed on b8cd950npm run test:focused -- tests/acceptance/elfNotesCli.test.ts tests/boundary/mcp/elfNotesMcp.test.ts tests/boundary/filesystem/elfNotes.test.ts: 15 passed on b8cd950, including MCP advertisement; the CLI and MCP files (13 tests) passed again on d83cf88npm run check:fast: typecheck and lint passed; it passed again as the pre-push hook on the pushed commitnpm run docs:check: passed (rerun on d83cf88)oxfmt) reformatted the staged files; the 91f7791 runs include that formatting.issue; the file sets differ byfindordering.[{},{},…]dlopen descriptors: on 91f7791 a 16 MiB descriptor added about 790 MiB of heap and took 5.3 s; on 47c7c61 16 MiB and 64 MiB descriptors add about 0 MiB and finish in 44 ms and 134 ms. Withmax_entries: 256, 255 distinct 64 KiB notes (15.9 MiB file) added about 700 MiB of heap in 4.6 s on 47c7c61, and about 0 MiB in 100 ms on d83cf88.Compatibility, safety, and release
type_namevalues and fields are unchanged.The current-base refresh at
980e23fdabuses exact JSON and complete descriptor framing. It caps both cumulative descriptor decoding and cumulative projected JSON. Repeated descriptors reuse a decode but each emitted representation consumes projection allowance. Oversized, imprecise, duplicate-key, and wrong-shape descriptors retain raw note Evidence. The refresh passed 323 source tests with one skip and 70 compiled tests, including the four previously failing files. Typecheck, lint, and docs checks passed.At
8194a6eca7, the compiled desktop heap test imports the shared depth checker. The stale import failed before the change. Afterward, 157 focused tests passed, including all five heap tests, with one host-ELF skip.Author readiness
Human owner: @AniketR10
Before merge
type(scope): outcome.