zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.85k stars 6.61k forks source link

Accept() error in secure sockets. #71525

Closed Nulllix closed 6 months ago

Nulllix commented 7 months ago

Discussed in https://github.com/zephyrproject-rtos/zephyr/discussions/66405

Originally posted by **Nulllix** December 11, 2023 ## Introduction Hey, everybody! I have an nRF52840-DK debug board on which I am trying to run [BSD Secure Sockets](https://docs.zephyrproject.org/latest/connectivity/networking/api/sockets.html#secure-sockets) on up the [IPSP](https://docs.zephyrproject.org/latest/samples/bluetooth/ipsp/README.html). I used the [echo server (advanced) example](https://docs.zephyrproject.org/latest/samples/net/sockets/echo_server/README.html#sockets-echo-server) as a basis. My code on which the problem is stably reproduced [is here](https://github.com/Nulllix/test_project). ## Problem I have written a [small python script](https://github.com/Nulllix/test_project/blob/main/utils/test_conn.py) that I'm trying to use to connect to my server. When I try to connect to nRF52840 with it, HardFault occurs in `accept(...)` function: ![image](https://github.com/zephyrproject-rtos/zephyr/assets/35011033/091b2e9b-5430-453a-a5bb-93dbfe66c6bb) I have enabled additional logs inside the bluetooth stack and as you can see, at some point the pointer to `user_data` takes an invalid value. Callstack which leads to HardFault: ![image](https://github.com/zephyrproject-rtos/zephyr/assets/35011033/d573c4c1-97f1-446d-93e0-8505500d9c30) Using a debugger I was able to get the full callstask which causes this error (inside `bt_conn_send_cb(...)` the functions you see in the screenshot above are called):
BIG SCREENSHOTS WITH CALLSTACK
The full log with the error and callstack in text form, can be [found here](https://github.com/Nulllix/test_project/tree/main/logs). ## How to reproduce? 1. Clone [my repository](https://github.com/Nulllix/test_project/tree/main). 2. Build and load firmware to nRF52840 from it. 3. Connect BLE adapter to PC (i use TL-LINK UB400) 4. Use script [board_connect.sh](https://github.com/Nulllix/test_project/blob/main/utils/board_connect.sh) to activate the 6lowpan and connect it to the board. 5. Use python script [test_conn.py](https://github.com/Nulllix/test_project/blob/main/utils/test_conn.py) to connect to the sockets. Has anyone ever encountered anything like this?
github-actions[bot] commented 7 months ago

Hi @Nulllix! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

jukkar commented 7 months ago

Note that IPSP support was just recently removed from upstream Zephyr. There were lot of issues with it, not sure if they were related to the issue you are seeing. See for example #68629 and #68627 for more details.

Nulllix commented 6 months ago

@jukkar Thanks for the info.