|
5 | 5 | */ |
6 | 6 | #include <suit_mci.h> |
7 | 7 | #include <drivers/nrfx_common.h> |
| 8 | +#include <suit_storage.h> |
8 | 9 | #include <suit_storage_mpi.h> |
9 | 10 | #include <suit_execution_mode.h> |
10 | 11 | #include <sdfw/lcs.h> |
@@ -375,6 +376,43 @@ mci_err_t suit_mci_memory_access_rights_validate(const suit_manifest_class_id_t |
375 | 376 | return MCI_ERR_MANIFESTCLASSID; |
376 | 377 | } |
377 | 378 |
|
| 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 | + |
378 | 416 | switch (role) { |
379 | 417 | case SUIT_MANIFEST_UNKNOWN: |
380 | 418 | return MCI_ERR_MANIFESTCLASSID; |
|
0 commit comments