Skip to content

Conversation

@jukkar
Copy link
Member

@jukkar jukkar commented Feb 3, 2025

If we have received data to the accepted socket, then release those before removing the accepted socket. This is a rare event as it requires that we get multiple simultaneous connections and there is a failure before the socket accept is called by the application.
For example one such scenario is when HTTP server receives multiple connection attempts at the same time, and the server poll fails before socket accept is called. This leads to buffer leak as the socket close is not called for the accepted socket because the accepted is not yet created from application point of view. The solution is to flush the received queue of the accepted socket before removing the actual accepted socket.

Fixes #84538

Signed-off-by: Jukka Rissanen [email protected]
(cherry picked from commit 535e70a)

If we have received data to the accepted socket, then release
those before removing the accepted socket. This is a rare event
as it requires that we get multiple simultaneous connections
and there is a failure before the socket accept is called by
the application.
For example one such scenario is when HTTP server receives multiple
connection attempts at the same time, and the server poll fails
before socket accept is called. This leads to buffer leak as the
socket close is not called for the accepted socket because the
accepted is not yet created from application point of view.
The solution is to flush the received queue of the accepted socket
before removing the actual accepted socket.

Fixes zephyrproject-rtos#84538

Signed-off-by: Jukka Rissanen <[email protected]>
(cherry picked from commit 535e70a)
@jukkar jukkar added this to the v3.7.2 milestone Feb 3, 2025
@jukkar
Copy link
Member Author

jukkar commented Feb 3, 2025

This is a backport of #84660

@jukkar jukkar changed the title net: socket: Release packets in accepted socket in close [Backport v3.7-branch] net: socket: Release packets in accepted socket in close Feb 3, 2025
@jukkar jukkar added the Backport Backport PR and backport failure issues label Feb 3, 2025
@nashif nashif merged commit 28f1398 into zephyrproject-rtos:v3.7-branch Feb 21, 2025
32 of 33 checks passed
@jukkar jukkar deleted the backport/84660/to-v3.7-branch branch February 21, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Networking area: Sockets Networking sockets Backport Backport PR and backport failure issues

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants