diff options
| author | Daniel Golle <[email protected]> | 2026-07-28 23:09:53 +0100 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-08-10 12:32:41 -0600 |
| commit | fe9877c7d9dea740985edd11f7ff583e311568be (patch) | |
| tree | 137f56e3554aaf1bb81a7493d8c901022ad183d4 /include | |
| parent | 2601d94691c00e0a05dc61241bb91d680519d49b (diff) | |
test: fit: verify dm-verity roothash is covered by the config signature
A dm-verity protected filesystem image is not hashed by U-Boot; its
integrity is delegated to the kernel, which trusts the roothash taken
from the FIT dm-verity subnode. For that chain of trust to hold, the
roothash (and salt) must be part of the region covered by the
configuration signature, otherwise an attacker can replace both the
filesystem and the roothash while keeping the signature valid.
Add two independent checks of this property:
- test/py/tests/test_fit_verity_sign.py signs a configuration that
references a filesystem image carrying a dm-verity subnode, then
confirms that tampering the roothash or the salt is rejected by
fit_check_sign. A control that tampers a byte known to be signed
proves the check can fail. A matching page is added under
doc/develop/pytest/ so the module documentation is rendered with
the rest of the generated docs.
- test/boot/fit_verity.c gains a runtime unit test that builds the
exact node list the configuration signature is computed over,
turns it into hashed regions and checks both that the roothash
bytes fall inside a signed region and that tampering them changes
the hash. It needs no private key, so it also runs on real devices
and uses the same hash path a device would.
To let the unit test build the signed-region node list, rename the
config node-list helper to fit_config_get_signed_nodes(), make it
non-static and declare it in image.h.
Signed-off-by: Daniel Golle <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/image.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/image.h b/include/image.h index 4149ebbcce9..6edcb1995bf 100644 --- a/include/image.h +++ b/include/image.h @@ -1897,6 +1897,29 @@ struct image_region *fit_region_make_list(const void *fit, struct fdt_region *fdt_regions, int count, struct image_region *region); +/** + * fit_config_get_signed_nodes() - Build the list of nodes covered by a config + * signature + * + * Collects the paths of the nodes that the configuration signature is + * computed over: the root node, the configuration node, and for each image + * referenced by the configuration its node, its hash subnodes and its cipher + * and dm-verity subnodes. The result is the same node list used when creating + * and verifying the signature, and is suitable for passing to + * fdt_find_regions(). + * + * @fit: FIT blob + * @conf_noffset: Configuration node offset + * @node_inc: Array to fill with pointers to packed path strings + * @max_nodes: Number of entries in @node_inc + * @buf: Buffer for the packed null-terminated path strings + * @buf_len: Size of @buf + * Return: number of entries written to @node_inc, or -ve on error + */ +int fit_config_get_signed_nodes(const void *fit, int conf_noffset, + char **node_inc, int max_nodes, + char *buf, int buf_len); + static inline int fit_image_check_target_arch(const void *fdt, int node) { #ifndef USE_HOSTCC |
