From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: netdev@vger.kernel.org
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>,
Eddy Tsalolikhin <eddsterxyz@gmail.com>,
Kyle Zeng <kylebot@openai.com>,
John Fastabend <john.fastabend@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
Sabrina Dubroca <sd@queasysnail.net>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH net v1] tls: fix ring wrap in sk_msg_memcopy_from_iter() after splice
Date: Sat, 21 Nov 2026 06:57:19 +0800 [thread overview]
Message-ID: <20261120225720.89044-1-jiayuan.chen@linux.dev> (raw)
tls_sw_sendmsg_splice() forces sg.curr = sg.end after adding the
spliced page.
The following non-splice sk_msg_memcopy_from_iter() is a do-while
loop: it advances i with sk_msg_iter_var_next() and only then tests
i != sg.end, so starting from sg.curr == sg.end it wraps the ring.
Reported-by: Eddy Tsalolikhin <eddsterxyz@gmail.com>
Reported-by: Kyle Zeng <kylebot@openai.com>
Fixes: c5a595000e26 ("net: tls, update curr on splice as well")
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
net/tls/tls_sw.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 365c9485bb7c..d3a9b1c41de8 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -764,8 +764,10 @@ static int tls_sw_sendmsg_splice(struct sock *sk, struct msghdr *msg,
}
sk_msg_page_add(msg_pl, page, part, off);
- msg_pl->sg.copybreak = 0;
+ /* keep sg.curr on the last frag so a later copy won't wrap */
msg_pl->sg.curr = msg_pl->sg.end;
+ sk_msg_iter_var_prev(msg_pl->sg.curr);
+ msg_pl->sg.copybreak = sk_msg_elem(msg_pl, msg_pl->sg.curr)->length;
sk_mem_charge(sk, part);
*copied += part;
try_to_copy -= part;
--
2.43.0
next reply other threads:[~2026-11-20 22:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 22:57 Jiayuan Chen [this message]
2026-11-20 23:03 ` [PATCH net v1] tls: fix ring wrap in sk_msg_memcopy_from_iter() after splice netdev-bot+sinfo
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=20261120225720.89044-1-jiayuan.chen@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=davem@davemloft.net \
--cc=eddsterxyz@gmail.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=kylebot@openai.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
/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.