-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
NULL pointer access in zsock_getsockname_ctx with TCP2 #28735
Comments
@armandciejak Please provide your changes to |
Here is the patch for diff --git a/lib/libc/minimal/source/string/string.c b/lib/libc/minimal/source/string/string.c
index 9344f824ca..3fb9a06933 100644
--- a/lib/libc/minimal/source/string/string.c
+++ b/lib/libc/minimal/source/string/string.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
+#include <sys/__assert.h>
/**
*
@@ -297,6 +298,9 @@ void *memmove(void *d, const void *s, size_t n)
void *memcpy(void *_MLIBC_RESTRICT d, const void *_MLIBC_RESTRICT s, size_t n)
{
+ __ASSERT(d != NULL, "d is NULL");
+ __ASSERT(s != NULL, "s is NULL");
+
/* attempt word-sized copying only if buffers have identical alignment */
unsigned char *d_byte = (unsigned char *)d; I tested the |
Could you send a PR for the memcpy() asserts, they look useful to have. |
Does this asserts fire only in debug mode or always? I would prefer them only for debugging purposes. |
Asserts are off by default. |
The local and accepted socket was not bound which caused the local address to be set as NULL. This then caused issues when zsock_getsockname() was called by the application. Fixes zephyrproject-rtos#28735 Signed-off-by: Jukka Rissanen <[email protected]>
@armandciejak fix proposal at #28755. I tested it but would appreciate if you can verify it works ok for you too. |
@jukkar Thanks for the fix. I tested it successfully ( Unfortunately I get another assert after a few round of curl downloading the home page:
|
Ok, that assert seems to be unnecessary. I added a commit to the #28755 that does not assert in this case. |
I created a new issue for the "Not in retransmission" assert: #28758. |
The local and accepted socket was not bound which caused the local address to be set as NULL. This then caused issues when zsock_getsockname() was called by the application. Fixes #28735 Signed-off-by: Jukka Rissanen <[email protected]>
Describe the bug
When testing civetweb sample application with TCP2 I noticed a NULL pointer access in
memcpy
when called inzsock_getsockname_ctx
. I added asserts into memcpy because I already had similar problems and it helped catching the faulty code. Without the assert the error get unnoticed.Note: The problem is not present in TCP1.
To Reproduce
Steps to reproduce the behavior:
__ASSERT(d != NULL, "d is NULL");
and__ASSERT(s != NULL, "s is NULL");
west build --board <YOUR BOARD> zephyr/samples/net/sockets/civetweb -p
west flash
curl http://192.168.1.241:8080
The error is systematic. I tried it on both mimxrt1050_evk and nucleo_f767zi and I got the same results.
Expected behavior
No NULL pointer access.
Impact
This is a show stopper for my project since we use civetweb and are migrating to Zephyr v2.4 because we need all the improvements of TCP2.
Logs and console output
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: