Repository navigation
fix(devicetree): read later FDT versions backwards compatible with v17 - #14136
vincentkoc merged 7 commits into
Conversation
The header reader admitted only versions 16 and 17 and consulted last_comp_version only to reject a value above the version. DTSpec 5.1 requires a client to accept any version backwards compatible with version 17, and libfdt reads such a blob with the version 17 header. Admit a later version whose last_comp_version is 17 or lower and read it with the version 17 layout, reporting the declared version. A later version that needs a newer reader and any version below 16 stay unsupported, and v16 and v17 outcomes are unchanged. FIT recognition shares the reader, so it now claims a FIT in such a version as well.
… v17 Parse the shared fixture with version 18 and last_comp_version 16: the header is read with the version 17 layout and the tree decodes as it does for v17. Raising last_comp_version to 18 keeps the blob unsupported. FIT recognition, which shares the header reader, covers the same version. On the previous reader the version 18 parse and the version 18 FIT recognition fail, because version 18 was refused before last_comp_version was read.
…le header The CLI and MCP error cases used version 18 as an arbitrary unsupported version, but their fixture declares last_comp_version 16, which is now read as a version 17 blob. Declare last_comp_version 18 there so both cases still reach unsupported_target through the public paths. The shared fixture takes the declared compatibility version for this, and the parser case uses it instead of patching the header word.
[Medium impact] This PR appears safe to merge; no actionable issues were found. SummaryAccepts later FDT versions that remain backwards compatible with version 17. The shared reader uses the version 17 header layout and preserves the declared version.
Reviews (3) · Last reviewed commit: "test(devicetree): cover compatible versi..." · Reviewed by Greptile |
|
Checked against current main (43e0567): |
…-compatible-versions
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. |
* commit '76cb6645be39cf3844f7a8bb4568b02d8a713595': (95 commits) fix(macos-pkg): retain cpio hard-link contents (morluto#15157) fix(artifacts): report macOS package bundle release versions (morluto#14860) test(asar): verify cleanup on the original file handle (morluto#15155) fix(ubi): bound smaller-grid probe memoization (morluto#15168) fix(artifacts): distinguish content from containment changes (morluto#15165) fix(bflt): retain complete text when data is truncated (morluto#15160) refactor(domain): reuse graph projection and validation helpers (morluto#15173) fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801) test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172) test(beam): reuse the CLI Evidence reader (morluto#15171) test(oci): share descriptor budget refusal assertions (morluto#15159) refactor(audit): share byte framing for offline audit logs (morluto#15162) refactor(evidence): reuse observed file reports for binary metadata (morluto#15161) fix(doctor): omit package-runner cache shims from installations (morluto#15059) refactor(packages): share package inspection budget contracts (morluto#15158) refactor(desktop): share completed command answer recovery (morluto#15156) refactor(views): share page byte reservations (morluto#15152) refactor(artifacts): share GPU and media asset layout rules (morluto#15150) fix(setup): name the detected host when Hopper setup does not apply (morluto#14449) fix(iso9660): read a directory record whose identifier padding byte is not zero (morluto#15020) ...
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
thanks! canonical review is clean. i added CLI/MCP regressions for both compatible header declarations and aligned the remaining version summaries. the branch is now updated with the pinned main; waiting for CI on 23b72f6 before landing. |
|
thanks! merged with the CLI/MCP compatibility regressions and version summaries aligned. canonical review and all CI checks passed: 669 tests passed, 2 unchanged skips. |
* commit 'eb5cd34258f35b7f12602c9fc95c4c9509c7be10': fix(devicetree): read later FDT versions backwards compatible with v17 (morluto#14136) fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949) fix(macos-pkg): retain cpio hard-link contents (morluto#15157) fix(artifacts): report macOS package bundle release versions (morluto#14860)
* commit 'c86e86d697cc00dd00367ee2a4e726d4552e637e': fix(artifacts): retain stored files in Godot PCK patches (morluto#15180) fix(setup): do not persist versioned launcher paths (morluto#15123) fix(devicetree): read later FDT versions backwards compatible with v17 (morluto#14136) fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949) fix(macos-pkg): retain cpio hard-link contents (morluto#15157)
* commit '91380cff6a6ce8b82b042ceb4e5013f3cc87a9d0': fix(ci): run npm lifecycle hooks in selected host lanes (morluto#15169) fix(artifacts): retain stored files in Godot PCK patches (morluto#15180) fix(setup): do not persist versioned launcher paths (morluto#15123) fix(devicetree): read later FDT versions backwards compatible with v17 (morluto#14136) fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949) fix(macos-pkg): retain cpio hard-link contents (morluto#15157) fix(artifacts): report macOS package bundle release versions (morluto#14860) test(asar): verify cleanup on the original file handle (morluto#15155) fix(ubi): bound smaller-grid probe memoization (morluto#15168) fix(artifacts): distinguish content from containment changes (morluto#15165) fix(bflt): retain complete text when data is truncated (morluto#15160) refactor(domain): reuse graph projection and validation helpers (morluto#15173) fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801) test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172)
* commit '91380cff6a6ce8b82b042ceb4e5013f3cc87a9d0': fix(ci): run npm lifecycle hooks in selected host lanes (morluto#15169) fix(artifacts): retain stored files in Godot PCK patches (morluto#15180) fix(setup): do not persist versioned launcher paths (morluto#15123) fix(devicetree): read later FDT versions backwards compatible with v17 (morluto#14136) fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949) fix(macos-pkg): retain cpio hard-link contents (morluto#15157) fix(artifacts): report macOS package bundle release versions (morluto#14860) test(asar): verify cleanup on the original file handle (morluto#15155)
* commit '6053481d47c518af7de8e6a88a3579f1f95e7851': fix(nds): bind file names to disjoint FNT subtables (morluto#15178) fix(glb): preserve JSON chunk read failures (morluto#15181) fix(ci): run npm lifecycle hooks in selected host lanes (morluto#15169) fix(artifacts): retain stored files in Godot PCK patches (morluto#15180) fix(setup): do not persist versioned launcher paths (morluto#15123) fix(devicetree): read later FDT versions backwards compatible with v17 (morluto#14136) fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949) fix(macos-pkg): retain cpio hard-link contents (morluto#15157) fix(artifacts): report macOS package bundle release versions (morluto#14860)
* commit '5c3c1edd72453746266691deca2c7355a8df9b0d': (623 commits) fix(dtbo): keep coverage unknown beyond the declared image (morluto#15182) perf(n64): stream ROM byte-order normalization (morluto#15179) fix(oci)!: keep unobserved directory identity unknown (morluto#15164) fix(nds): bind file names to disjoint FNT subtables (morluto#15178) fix(glb): preserve JSON chunk read failures (morluto#15181) fix(ci): run npm lifecycle hooks in selected host lanes (morluto#15169) fix(artifacts): retain stored files in Godot PCK patches (morluto#15180) fix(setup): do not persist versioned launcher paths (morluto#15123) fix(devicetree): read later FDT versions backwards compatible with v17 (morluto#14136) fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949) fix(macos-pkg): retain cpio hard-link contents (morluto#15157) fix(artifacts): report macOS package bundle release versions (morluto#14860) test(asar): verify cleanup on the original file handle (morluto#15155) fix(ubi): bound smaller-grid probe memoization (morluto#15168) fix(artifacts): distinguish content from containment changes (morluto#15165) fix(bflt): retain complete text when data is truncated (morluto#15160) refactor(domain): reuse graph projection and validation helpers (morluto#15173) fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801) test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172) test(beam): reuse the CLI Evidence reader (morluto#15171) ... # Conflicts: # src/cli/cliCommandRegistrations.ts
* commit '31cec30f51fb59b28a1849a67d09ab79b1c40094': (803 commits) fix(android): declare Android mapping and JNI fixed allowances (morluto#15183) fix(artifacts): retain deep comparison source chains (morluto#15191) perf(evidence): bound link inspection frontier by records (morluto#15189) perf(evidence): retain snapshots across duplicate imports (morluto#15186) fix(nro): exclude ASET header bytes from asset ranges (morluto#15185) fix(bflt): reject relocation tables overlapping image segments (morluto#15188) docs(artifacts): document Kubernetes audit log inventory (morluto#15187) fix(dtbo): keep coverage unknown beyond the declared image (morluto#15182) perf(n64): stream ROM byte-order normalization (morluto#15179) fix(oci)!: keep unobserved directory identity unknown (morluto#15164) fix(nds): bind file names to disjoint FNT subtables (morluto#15178) fix(glb): preserve JSON chunk read failures (morluto#15181) fix(ci): run npm lifecycle hooks in selected host lanes (morluto#15169) fix(artifacts): retain stored files in Godot PCK patches (morluto#15180) fix(setup): do not persist versioned launcher paths (morluto#15123) fix(devicetree): read later FDT versions backwards compatible with v17 (morluto#14136) fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949) fix(macos-pkg): retain cpio hard-link contents (morluto#15157) fix(artifacts): report macOS package bundle release versions (morluto#14860) test(asar): verify cleanup on the original file handle (morluto#15155) ...
* commit '31cec30f51fb59b28a1849a67d09ab79b1c40094': (803 commits) fix(android): declare Android mapping and JNI fixed allowances (morluto#15183) fix(artifacts): retain deep comparison source chains (morluto#15191) perf(evidence): bound link inspection frontier by records (morluto#15189) perf(evidence): retain snapshots across duplicate imports (morluto#15186) fix(nro): exclude ASET header bytes from asset ranges (morluto#15185) fix(bflt): reject relocation tables overlapping image segments (morluto#15188) docs(artifacts): document Kubernetes audit log inventory (morluto#15187) fix(dtbo): keep coverage unknown beyond the declared image (morluto#15182) perf(n64): stream ROM byte-order normalization (morluto#15179) fix(oci)!: keep unobserved directory identity unknown (morluto#15164) fix(nds): bind file names to disjoint FNT subtables (morluto#15178) fix(glb): preserve JSON chunk read failures (morluto#15181) fix(ci): run npm lifecycle hooks in selected host lanes (morluto#15169) fix(artifacts): retain stored files in Godot PCK patches (morluto#15180) fix(setup): do not persist versioned launcher paths (morluto#15123) fix(devicetree): read later FDT versions backwards compatible with v17 (morluto#14136) fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949) fix(macos-pkg): retain cpio hard-link contents (morluto#15157) fix(artifacts): report macOS package bundle release versions (morluto#14860) test(asar): verify cleanup on the original file handle (morluto#15155) ...
Summary
Closes #14134
inspect_devicetreeadmitted only FDT versions 16 and 17, so a blob that declares a later version but stays backwards compatible with version 17 was refused asunsupported_target, and FIT recognition did not claim a FIT in such a version. DTSpec §5.1 requires a client to accept any version backwards compatible with version 17. This PR reads such a blob with the version 17 header layout and reports its declared version.Problem and expected behavior
Smallest trigger: a dtc-written DTB (
version17,last_comp_version16) whose version word at offset 20 is changed to 18.On
main(dcf7e25d0),readDevicetreeHeaderrefused every version other than 16 and 17 before readinglast_comp_version(src/domain/firmware/devicetreeHeader.ts:34-39), and usedlast_comp_versiononly to reject a value above the version (line 55).hasFitImagesNodereturnsfalseon that failure (src/domain/firmware/fitImage.ts:17-21).DTSpec §5.1: "DTSpec compliant client programs shall accept devicetrees of any version backwards compatible with version 17 and may accept other versions as well." §5.2 defines
last_comp_versionas "the lowest version of the devicetree data structure with which the version used is backwards compatible". libfdt applies the rule infdt_header_size_andfdt_check_header: it refuses only aversionbelow 2, alast_comp_versionabove 17 or aversionbelowlast_comp_version, and uses the version 17 header size for every version above 16.Expected: such a blob is inspected and reports
header.versionas declared, itslast_comp_versionand a non-nullheader.size_dt_struct. A later version whoselast_comp_versionis above 17 staysunsupported_target.No producer I know writes a version above 17 today. dtc at the same commit writes versions 1, 2, 3, 16 and 17 (
flattree.c:23-34). The change is the forward compatibility the format defines throughlast_comp_version.Change and scope
src/domain/firmware/devicetreeHeader.ts:last_comp_versionis read before admission. A version below 16, or a later version whoselast_comp_versionis above 17, staysunsupported, and the message now nameslast_comp_versionand the rule. The version 17 header size andsize_dt_structare selected withversion >= 17. Versions 16 and 17 take the same paths as before, includingmalformedforlast_comp_version > version.docs/devicetree.md,docs/fit-images.md: the admission rule with the DTSpec reference, and the synthetic coverage.FIT recognition (
hasFitImagesNode) andFitArtifactReadersharereadDevicetreeHeader, so they follow the rule without a change of their own.Not included:
inspect_devicetreetool description (src/contracts/native/binaryDiagnosticsToolContracts.ts:140),docs/getting-started/cli.md:1952anddocs/guides/firmware/firmware-analysis.md:528keep "FDT v16/v17". A compatible later version is read with the version 17 layout, the rule is stated indocs/devicetree.md, and changing the tool description would also change the generated catalog.Contribution scope: ordinary fix within existing boundaries (static format inspection); maintainer scope decision not applicable.
Contract and boundary impact
readDevicetreeHeaderowns FDT header admission forparseDevicetree,hasFitImagesNodeandFitArtifactReader. None of them branches onheader.version;parseDevicetreecheckssize_dt_struct !== null, which holds for every admitted version above 16.header.versionand the FITfdt_versionare already unconstrained integers). A blob withversionabove 17 andlast_comp_version16 or 17, refused before asunsupported_target, is now inspected. Theunsupportedmessage text changes.docs/public/product-catalog.json), package, or installation impact: none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/domain/firmware/devicetreeParser.test.ts, "reads a later version only when it is backwards compatible with v17": the shared fixture withversion18 andlast_comp_version16 decodes withsize_dt_structread from offset 36 and the same summary as v17, and the same fixture withlast_comp_version18 is refused as unsupported. On the base reader the first parse throwsFDT version 18 is unsupported; supported versions are 16 and 17.src/domain/artifactFormatRecognition.test.ts, "recognizes FIT from an FDT v%s structure in a bounded prefix": version 18 joins 16 and 17. On the base readerhasFitImagesNodereturnsfalsefor it.tests/acceptance/devicetreeCli.test.ts("reports unsupported DTB input") andtests/boundary/mcp/devicetreeMcp.test.ts("rejects relative paths and unsupported versions") used version 18 as an arbitrary unsupported version, with the fixture'slast_comp_version16. They now declarelast_comp_version18, so both public paths still returnunsupported_target.src/domain/firmware/devicetree.fixture.ts:devicetreeFixturetakes the declaredlast_comp_version, defaulting to the 16 it always wrote.fdt.c:69-106and dtcflattree.c:23-34atc954f9dd8, read on 2026-11-23.header.version: 18,header.last_comp_version: 16andheader.size_dt_structequal to the structure block size.Boundary regressions: format assumptions, with the accepted later version paired with the same header declaring
last_comp_version18. Detection and inspection share the reader: the accepted case is covered in both, and the refused case through the parser and the public CLI and MCP paths.For evidence-bearing changes:
Validation performed
readDevicetreeHeader, its callers (parseDevicetree,hasFitImagesNode,FitArtifactReader),devicetreeFixture,fitFixtureand every test that builds a devicetree with an explicit version (rgoversrcandtests).main(21cfc809b) is merged into the branch at2e17d192c. The only conflict was insrc/domain/artifactFormatRecognition.test.ts, wheremainadded three cases right before theit.eachthis PR extends to version 18; both sides are kept.maindid not changedevicetreeHeader.tsor the fixture since the original base.2e17d192c(run 46163668663): Static checks, Documentation, Build package, Portable tests, Native package baseline (linux x64), Build bundled Windows x64 native controls, Test shard (1/1) and CI required passed; none failed. The shard selected 24 affected files and ran 540 tests: 538 passed and 2 were skipped intests/boundary/filesystem/binaryTarget.test.ts, which this PR does not change. The selection includedsrc/domain/firmware/devicetreeParser.test.ts(46),src/domain/artifactFormatRecognition.test.ts(38),tests/acceptance/devicetreeCli.test.ts(11) andtests/boundary/mcp/devicetreeMcp.test.ts(5).Compatibility, safety, and release
totalsizeand the 40-byte version 17 header, and the reader never executes the file.Author readiness
Human owner: @viniciusdsandrade
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.