Skip to content

Commit 464e232

Browse files
borkmanngregkh
authored andcommitted
sock: fix sg page frag coalescing in sk_alloc_sg
[ Upstream commit 144fe2b ] 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 <daniel@iogearbox.net> Acked-by: Dave Watson <davejwatson@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 50b464d commit 464e232

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎net/tls/tls_sw.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ static int alloc_sg(struct sock *sk, int len, struct scatterlist *sg,
135135
pfrag->offset += use;
136136

137137
sge = sg + num_elem - 1;
138-
if (num_elem > first_coalesce && sg_page(sg) == pfrag->page &&
139-
sg->offset + sg->length == orig_offset) {
140-
sg->length += use;
138+
139+
if (num_elem > first_coalesce && sg_page(sge) == pfrag->page &&
140+
sge->offset + sge->length == orig_offset) {
141+
sge->length += use;
141142
} else {
142143
sge++;
143144
sg_unmark_end(sge);

0 commit comments

Comments
 (0)