Subject: Re: [PATCH net-next v11 6/6] tls: Flush backlog before waiting for a new record

From: Sabrina Dubroca <[email-masked]>
Date: Thu, 28 May 2026 11:14:41 +0200

2026-05-26, 10:21:36 -0400, Chuck Lever wrote:
> diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
> index df4cdf11f784..d2f31623511a 100644
> --- a/net/tls/tls_sw.c
> +++ b/net/tls/tls_sw.c
> @@ -1400,6 +1400,8 @@ tls_rx_rec_wait(struct sock *sk, struct sk_psock *psock, bool nonblock,
>  		if (ret < 0)
>  			return ret;
>  
> +		if (sk_flush_backlog(sk))
> +			released = true;
>  		if (!skb_queue_empty(&sk->sk_receive_queue)) {
>  			/* Defer notification to the exit point; this thread
>  			 * will consume the record directly.
> @@ -1409,6 +1411,13 @@ tls_rx_rec_wait(struct sock *sk, struct sk_psock *psock, bool nonblock,
>  				break;
>  		}
>  
> +		/* sk_flush_backlog() can run tcp_reset(), which sets
> +		 * sk_err and then sk_shutdown via tcp_done(). Recheck
> +		 * sk_err here so a connection abort surfaces as the
> +		 * actual error rather than a clean EOF.
> +		 */
> +		if (sk->sk_err)
> +			return -READ_ONCE(sk->sk_err);

This should have the same "if (has_copied)" handling as the top of the
loop got in f508262ae9f2 ("tls: Preserve sk_err across recvmsg() when
data has been copied") ?

-- 
Sabrina