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 <benwolsieffer@gmail.com>
This commit is contained in:
Ben Wolsieffer 2024-04-12 22:34:21 -04:00 committed by Alberto Escolar
parent 7f115412b1
commit 57ed0a7ae9
1 changed files with 3 additions and 1 deletions

View File

@ -76,11 +76,13 @@ void log_multidomain_link_on_recv_cb(struct log_multidomain_link *link_remote,
case Z_LOG_MULTIDOMAIN_ID_SET_RUNTIME_LEVEL:
link_remote->dst.set_runtime_level.level = msg->data.set_rt_level.runtime_level;
break;
case Z_LOG_MULTIDOMAIN_ID_DROPPED:
return;
case Z_LOG_MULTIDOMAIN_ID_READY:
break;
default:
__ASSERT(0, "Unexpected message");
break;
return;
}
exit: