Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Jiayuan Chen
Fri, 20 Nov 2026 22:57
[PATCH net v1] tls: fix ring wrap in sk_msg_memcopy_from_iter() after splice
Author: Jiayuan Chen
Date: Fri, 20 Nov 2026 22:57
Date: Fri, 20 Nov 2026 22:57
34 lines
9403 bytes
9403 bytes
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
Re: [PATCH net v1] tls: fix ring wrap in sk_msg_memcopy_from_iter() after splice
Author: netdev-bot+sinfo
Date: Fri, 20 Nov 2026 23:03
Date: Fri, 20 Nov 2026 23:03
19 lines
8642 bytes
8642 bytes
Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH net v1] tls: fix ring wrap in sk_msg_memcopy_from_iter() after splice
Author: Juan Agustin Niccolini
Date: Mon, 23 Nov 2026 06:30
Date: Mon, 23 Nov 2026 06:30
38 lines
12661 bytes
12661 bytes
On Sat, 21 Nov 2026 06:57:19 +0800, Jiayuan Chen wrote: > 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. I don't think this addresses the root cause. The copy path in tls_sw_sendmsg_locked() starts writing at whatever cursor the last producer left behind, and this is the second time the splice line has been fixed because of that: c5a595000e26 made it move sg.curr because the copy was writing into the spliced page, and that change is what introduced this bug. This patch does close the splice route on mainline but doesn't touch multiple producers that leave the scatterlist cursor in a bad state for the next copy: - tls_sw_do_sendpage() on 6.1, 5.15 and 5.10, where this patch does not apply. The bug is reachable there too, as a race rather than deterministically (won within a second in my tests). - the record split in tls_push_record() on 7.1 and older. The copy path always appends after the data already in the record, so it can set the cursor itself, in tls_clone_plaintext_msg(), before cloning: on the last element with copybreak at its length, or at sg.start when the record is empty, as sk_msg_reset_curr() does. That holds whether the clone grows the last element or adds a new one, covers every producer, would have made c5a595000e26 unnecessary, and applies unchanged to every stable branch. I'll send it as a separate patch that tags d829e9c4112b which caused the symptom that c5a595000e26 fixed but introduced this bug. Best, Agustin
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads