From: Sabrina Dubroca <sd@queasysnail.net>
To: Chuck Lever <cel@kernel.org>
Cc: John Fastabend <john.fastabend@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Shuah Khan <shuah@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net 2/2] selftests: tls: cover splice after a failed decrypt
Date: Tue, 11 Aug 2026 12:45:27 +0200 [thread overview]
Message-ID: <anr9R3FfLC_Kug8m@krikkit> (raw)
In-Reply-To: <20260806-tls-splice-crypto-fix-v1-2-a2624005a286@kernel.org>
2026-08-06, 20:44:08 -0400, Chuck Lever wrote:
> Nothing in this file splices a socket whose last decrypt failed, so
> the check that fails tls_sw_splice_read() on a broken connection can
> be removed without a test noticing. Such a splice hands the
> application plaintext that recvmsg() and read_sock() already refuse
> to return.
>
> Extend the bad_auth pattern. Corrupt an authenticated record, confirm
> recvmsg() reports EBADMSG, then splice the same socket and require
> EBADMSG again. A synchronous decrypt fails again on the still-queued
> record, so only an async decrypt reaches EBADMSG through the
> recorded-failure check alone.
>
> bad_auth builds the same corrupted record, so its construction moves
> into a helper the two tests share.
>
> Signed-off-by: Chuck Lever <cel@kernel.org>
> ---
> tools/testing/selftests/net/tls.c | 75 +++++++++++++++++++++++++++++++++------
> 1 file changed, 65 insertions(+), 10 deletions(-)
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
(just one nit:)
> +/* cfd carries a byte stream, so one recv() can return part of a
> + * record. Take the fragment length from the record header and wait
> + * for the remainder.
> + */
I understand what the function does, but it took me a while to parse
this comment. Now I see it applies more to the
"MSG_WAITALL/len/MSG_WAITALL" construct than to the overall function
(the function's name gives a good enough description of what it does).
> +static void tls_send_bad_auth(struct __test_metadata *_metadata,
> + int fd, int cfd, int fd2)
> +{
> + char buf[128];
> + int len;
> +
> + memrnd(buf, sizeof(buf) / 2);
> + ASSERT_EQ(send(fd, buf, sizeof(buf) / 2, 0), sizeof(buf) / 2);
> +
> + ASSERT_EQ(recv(cfd, buf, TLS_HDR_LEN, MSG_WAITALL), TLS_HDR_LEN);
> +
> + len = ((unsigned char)buf[3] << 8) | (unsigned char)buf[4];
> + ASSERT_GT(len, 0);
> + ASSERT_LE(len, (int)sizeof(buf) - TLS_HDR_LEN);
> +
> + ASSERT_EQ(recv(cfd, buf + TLS_HDR_LEN, len, MSG_WAITALL), len);
> +
> + buf[TLS_HDR_LEN + len - 1]++;
> +
> + ASSERT_EQ(send(fd2, buf, TLS_HDR_LEN + len, 0), TLS_HDR_LEN + len);
> +}
--
Sabrina
next prev parent reply other threads:[~2026-08-11 10:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 0:44 [PATCH net 0/2] net/tls: Fail splice after a failed async decrypt Chuck Lever
2026-08-07 0:44 ` [PATCH net 1/2] net/tls: Fail tls_sw_splice_read() " Chuck Lever
2026-08-11 10:41 ` Sabrina Dubroca
2026-08-07 0:44 ` [PATCH net 2/2] selftests: tls: cover splice after a failed decrypt Chuck Lever
2026-08-11 10:45 ` Sabrina Dubroca [this message]
2026-08-11 13:50 ` [PATCH net 0/2] net/tls: Fail splice after a failed async decrypt patchwork-bot+netdevbpf
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=anr9R3FfLC_Kug8m@krikkit \
--to=sd@queasysnail.net \
--cc=cel@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.