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

[Backport v3.7-branch] net: socket: Release packets in accepted socket in close #85073

Open
wants to merge 1 commit into
base: v3.7-branch
Choose a base branch
from

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
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: To do
Development

Successfully merging this pull request may close these issues.

3 participants