summaryrefslogtreecommitdiff
path: root/net/tls
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2018-07-23 22:37:54 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-28 07:55:42 +0200
commit464e2326a7f5cd39d82f96750bb56a9d302edf8d (patch)
treed8d84e12a59a1eaba3c45fc519965fc79240bee5 /net/tls
parent50b464d33964282fb09be7d6d8a6063475f63814 (diff)
sock: fix sg page frag coalescing in sk_alloc_sg
[ Upstream commit 144fe2bfd236dc814eae587aea7e2af03dbdd755 ] 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: 3c4d7559159b ("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>
Diffstat (limited to 'net/tls')
-rw-r--r--net/tls/tls_sw.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 8ee4e667a414..fb79caf56d0e 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -135,9 +135,10 @@ static int alloc_sg(struct sock *sk, int len, struct scatterlist *sg,
pfrag->offset += use;
sge = sg + num_elem - 1;
- if (num_elem > first_coalesce && sg_page(sg) == pfrag->page &&
- sg->offset + sg->length == orig_offset) {
- sg->length += use;
+
+ if (num_elem > first_coalesce && sg_page(sge) == pfrag->page &&
+ sge->offset + sge->length == orig_offset) {
+ sge->length += use;
} else {
sge++;
sg_unmark_end(sge);