Skip to content

Commit c99f283

Browse files
tomchyrlubos
authored andcommitted
suit: Block accesses to DFU partition
Invalidate all MEM components that addresses the current DFU partition. Ref: NCSDK-27375 Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent f0f8a14 commit c99f283

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

subsys/suit/mci/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ zephyr_library_sources_ifdef(CONFIG_SUIT_MCI_IMPL_NRF54H20_SDFW src/suit_mci_nrf
1515
zephyr_library_sources(src/suit_generic_ids.c)
1616

1717
zephyr_library_link_libraries(suit_mci)
18+
zephyr_library_link_libraries(suit_utils)
1819
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STORAGE suit_storage_interface)
1920
zephyr_library_link_libraries(suit_execution_mode)

subsys/suit/mci/src/suit_mci_nrf54h20.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include <suit_mci.h>
77
#include <drivers/nrfx_common.h>
8+
#include <suit_storage.h>
89
#include <suit_storage_mpi.h>
910
#include <suit_execution_mode.h>
1011
#include <sdfw/lcs.h>
@@ -375,6 +376,43 @@ mci_err_t suit_mci_memory_access_rights_validate(const suit_manifest_class_id_t
375376
return MCI_ERR_MANIFESTCLASSID;
376377
}
377378

379+
/* If the SUIT orchestrator is currently processing update candidate,
380+
* block all MEM components (regardless of the manifest class ID)
381+
* that points to the DFU partition, or any other region that contains
382+
* update candidate.
383+
* This check is necessary to ensure that the digest of the
384+
* authenticated digest of manifest or involved new firmware components
385+
* remains unchanged during the whole update procedure.
386+
*/
387+
if (suit_execution_mode_updating()) {
388+
const suit_plat_mreg_t *update_regions = NULL;
389+
size_t update_regions_len = 0;
390+
suit_plat_err_t plat_err =
391+
suit_storage_update_cand_get(&update_regions, &update_regions_len);
392+
393+
if (plat_err != SUIT_PLAT_SUCCESS) {
394+
/* Should never happen as the execution mode indicates processing of
395+
* a pending update candiadate.
396+
*/
397+
return SUIT_PLAT_ERR_CRASH;
398+
}
399+
400+
/* Ensure that the regions are mutually exclusive.
401+
*
402+
* The condition below is a negation of the following condition:
403+
* (start_a) >= (start_b + size_b)
404+
* or
405+
* (start_b) >= (start_a + size_a)
406+
*/
407+
for (size_t i = 0; i < update_regions_len; i++) {
408+
if ((((uint8_t *)address) <
409+
(update_regions[i].mem + update_regions[i].size)) &&
410+
(update_regions[i].mem < (((uint8_t *)address) + mem_size))) {
411+
return MCI_ERR_NOACCESS;
412+
}
413+
}
414+
}
415+
378416
switch (role) {
379417
case SUIT_MANIFEST_UNKNOWN:
380418
return MCI_ERR_MANIFESTCLASSID;

0 commit comments

Comments
 (0)