Skip to content

Commit c15d5c6

Browse files
Shahar Shitritkuba-moo
authored andcommitted
net: tls: Cancel RX async resync request on rcd_delta overflow
When a netdev issues a RX async resync request for a TLS connection, the TLS module handles it by logging record headers and attempting to match them to the tcp_sn provided by the device. If a match is found, the TLS module approves the tcp_sn for resynchronization. While waiting for a device response, the TLS module also increments rcd_delta each time a new TLS record is received, tracking the distance from the original resync request. However, if the device response is delayed or fails (e.g due to unstable connection and device getting out of tracking, hardware errors, resource exhaustion etc.), the TLS module keeps logging and incrementing, which can lead to a WARN() when rcd_delta exceeds the threshold. To address this, introduce tls_offload_rx_resync_async_request_cancel() to explicitly cancel resync requests when a device response failure is detected. Call this helper also as a final safeguard when rcd_delta crosses its threshold, as reaching this point implies that earlier cancellation did not occur. Signed-off-by: Shahar Shitrit <[email protected]> Reviewed-by: Sabrina Dubroca <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 34892cf commit c15d5c6

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

include/net/tls.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,12 @@ tls_offload_rx_resync_async_request_end(struct tls_offload_resync_async *resync_
467467
atomic64_set(&resync_async->req, ((u64)ntohl(seq) << 32) | RESYNC_REQ);
468468
}
469469

470+
static inline void
471+
tls_offload_rx_resync_async_request_cancel(struct tls_offload_resync_async *resync_async)
472+
{
473+
atomic64_set(&resync_async->req, 0);
474+
}
475+
470476
static inline void
471477
tls_offload_rx_resync_set_type(struct sock *sk, enum tls_offload_sync_type type)
472478
{

net/tls/tls_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,10 @@ tls_device_rx_resync_async(struct tls_offload_resync_async *resync_async,
723723
/* shouldn't get to wraparound:
724724
* too long in async stage, something bad happened
725725
*/
726-
if (WARN_ON_ONCE(resync_async->rcd_delta == USHRT_MAX))
726+
if (WARN_ON_ONCE(resync_async->rcd_delta == USHRT_MAX)) {
727+
tls_offload_rx_resync_async_request_cancel(resync_async);
727728
return false;
729+
}
728730

729731
/* asynchronous stage: log all headers seq such that
730732
* req_seq <= seq <= end_seq, and wait for real resync request

0 commit comments

Comments
 (0)