From: chanyoung <ppoo1220@gmail.com>
To: netdev@vger.kernel.org
Cc: Sabrina Dubroca <sd@queasysnail.net>,
Jakub Kicinski <kuba@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
David Howells <dhowells@redhat.com>,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, chanyoung <ppoo1220@gmail.com>
Subject: [PATCH net v2 2/2] selftests: tls: add a test for splicing onto a full plaintext record
Date: Tue, 4 Aug 2026 14:28:36 +0900 [thread overview]
Message-ID: <20260804052837.49015-3-ppoo1220@gmail.com> (raw)
In-Reply-To: <20260804052837.49015-1-ppoo1220@gmail.com>
Splicing onto a plaintext sk_msg ring that is already full used to wrap the
ring and make the kernel oops in the scatterwalk once the record was
pushed.
Only the copy path leaves the ring full without pushing it, so splice until
the ring is one fragment short, add the last fragment with a one-byte
MSG_MORE send, and splice once more before pushing the record.
CONFIG_MAX_SKB_FRAGS is 17..45, so that last fragment follows between 16
and 44 splices; sweep that range to trigger the bug on any build.
Signed-off-by: chanyoung <ppoo1220@gmail.com>
---
tools/testing/selftests/net/tls.c | 37 +++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index cbdd3ea28b9..3d6f553eaf9 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -835,6 +835,43 @@ TEST_F(tls, send_and_splice)
EXPECT_EQ(memcmp(mem_send, mem_recv, send_len), 0);
}
+TEST_F(tls, splice_onto_full_record)
+{
+ char mem_send[4608];
+ char mem_recv[4608];
+ int frag_len = 100;
+ int nfrags, i, off;
+ int p[2];
+
+ memrnd(mem_send, sizeof(mem_send));
+ ASSERT_GE(pipe(p), 0);
+
+ for (nfrags = 16; nfrags <= 44; nfrags++) {
+ for (i = 0, off = 0; i < nfrags; i++, off += frag_len) {
+ EXPECT_EQ(write(p[1], mem_send + off, frag_len), frag_len);
+ EXPECT_EQ(splice(p[0], NULL, self->fd, NULL, frag_len,
+ SPLICE_F_MORE), frag_len);
+ }
+
+ EXPECT_EQ(send(self->fd, mem_send + off, 1, MSG_MORE), 1);
+ off++;
+
+ EXPECT_EQ(write(p[1], mem_send + off, frag_len), frag_len);
+ EXPECT_EQ(splice(p[0], NULL, self->fd, NULL, frag_len,
+ SPLICE_F_MORE), frag_len);
+ off += frag_len;
+
+ EXPECT_EQ(send(self->fd, mem_send + off, 1, 0), 1);
+ off++;
+
+ EXPECT_EQ(recv(self->cfd, mem_recv, off, MSG_WAITALL), off);
+ EXPECT_EQ(memcmp(mem_send, mem_recv, off), 0);
+ }
+
+ close(p[0]);
+ close(p[1]);
+}
+
TEST_F(tls, splice_to_pipe)
{
int send_len = TLS_PAYLOAD_MAX_LEN;
--
2.43.0
next prev parent reply other threads:[~2026-08-04 5:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 5:28 [PATCH net v2 0/2] tls: fix plaintext sk_msg ring over-fill chanyoung
2026-08-04 5:28 ` [PATCH net v2 1/2] tls: don't leave a full plaintext sk_msg ring unpushed chanyoung
2026-08-04 5:28 ` chanyoung [this message]
2026-08-06 16:10 ` [PATCH net v2 0/2] tls: fix plaintext sk_msg ring over-fill 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=20260804052837.49015-3-ppoo1220@gmail.com \
--to=ppoo1220@gmail.com \
--cc=dhowells@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--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