Skip to content

ipc: Fix ipc_msg_send() with payload already prepared#10717

Open
ujfalusi wants to merge 1 commit intothesofproject:mainfrom
ujfalusi:peter/pr/fix_msg_send_with_payload
Open

ipc: Fix ipc_msg_send() with payload already prepared#10717
ujfalusi wants to merge 1 commit intothesofproject:mainfrom
ujfalusi:peter/pr/fix_msg_send_with_payload

Conversation

@ujfalusi
Copy link
Copy Markdown
Contributor

If the msg->tx_size/data have been prepared by caller and it calls the function with NULL as data: ipc_msg_send(msg, NULL, false);

then we try to copy from NULL to the msg->tx_data because msg->tx_data != data is true.

The callers could be fixed as well, but the ipc_msg_send() should handle this.

Copilot AI review requested due to automatic review settings April 23, 2026 08:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes ipc_msg_send() so callers can pre-populate msg->tx_data/tx_size and safely call ipc_msg_send(msg, NULL, ...) without triggering a copy attempt from a NULL pointer.

Changes:

  • Guard the payload copy in ipc_msg_send() with data != NULL to avoid memcpy_s() from NULL.
  • Preserve the “no-copy” path for cases where the payload is already prepared in msg->tx_data.

If the msg->tx_size/data have been prepared by caller and it calls the
function with NULL as data: ipc_msg_send(msg, NULL, false);

then we try to copy from NULL to the msg->tx_data because
msg->tx_data != data is true.

The callers could be fixed as well, but the ipc_msg_send() and
ipc_msg_send_direct() should handle this.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi ujfalusi force-pushed the peter/pr/fix_msg_send_with_payload branch from 69a7486 to b057205 Compare April 23, 2026 11:58
@ujfalusi
Copy link
Copy Markdown
Contributor Author

Changes since v1:

  • update ipc_msg_send_direct() as well

Note: this causes only firmware crash in debug build as assert() is NOP otherwise.

Copy link
Copy Markdown
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo on commit, good otherwise.

Comment thread src/ipc/ipc-common.c
@@ -205,7 +205,7 @@ __cold void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
key = k_spin_lock(&ipc->lock);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

messagegate sending or message sending?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants