Skip to content

Match the full property name in the Versal device tree lookup and test it - #203

Merged
gasbytes merged 1 commit into
wolfSSL:masterfrom
dgarske:versal_ota_fdt
Dec 3, 2026
Merged

gasbytes merged 1 commit into
wolfSSL:masterfrom
dgarske:versal_ota_fdt

Conversation

@dgarske

@dgarske dgarske commented Dec 1, 2026

Copy link
Copy Markdown
Member

The Versal update example reads /chosen/wolfboot,boot-part from the device tree wolfBoot passes in, to learn which slot it booted from.

fdt_find_u32() compared the property name with strncmp() bounded by the bytes left in the string table. When the table ended partway through a name, only the bytes present were compared, so a truncated wolfboot,boot-p... matched wolfboot,boot-part. The lookup now requires the whole name and its terminator to lie inside the table.

  • src/port/amd/boards/versal/ota_fdt.c, ota_fdt.h: the lookup, moved out of ota_store.c so it builds on the host
  • src/test/test_ota_fdt.c: host unit test with well-formed, truncated and corrupted trees
  • Makefile, linux.yml: build/test-ota-fdt target, run in the Linux workflow (no wolfSSL needed)

Tested on a VMK180: update, tampered image rejected, wrong client certificate not confirmed, unconfirmed image rolled back, from both slots.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 21:50
@dgarske
dgarske requested a review from mattia-moffa December 1, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Property-name validation uses the blob boundary instead of the string-table boundary, allowing names with terminators outside the declared string table to be accepted.

1 open issue
What changed in this PR

This PR hardens the device-tree lookup used by the Versal OTA example to identify its boot slot and makes the parser testable on the host.

Changes:

  • Extracts the lookup into a separate module and compares the full property name, including its terminator.
  • Adds host tests for valid, truncated, and corrupted device trees.
  • Integrates the parser into the Versal build and adds a wolfSSL-independent test target to Linux CI.
File Description
src/​test/​test_ota_fdt.c Adds device-tree lookup tests.
src/​port/​amd/​boards/​versal/​ota_store.c Uses the extracted lookup function.
src/​port/​amd/​boards/​versal/​ota_fdt.h Declares and documents the lookup API.
src/​port/​amd/​boards/​versal/​ota_fdt.c Implements the parser with full-name comparison.
src/​port/​amd/​boards/​versal/​Makefile Links the parser into OTA builds.
Makefile Adds the wolfSSL-independent host test target.
.github/​workflows/​linux.yml Builds and runs the new host test.

Review effort: Balanced

Comment thread src/port/amd/boards/versal/ota_fdt.c Resolved
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

@gasbytes
gasbytes merged commit 23b809c into wolfSSL:master Dec 3, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants