Skip to content

[REVERTME] net/socket: Add msg_copy_to_user and msg_copy_from_user fo…#451

Closed
jlaitine wants to merge 1 commit intomasterfrom
fix_sockets
Closed

[REVERTME] net/socket: Add msg_copy_to_user and msg_copy_from_user fo…#451
jlaitine wants to merge 1 commit intomasterfrom
fix_sockets

Conversation

@jlaitine
Copy link
Copy Markdown

@jlaitine jlaitine commented Apr 28, 2026

Hai earlier reported "https://jira.tii.ae/browse/SSRCDP-11725", he found corrupted can frames coming from NuttX network stack.

The issue appeared at some point, when updating NuttX baseline to a newer one, but it was never quite understood.

The issue seems to be profound and serious; in kernel builds, the network stack sometimes uses user-side buffer pointers in copying data, in recvmsg /sendmsg - not just for can, but for all blocking socket transfers.

This has been discovered by @arjav1528 in upstream apache NuttX, and started a fix proposal
https://redirect.github.com/apache/nuttx/pull/18712

The upstream issue tracking is in
https://redirect.github.com/apache/nuttx/issues/17321.

Until the issue gets resolved upstream, I believe we need to introduce a temporary fix in tiiuae branch. This PR introduces a network packet copy_from_user / copy_to_user fix to solve the issue. When the issue has been resolved upstream, this patch can be reverted.

This adds copying to/from kerenel memory when doing sendmsg/recvmsg to avoid
corrupting messages or other process' address environment, when the actual
device drivers do copy while the calling process is blocked.

This patch allocates one IOB for storing the metadata and the payload. If the
payload doesn't fit in the IOB, the payload is allocated from the kernel heap.

In other words, to optimize number of heap allocations, one can increase the IOB size
so that all the packets fit in one IOB.

This needs to be reverted when there is similar fix in upstream; the work is in
progress in apache#18712

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
@jlaitine jlaitine closed this Apr 28, 2026
@jlaitine jlaitine deleted the fix_sockets branch April 28, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant