Repository navigation
feat(elf): decode ksymtab strings/CRCs and extended modversions - #14394
saariuslystoned wants to merge 3 commits into
Conversation
Codex Review Summary: ❌ FailedThis 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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; no new actionable issue remains from this review. SummaryExtends kernel-module inspection with export strings, export CRC arrays, and paired extended modversions.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Selected file] --> B{Container and ELF type}
B -->|Compressed or not ET_REL| C[Explicit unsupported or not-applicable report]
B -->|ET_REL| D[Read module sections]
D --> E[Decode strings and CRCs within shared entry budget]
E --> F[Keep ranges, hashes, reasons and omissions]
F --> G[Check report and child ranges]
G --> H[CLI and MCP Evidence]
Reviews (2) · Last reviewed commit: "fix(elf): charge mismatched modversions,..." · Reviewed by Greptile |
Summary
Extend
inspect_kernel_module(inspect-kernel-module) to decode__ksymtab_strings,__kcrctab/__kcrctab_gplCRC arrays, andCONFIG_EXTENDED_MODVERSIONS(__version_ext_names+__version_ext_crcs) in strictly additive, bounded fashion while preserving full backward compatibility with existing schemas, reports, and tests.Problem and expected behavior
Previously in
src/native/elf/KernelModuleParser.ts:__ksymtab*section locations without decoding exported symbol/namespace strings in__ksymtab_stringsoru32CRC arrays in__kcrctab/__kcrctab_gpl.__versions, leavingCONFIG_EXTENDED_MODVERSIONS(__version_ext_namespaired 1:1 with__version_ext_crcs) unparsed and unreported.Expected behavior:
ET_RELkernel modules decode__ksymtab_strings(NUL-terminated symbol/namespace strings),__kcrctaband__kcrctab_gpl(u32CRC arrays in ELF byte order, explicitly left unpaired from strings becausestruct kernel_symbolPREL32 vs pointer relocations are not resolved), andextended_versions(__version_ext_namespaired 1:1 withu32CRCs in__version_ext_crcs).MAX_KERNEL_MODULE_RAW_BYTES(4096) omit inline text (null+omitted: true) while preservingraw_sha256andbytes. All decoded entries are bounded bymax_entries(examined_entries).ET_RELtargets setextended_versions: null(withksymtab: null). Schema additions onksymtabSchemaandkernelModuleSchemaremain.exactOptional()for backward compatibility with existing callers/fixtures.Change and scope
src/domain/native/kernelModule.ts): AddedKERNEL_MODULE_CRC32_ENTRY_BYTES = 4,crc32Hex, typed section/entry reason enums and Zod schemas (ksymtabStringEntrySchema,ksymtabStringsSchema,kcrctabEntrySchema,kcrctabSectionSchema,extendedVersionSectionMetaSchema,extendedVersionEntrySchema,extendedVersionsSchema), and strictly additive.exactOptional()properties (ksymtab.strings,ksymtab.kcrctab,ksymtab.kcrctab_gpl,extended_versions). Updatedmax_entriesinput schema description.src/native/elf/KernelModuleParser.ts): ImplementedparseKsymtabStrings,parseKcrctabSection, andparseExtendedVersionsusing boundedBinaryReaderslice reads; handled duplicate/empty/unterminated/misaligned/mismatch conditions and trailing NUL padding in__version_ext_names; updated limitations (including explicitstruct kernel_symbolPREL32 vs pointer relocation caveat and extended modversions missing-half / malformed / omitted-text notes) and partial coverage checks.src/native/elf/KernelModuleProvider.ts,src/application/binaryDiagnostics/KernelModuleService.ts): Updatedmax_entriesremediation text, validation range overlap checks, evidence normalization consistency guards, and backward-compatibleexamined_entriessum.src/contracts/native/binaryDiagnosticsToolContracts.ts,docs/kernel-modules.md,docs/getting-started/cli.md,docs/reference/supported-targets.md,.agents/skills/reverse-engineer-anything/references/native-and-artifacts.md,.cursor-plugin/skills/reverse-engineer-anything/references/native-and-artifacts.md): Documented the additive fields, schema caveats, and updated tool summary.src/native/elf/KernelModule.fixture.tswithcrc32Array,extendedVersionSections, section flags, and optional custom section inputs (default fixture output unchanged), and added coverage across unit, service, filesystem boundary, MCP, and CLI acceptance tests.Not included:
struct kernel_symbolentries (PREL32 vs pointer layouts) to map individual__ksymtab*slots back to__ksymtab_strings/__kcrctab*; explicitly documented inlimitations.Contract and boundary impact
src/native/elf/KernelModuleParser.ts(static ELF.koparser) andsrc/domain/native/kernelModule.ts(kernelModuleSchema);KernelModuleService.tsconsumes these directly with no duplicated parsing.inspect_kernel_modulestatic ELF analyzer (not applicablefor new execution/injection scope).inspect_kernel_moduletool contract andrea inspect-kernel-moduleCLI retain backward compatibility; new fields (ksymtab.strings,ksymtab.kcrctab,ksymtab.kcrctab_gpl,extended_versions) are strictly additive and.exactOptional()onkernelModuleSchema/ksymtabSchema. Verified viatests/boundary/mcp/kernelModuleMcp.test.ts,tests/boundary/mcp/advertisedDialect.test.ts,tests/acceptance/kernelModuleCli.test.ts, andsrc/contracts/tupleSchemaParity.test.ts.BinaryReaderELF inspection; no external binaries or target execution.observedvs omitted values (raw_sha256retained), section metadata (offset,size,section_name,section_index,count), typedmalformedreasons,coverage.status, andlimitations.docs/public/product-catalog.json), package, or installation impact: Authored instructions updated in.agents/skills/reverse-engineer-anything/references/native-and-artifacts.md;.cursor-plugin/skills/reverse-engineer-anything/references/native-and-artifacts.mdregenerated vianode scripts/generate-cursor-plugin-skill.mjs;npm run metadata:checkandnpm run docs:checkpass.Expected effects:
Evidence and regression coverage
src/domain/native/kernelModule.test.ts: schema validation forksymtabstrings/kcrctab*,extended_versions, legacy schema compatibility, and fixedMAX_INSPECT_KERNEL_MODULE_ENTRIESparity.src/native/elf/KernelModuleParser.test.ts: LE & BE__ksymtab_strings(empty entries, unterminated trailing string, omitted >4096-byte strings),__kcrctab/__kcrctab_gpl(u32alignment errors, empty section),CONFIG_EXTENDED_MODVERSIONSpaired entries, trailing NUL padding, count mismatch, single-section-only (missing_names/missing_crcs), unterminated/empty names, oversized extended name omission, non-ET_RELnullbehavior, andmax_entriesbudget boundary.src/application/binaryDiagnostics/KernelModuleService.test.ts: validation & consistency invariants across new sections, omitted oversized entries, malformed reports, and preserved backward compatibility when optional fields are absent.tests/boundary/filesystem/kernelModule.test.ts,tests/boundary/mcp/kernelModuleMcp.test.ts,tests/acceptance/kernelModuleCli.test.ts: end-to-end service, MCP stdio schema/result parity, and CLI JSON output +resource_constraint(max_entries) verification using synthetic ELF.kofixtures.For evidence-bearing changes:
Validation performed
All checks ran cleanly on HEAD
742612d66a5a680d27f60b77e5dcece15b6430e6(no code/doc changes modified bylint-staged):npm run format:check— passed (exit 0,8823files checked)npm run check:fast— passed (exit 0:turbotypecheck+lint2/2,verify:architecture-guards3113source files)npm run verify:test-discovery— passed (exit 0,3899test and spec files)npm run metadata:check— passed (exit 0)npm run docs:check— passed (exit 0:docs:check:built6/6,tests/conformance/readmeConsistency.test.ts8/8)npx vitest run src/domain/native/kernelModule.test.ts src/native/elf/KernelModuleParser.test.ts src/application/binaryDiagnostics/KernelModuleService.test.ts tests/boundary/filesystem/kernelModule.test.ts tests/boundary/filesystem/elfStableReportFinalization.test.ts tests/boundary/providers/nativeArtifactFinalization.test.ts tests/boundary/mcp/kernelModuleMcp.test.ts tests/acceptance/kernelModuleCli.test.ts tests/boundary/mcp/advertisedDialect.test.ts tests/acceptance/nativeElfFrameAllowanceMcp.test.ts tests/acceptance/tools/localToolContracts.test.ts src/contracts/tupleSchemaParity.test.ts— passed (12test files,193/193tests passed,0skipped,0failed)Compatibility, safety, and release
.exactOptional()onksymtabSchemaandkernelModuleSchema..koobjects across LE/BE and CLI/MCP boundaries)..koblobs.Author readiness
Human owner:
Author checklist (completed by the PR author before requesting review)
type(scope): outcome.REA_runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.