Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] UDP RX stack corruption (if multiple matching connections) #14743

Open
1 task done
kk-thrane opened this issue Nov 12, 2024 · 1 comment
Open
1 task done

[BUG] UDP RX stack corruption (if multiple matching connections) #14743

kk-thrane opened this issue Nov 12, 2024 · 1 comment
Labels
Arch: arm Issues related to ARM (32-bit) architecture Area: Networking Effects networking subsystem OS: Linux Issues related to Linux (building system, etc) Type: Bug Something isn't working

Comments

@kk-thrane
Copy link
Contributor

kk-thrane commented Nov 12, 2024

Description / Steps to reproduce the issue

What I observe

I believe there is an error in the UDP receive logic when an incoming UDP packet matches multiple UDP connections. The udp_readahead() "unflatten" what should be meta-data, but seems to be the original IP packet. The resulting meta-data is thus garbled, which in my case results in stack corruption when iob_copyout() uses a too large "src_addr_size" to copy into an object on the stack.
My attached patch adds a DEBUGASSERT() to udp_readahead() which gets triggered. I hope it makes clear what happens.

Possible cause

I added some debug logging and noticed that the value of dev->d_len matched the size of the application data before udp_input_conn() was called the 1st time by udp_input(). The second time (for the second UDP connection), the value of dev->d_len was 28 (decimal) larger, which equals the value of udpiplen. dev->d_len was updated by the call to netdev_iob_replace() in udp_input().
My attached patch does an attempt on fixing this, but I have no idea whether it is correct or not (it seems to fix the issue I experience).

Steps to reproduce

I have multiple proprietary hardware devices with STM32H725 (which is not supported upstream) connected in a network. The network traffic is also generated with proprietary application software.
Hence, I have a hard time providing steps to reproduce this issue. So please let me know the best approach in this case, and I will try supply any further information you need.

Related issue?

I am unsure if this bug is an expected consequence of: #3374

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Ubuntu 24.04

NuttX Version

12.7

Issue Architecture

[Arch: arm]

Issue Area

[Area: Networking]

Verification

  • I have verified before submitting the report.
@kk-thrane kk-thrane added the Type: Bug Something isn't working label Nov 12, 2024
@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Area: Networking Effects networking subsystem OS: Linux Issues related to Linux (building system, etc) labels Nov 12, 2024
@kk-thrane
Copy link
Contributor Author

kk-thrane commented Nov 12, 2024

udp.txt
For some reason github didn't allow me to attacht the file as a .patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: arm Issues related to ARM (32-bit) architecture Area: Networking Effects networking subsystem OS: Linux Issues related to Linux (building system, etc) Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant