Skip to content

Commit 57ed0a7

Browse files
lopsided98aescolar
authored andcommitted
logging: multidomain_link: fix crash caused by drop notification
The remote domain may send unsolicited Z_LOG_MULTIDOMAIN_ID_DROPPED IPC messages, which are not handled in log_multidomain_link_on_recv_cb(). With CONFIG_ASSERT=y, this will cause an assertion failure. With asserts disabled, this message would be treated as a reply to any in progress request and cause getter_msg_process() to return early. In turn, this can cause various kinds of memory corruption when the real reply arrives and the callback reads/writes stack variables that are no longer valid. Fix this by explicitly ignoring Z_LOG_MULTIDOMAIN_ID_DROPPED, and also don't treat unrecognized message types as replies. Signed-off-by: Ben Wolsieffer <[email protected]>
1 parent 7f11541 commit 57ed0a7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/logging/log_multidomain_link.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ void log_multidomain_link_on_recv_cb(struct log_multidomain_link *link_remote,
7676
case Z_LOG_MULTIDOMAIN_ID_SET_RUNTIME_LEVEL:
7777
link_remote->dst.set_runtime_level.level = msg->data.set_rt_level.runtime_level;
7878
break;
79+
case Z_LOG_MULTIDOMAIN_ID_DROPPED:
80+
return;
7981
case Z_LOG_MULTIDOMAIN_ID_READY:
8082
break;
8183
default:
8284
__ASSERT(0, "Unexpected message");
83-
break;
85+
return;
8486
}
8587

8688
exit:

0 commit comments

Comments
 (0)