Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: cel@kernel.org
Cc: john.fastabend@gmail.com, kuba@kernel.org, sd@queasysnail.net,
	davem@davemloft.net, pabeni@redhat.com, horms@kernel.org,
	davejwatson@fb.com, shuah@kernel.org, qingfang.deng@linux.dev,
	edumazet@kernel.org, netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v5 06/10] tls: Return copied data ahead of a run of empty records
Date: Sun, 18 Oct 2026 19:23:00 +0000	[thread overview]
Message-ID: <179235138070.3135.12865177018877469954@kernel.org> (raw)
In-Reply-To: <20261014-tls-follow-on-v5-6-e76c301d4f05@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The new early exit in tls_sw_recvmsg() (net/tls/tls_sw.c:1946,
  `if (decrypted + copied >= target) break;`) only fires once the low-…

--

tls: Return copied data ahead of a run of empty records

This patch makes tls_sw_recvmsg() leave its receive loop at a zero-length
application_data record once the receive low-water mark has been met. The
goal is to stop a stream of empty records from holding back data that has
already been copied. A reader that has copied nothing keeps reading empty
records for as long as they arrive.

Link: https://lore.kernel.org/r/179124254665.434549.12245680127262431659@kernel.org

> diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
> index 153ff135a395e..9b4e66567ee8d 100644
> --- a/net/tls/tls_sw.c
> +++ b/net/tls/tls_sw.c
> @@ -1939,6 +1939,12 @@ int tls_sw_recvmsg(struct sock *sk,
>  
>  			/* An empty record still marks a boundary. */
>  			msg->msg_flags |= MSG_EOR;
> +
> +			/* Return data already copied instead of holding it
> +			 * through a run of empty records.
> +			 */
> +			if (decrypted + copied >= target)
> +				break;
>  			continue;

[Severity: High]
Does this leave the same stall in place for a reader that is still below
target?

When SO_RCVLOWAT is above the bytes copied so far, or MSG_WAITALL makes
target equal len, the check above is false. The empty record then takes the
continue. An empty record changes neither len nor decrypted, so the loop
condition stays true:

    while (len && (decrypted + copied < target || tls_strp_msg_ready(ctx))) {

Each pass calls tls_rx_rec_wait(). That function recomputes the timeout on
every call and skips its wait loop while a record is ready:

    timeo = sock_rcvtimeo(sk, nonblock);

    while (!tls_strp_msg_ready(ctx)) {
        ...
        if (!timeo)
            return -EAGAIN;
        ...
    }

As a result, MSG_DONTWAIT, O_NONBLOCK and SO_RCVTIMEO never come into
play. The only way out is this check at the top of the loop:

    if (nodata && signal_pending(current)) {

So if a peer keeps validly encrypted empty application_data records ready,
can a nonblocking or timed reader with partial data stay in the kernel?
It would hold the socket and reader locks and withhold the data it has
already copied.

The commit message describes that outcome as "the reader does not get the
data already copied until the stream stops or a signal is pending". The
same applies to a reader that has copied nothing, which the commit message
mentions.

tls_sw_splice_read() and tls_sw_read_sock() in the same file already stop a
run of empty records with a counter:

    if (++nodata >= TLS_RX_NODATA_LIMIT) {
        err = -EAGAIN;
        goto splice_read_end;
    }

Would a consecutive-empty-record cap like TLS_RX_NODATA_LIMIT in
tls_sw_recvmsg() also cover the below-target and zero-copied readers? It
would also cover the case this patch handles. TLS_RX_NODATA_LIMIT is
currently defined after tls_sw_recvmsg(), so it would need to move up.

>  		}
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261014-tls-follow-on-v5-0-e76c301d4f05%40kernel.org

  reply	other threads:[~2026-10-18 19:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 18:28 [PATCH net-next v5 00/10] net/tls: Receive-path fixes for zero-length data records Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 01/10] tls: Bound consecutive no-data records in tls_sw_read_sock() Chuck Lever
2026-10-18 19:22   ` netdev-bot+sashiko
2026-10-19 15:05     ` Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 02/10] tls: Check for a pending signal after an empty record Chuck Lever
2026-10-18 19:22   ` netdev-bot+sashiko
2026-10-19 15:09     ` Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 03/10] tls: Honor O_NONBLOCK in tls_sw_splice_read() Chuck Lever
2026-10-18 19:22   ` netdev-bot+sashiko
2026-10-19 15:10     ` Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 04/10] tls: Consume empty data records " Chuck Lever
2026-10-18 19:22   ` netdev-bot+sashiko
2026-10-19 15:10     ` Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 05/10] tls: Consume empty data records in tls_sw_recvmsg() Chuck Lever
2026-10-18 19:22   ` netdev-bot+sashiko
2026-10-19 15:11     ` Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 06/10] tls: Return copied data ahead of a run of empty records Chuck Lever
2026-10-18 19:23   ` netdev-bot+sashiko [this message]
2026-10-19 15:12     ` Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 07/10] selftests: tls: Skip the zero_len tests when TLS is unavailable Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 08/10] selftests: tls: Extend coverage for zero-length records Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 09/10] selftests: tls: Cover splice on a nonblocking socket Chuck Lever
2026-10-14 18:28 ` [PATCH net-next v5 10/10] selftests: tls: Cover the empty-record cap in splice Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179235138070.3135.12865177018877469954@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=cel@kernel.org \
    --cc=davejwatson@fb.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qingfang.deng@linux.dev \
    --cc=sd@queasysnail.net \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox