Skip to content

Commit

Permalink
ipc3: move pointer assignments to after validation
Browse files Browse the repository at this point in the history
UBSAN is complaining about the pointers being overflown given we haven't
checked the parameters. Move it behind the code that protects this to
satisfy the sanitizer.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
  • Loading branch information
cujomalainey authored and kv2019i committed Sep 5, 2024
1 parent 53adb48 commit 54bb3e4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ipc/ipc3/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,6 @@ static int ipc_trace_filter_update(uint32_t header)
int cnt;

packet = ipc->comp_data;
elem = packet->elems;
end = &packet->elems[packet->elem_cnt];

/* validation, packet->hdr.size has already been compared with SOF_IPC_MSG_MAX_SIZE */
if (sizeof(*packet) + sizeof(*elem) * packet->elem_cnt != packet->hdr.size) {
Expand All @@ -917,6 +915,9 @@ static int ipc_trace_filter_update(uint32_t header)
tr_info(&ipc_tr, "ipc: trace_filter_update received, size %d elems",
packet->elem_cnt);

elem = packet->elems;
end = &packet->elems[packet->elem_cnt];

/* read each filter set and update selected components trace settings */
while (elem != end) {
next_elem = trace_filter_fill(elem, end, &filter);
Expand Down

0 comments on commit 54bb3e4

Please sign in to comment.