Commit 464e2326 authored by Daniel Borkmann's avatar Daniel Borkmann Committed by Greg Kroah-Hartman

sock: fix sg page frag coalescing in sk_alloc_sg

[ Upstream commit 144fe2bf ]

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: 3c4d7559 ("tls: kernel TLS support")
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarDave Watson <davejwatson@fb.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 50b464d3
...@@ -135,9 +135,10 @@ static int alloc_sg(struct sock *sk, int len, struct scatterlist *sg, ...@@ -135,9 +135,10 @@ static int alloc_sg(struct sock *sk, int len, struct scatterlist *sg,
pfrag->offset += use; pfrag->offset += use;
sge = sg + num_elem - 1; sge = sg + num_elem - 1;
if (num_elem > first_coalesce && sg_page(sg) == pfrag->page &&
sg->offset + sg->length == orig_offset) { if (num_elem > first_coalesce && sg_page(sge) == pfrag->page &&
sg->length += use; sge->offset + sge->length == orig_offset) {
sge->length += use;
} else { } else {
sge++; sge++;
sg_unmark_end(sge); sg_unmark_end(sge);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment