This series fixes some issues in the RAUC bootmeth and adds two options to make it safer to use on real devices, together with tests.
Patches 1-4 fix bugs in bootmeth_rauc.c: an uninitialised pointer when a bootflow has no block device, a leak of the active slot name, a stack buffer overflow with long slot names in BOOT_ORDER, and a leak of the boot script when a boot attempt fails and is retried. Patch 5 makes the RAUC test restore the bootdev order also if it fails. Before, a failing check left a static array in std->bootdev_order, which was then passed to free() and aborted sandbox. Patches 6 and 7 add two new options, both empty by default so that nothing changes for existing users: - CONFIG_BOOTMETH_RAUC_PART_NAMES sets the expected GPT names of the boot and root partitions of each slot. Without it, the bootmeth claims any MMC device whose partitions happen to fit the configured layout, such as a standard distro installed to eMMC, and writes its BOOT_ORDER and BOOT_x_LEFT variables to the environment. This allows to use BOOTMETH_RAUC safely alongside other bootmeths. - CONFIG_BOOTMETH_RAUC_BOOTCMD sets a command built into U-Boot that boots the slot instead of running boot.scr from the boot partition. Nothing authenticates that partition, and signing the script is not a reliable fix, as the environment must stay writable for the RAUC variables and setting verify=no there skips all checks. With this option, U-Boot executes nothing from the boot partition. Patches 8-10 add sandbox tests for both options. As partition names need GPT, patch 8 adds GPT support to DiskHelper in fs_helper.py, which the RAUC test image now uses. checkpatch warns about the #ifdef in the tests in patches 9 and 10. It is needed, as the string options do not exist without CONFIG_BOOTMETH_RAUC and IS_ENABLED() cannot check a string. Signed-off-by: Frieder Schrempf <[email protected]> --- Frieder Schrempf (10): bootstd: rauc: Initialise desc in distro_rauc_scan_parts() bootstd: rauc: Fix leak of the active slot name bootstd: rauc: Fix overflow of the BOOT_x_LEFT name buffer bootstd: rauc: Free the boot script of a failed boot attempt test: boot: Restore the bootdev order if the RAUC test fails bootstd: rauc: Optionally check the partition names bootstd: rauc: Optionally boot with a built-in command test: fs_helper: Support GPT in DiskHelper test: boot: Test the RAUC partition name check test: boot: Test the RAUC built-in boot command arch/sandbox/dts/test.dts | 8 +++ boot/Kconfig | 29 ++++++++ boot/bootmeth_rauc.c | 156 +++++++++++++++++++++++++++++++++++-------- configs/sandbox_defconfig | 3 + doc/develop/bootstd/rauc.rst | 15 +++++ test/boot/bootflow.c | 153 ++++++++++++++++++++++++++++++++++++++---- test/py/tests/fs_helper.py | 36 +++++++--- test/py/tests/test_ut.py | 26 +++++--- 8 files changed, 367 insertions(+), 59 deletions(-) --- base-commit: 03e45557e1f38a39a0c80fe30483130ff376cf92 change-id: 20261029-main-c3a89be613d5 Best regards, -- Frieder Schrempf <[email protected]>
