-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Add minimal unit tests for TCP2 #24346
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
Conversation
jukkar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
causing CI failure. |
@MaureenHelm, are you aware of this? |
Let's rename: SRC -> TCP_EP_SRC, DST -> TCP_EP_DST |
Ok. |
e5a2c14 to
2e6ab81
Compare
ozhuraki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
I couldn't see these failures earlier. after "west update" something changed itseems. I could see test fails in my system too. Investigating it. |
|
something fishy with upstream, 3f8c83a was the last commit in my local branch where there are no issues with this PR.If I rebase it crashes. Have to bisect. |
|
after git bisect commit 38031dd causing crashes in this tests. |
|
If I add CONFIG_MEM_POOL_HEAP_BACKEND=n then it passes. |
|
Is it hitting a failing allocation where it used to pass or a crash inside or due to the allocator itself? |
|
Or for that matter: a succeeding allocation where it used to fail, thus exercising code paths that weren't hit before. There were a nontrivial number of spots in the test cases where code was doing some allocation, assuming that the heap would now be full, and then being surprised when the new heap was a little more flexible and returned memory. |
|
It occurs to me that another possibility is a genuine buffer overflow in the code under test. The older mem_pool would put all the heap block memory in a contiguous region and kept the metadata separate. The new code mixes them together in a more conventional architecture. But that means that if the buffers all contain mostly-ignored bytes (i.e. they're just network buffers that don't get inspected in the test), an overflow might go undetected in the old code where in the new implementation it will corrupt the heap. |
It looks like that. but need to investigate it. |
|
To me 754c268 might be fixing the symptom instead of the root cause. If the error is just out of size access on the allocated IPv4 tcp_endpoint by comparing it with IPv6 endpoint, the fix would be just find a place and add a check to prevent this. Could you please check, and if it is so, consider dropping 754c268. If done like in 754c268, I would suggest just to embed the union tcp_endpoint into struct tcp. |
The |
|
trigger the CI, random kernel tests are failing. |
root cause is not only comparison, also allocation. |
Indeed, good catch! |
This was the whole point, i.e. 8 bytes are needed for IPv4, 24 for IPv6. The root cause is most likely missing a check in tcp_endpoint_cmp(). |
Sure, but the code only allocates 8 bytes, but the struct is 24 bytes long (if IPv6 is enabled), so we overwrite the memory area by 16 bytes. |
The code allocates 8 or 24, and the sa_family in the most generic member of this union is used to check/ensure we are working with IPv4 or IPV6. |
Ok, so it seems we have some code that writes past the allocated entry. |
I tried to debug it, it's actually this line in net_tcp_connect(): |
thanks @ozhuraki. I dropped my patch. please submit your patch. This PR goes through CI after your fix gets into upstream. |
|
len is ssize_t variable type, %zd should be there. Signed-off-by: Ravi kumar Veeramally <[email protected]>
Some other part of Zephyr has similar defines (SRC) causing build failures. Signed-off-by: Ravi kumar Veeramally <[email protected]>
Minimal tests for TCP2 functionality added. Signed-off-by: Ravi kumar Veeramally <[email protected]>
Minimal tests for TCP2 functionality added.
LCOV - code coverage report