Skip to content

Commit f604dfa

Browse files
UEWBotAnton-TF
authored andcommitted
Mailbox: Avoid possible out-of-range write
tfm_mailbox_hal_init() should ensure that spe_mailbox_queue.ns_slot_count is always <= NUM_MAILBOX_QUEUE_SLOT, but it's safest to also check before writing to the spe_mailbox_queue.queue[] array. Signed-off-by: Chris Brand <chris.brand@cypress.com> Change-Id: I67e03295df0989a125c1f2460fd086c1a8688c43
1 parent 144178f commit f604dfa

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

secure_fw/partitions/ns_agent_mailbox/tfm_spe_mailbox.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ int32_t tfm_mailbox_handle_msg(void)
369369
return MAILBOX_NO_PEND_EVENT;
370370
}
371371

372-
for (idx = 0; idx < spe_mailbox_queue.ns_slot_count; idx++) {
372+
for (idx = 0;
373+
(idx < spe_mailbox_queue.ns_slot_count) && (idx < NUM_MAILBOX_QUEUE_SLOT);
374+
idx++) {
373375
mask_bits = (1 << idx);
374376
/* Check if current NSPE mailbox queue slot is pending for handling */
375377
if (!(pend_slots & mask_bits)) {

0 commit comments

Comments
 (0)