Skip to content

Commit cb968d1

Browse files
ahasztagtomchy
authored andcommitted
suit: orchestrate nordic top install from root
Add a possibility to block nordic_top updates in case they should only be orchestrated from the root manifest. Signed-off-by: Artur Hadasz <[email protected]>
1 parent 0b5e80f commit cb968d1

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

subsys/mgmt/suitfu/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ menuconfig MGMT_SUITFU
1515

1616
if MGMT_SUITFU
1717

18+
config MGMT_SUITFU_WORKER_STACK_SIZE
19+
int "Stack size for the MGMT SUITFU worker thread"
20+
default 4096
21+
1822
config MGMT_SUITFU_INITIALIZE_SUIT
1923
bool "Initialize the SUIT DFU library on startup"
2024
default y

subsys/mgmt/suitfu/src/suitfu_mgmt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222

2323
LOG_MODULE_REGISTER(suitfu_mgmt, CONFIG_MGMT_SUITFU_LOG_LEVEL);
2424

25-
#define SYSTEM_UPDATE_WORKER_STACK_SIZE 2048
26-
27-
static K_THREAD_STACK_DEFINE(system_update_stack_area, SYSTEM_UPDATE_WORKER_STACK_SIZE);
25+
static K_THREAD_STACK_DEFINE(system_update_stack_area, CONFIG_MGMT_SUITFU_WORKER_STACK_SIZE);
2826

2927
struct system_update_work {
3028
struct k_work_delayable work;

subsys/suit/orchestrator_app/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ config SUIT_CLEANUP_ON_INIT
1919
depends on SUIT_ORCHESTRATOR_APP_CANDIDATE_PROCESSING
2020
default y
2121

22+
config SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN
23+
bool "Disallow independent update of the Nordic Top envelope (not as part of the root envelope)"
24+
depends on SUIT_ORCHESTRATOR_APP_CANDIDATE_PROCESSING
25+
depends on SUIT_PROCESSOR
26+
2227
endif # SUIT_ORCHESTRATOR_APP

subsys/suit/orchestrator_app/src/suit_orchestrator_app.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <sdfw/sdfw_services/suit_service.h>
2020
#include <suit_envelope_info.h>
2121
#include <suit_plat_mem_util.h>
22+
#include <suit_plat_decode_util.h>
2223
#if CONFIG_SUIT_CACHE_RW
2324
#include <suit_dfu_cache_rw.h>
2425
#endif
@@ -64,6 +65,40 @@ static int dfu_partition_erase(void)
6465

6566
#endif /* CONFIG_SUIT_ORCHESTRATOR_APP_CANDIDATE_PROCESSING */
6667

68+
#if CONFIG_SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN
69+
static int nordic_top_disallowed_check(uint8_t *candidate_envelope_address,
70+
size_t candidate_envelope_size)
71+
{
72+
int err = 0;
73+
struct zcbor_string manifest_component_id = {
74+
.value = NULL,
75+
.len = 0,
76+
};
77+
suit_manifest_class_id_t *candidate_class_id = NULL;
78+
suit_ssf_manifest_class_info_t nordic_top_class_info;
79+
80+
err = suit_processor_get_manifest_metadata(
81+
candidate_envelope_address, candidate_envelope_size, false, &manifest_component_id,
82+
NULL, NULL, NULL, NULL, NULL);
83+
84+
if (suit_plat_decode_manifest_class_id(&manifest_component_id, &candidate_class_id) !=
85+
SUIT_PLAT_SUCCESS) {
86+
LOG_ERR("Component ID of candidate is not a manifest class");
87+
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
88+
}
89+
90+
suit_get_supported_manifest_info(SUIT_MANIFEST_SEC_TOP, &nordic_top_class_info);
91+
92+
if (suit_metadata_uuid_compare(candidate_class_id, &nordic_top_class_info.class_id) ==
93+
SUIT_PLAT_SUCCESS) {
94+
LOG_ERR("Nordic top manifest class ID is not allowed in the update candidate");
95+
return -EACCES;
96+
}
97+
98+
return 0;
99+
}
100+
#endif /* CONFIG_SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN */
101+
67102
int suit_dfu_initialize(void)
68103
{
69104
LOG_DBG("Enter");
@@ -182,6 +217,14 @@ int suit_dfu_candidate_preprocess(void)
182217
LOG_INF("Update candidate envelope detected, addr: %p, size %d bytes",
183218
(void *)candidate_envelope_address, candidate_envelope_size);
184219

220+
#if CONFIG_SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN
221+
err = nordic_top_disallowed_check(candidate_envelope_address, candidate_envelope_size);
222+
223+
if (err != 0) {
224+
return err;
225+
}
226+
#endif /* CONFIG_SUIT_NORDIC_TOP_INDEPENDENT_UPDATE_FORBIDDEN */
227+
185228
err = suit_process_sequence(candidate_envelope_address, candidate_envelope_size,
186229
SUIT_SEQ_DEP_RESOLUTION);
187230
if (err == SUIT_SUCCESS) {

0 commit comments

Comments
 (0)