Re: [PATCH net v1] tls: fix ring wrap in sk_msg_memcopy_from_iter() after splice
From: Juan Agustin Niccolini
Date: Mon Nov 23 2026 - 01:31:06 EST
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