Skip to content

net: sockets: tls: Prevent infinite block during handshake #78492

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

Merged

Conversation

rlubos
Copy link
Contributor

@rlubos rlubos commented Sep 16, 2024

In case peer goes down or we disconnect from the network during the TLS handshake, the TLS socket may block indefinitely during connect()/accept(), waiting for data from the peer. This should be avoided, hence use the preconfigured timeout for the TLS handshake, same as we use for TCP-level handshake.

Fixes #78494

@clamattia
Copy link
Contributor

Thank you. Please consider updating the comment in sendto_dtls_client explaining, why K_FOREVER is ok there instead of the TODO.

In case peer goes down or we disconnect from the network during the
TLS handshake, the TLS socket may block indefinitely during
connect()/accept(), waiting for data from the peer. This should be
avoided, hence use the preconfigured timeout for the TLS handshake,
same as we use for TCP-level handshake.

Signed-off-by: Robert Lubos <[email protected]>
@rlubos rlubos force-pushed the net/tls-socket-handshake-timeout branch from 046540b to 0b2fbd8 Compare September 16, 2024 15:28
@rlubos
Copy link
Contributor Author

rlubos commented Sep 16, 2024

Thank you. Please consider updating the comment in sendto_dtls_client explaining, why K_FOREVER is ok there instead of the TODO.

Added additional comment but left the TODO, as it's about something else (blocking/non-blocking socket behavior).

Copy link
Contributor

@clamattia clamattia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you once again

@rlubos rlubos added the backport v3.7-branch Request backport to the v3.7-branch label Sep 17, 2024
@nashif nashif merged commit fc007ee into zephyrproject-rtos:main Sep 19, 2024
26 checks passed
@rlubos rlubos deleted the net/tls-socket-handshake-timeout branch April 24, 2025 13:17
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 v3.7-branch Request backport to the v3.7-branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subsys: net: socket_tls: Connection vanishes -> Caller blocked forever
7 participants