Skip to content

Commit 144fe2b

Browse files
borkmanndavem330
authored andcommitted
sock: fix sg page frag coalescing in sk_alloc_sg
Current sg coalescing logic in sk_alloc_sg() (latter is used by tls and sockmap) is not quite correct in that we do fetch the previous sg entry, however the subsequent check whether the refilled page frag from the socket is still the same as from the last entry with prior offset and length matching the start of the current buffer is comparing always the first sg list entry instead of the prior one. Fixes: 3c4d755 ("tls: kernel TLS support") Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Dave Watson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a4f14b commit 144fe2b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/core/sock.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,9 +2277,9 @@ int sk_alloc_sg(struct sock *sk, int len, struct scatterlist *sg,
22772277
pfrag->offset += use;
22782278

22792279
sge = sg + sg_curr - 1;
2280-
if (sg_curr > first_coalesce && sg_page(sg) == pfrag->page &&
2281-
sg->offset + sg->length == orig_offset) {
2282-
sg->length += use;
2280+
if (sg_curr > first_coalesce && sg_page(sge) == pfrag->page &&
2281+
sge->offset + sge->length == orig_offset) {
2282+
sge->length += use;
22832283
} else {
22842284
sge = sg + sg_curr;
22852285
sg_unmark_end(sge);

0 commit comments

Comments
 (0)