Skip to content

Commit ff3bc08

Browse files
committed
ipc3: Don't trust size values in protocol input
The handling for SOF_COMP_NONE was extracting a "size" field from a struct sof_ipc_comp_process command and passing it down into the module_adapter layer where it was being used as the range for a memcpy_s(). But that struct is IPC input data from the host! The size can trivially be wrong and cause an overflow. And needless to say, fuzzing discovered the hole and blew it up. Note that the previous behavior when LIBRARY||UNIT_TEST is left unchanged (fuzz builds as "real" firmware and doesn't use those features). It turns out that this is still in production use, though the details of why the code is different are unclear. Drop a note in to fix this later. Signed-off-by: Andy Ross <andyross@google.com>
1 parent 192d1df commit ff3bc08

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ipc/ipc3/helper.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,14 @@ static void comp_specific_builder(struct sof_ipc_comp *comp,
277277
case SOF_COMP_MODULE_ADAPTER:
278278
case SOF_COMP_NONE:
279279
config->process.type = proc->type;
280-
config->process.size = proc->size;
281280
#if CONFIG_LIBRARY || UNIT_TEST
281+
/* FIXME: protocol code paths shouldn't be different for testing */
282+
config->process.size = proc->size;
282283
config->process.data = proc->data + comp->ext_data_length;
283284
#else
285+
/* Clamp size, don't trust the protocol-supplied value! */
286+
config->process.size = MIN(proc->size,
287+
SOF_IPC_MSG_MAX_SIZE - sizeof(*proc));
284288
config->process.data = proc->data;
285289
#endif
286290
break;

0 commit comments

Comments
 (0)