netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] sock: fix sg page frag coalescing in sk_alloc_sg
@ 2018-07-23 20:37 Daniel Borkmann
  2018-07-24  4:29 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Borkmann @ 2018-07-23 20:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, davejwatson, borisp, john.fastabend, Daniel Borkmann

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>
---
 net/core/sock.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 9e8f655..bc2d7a3 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2277,9 +2277,9 @@ int sk_alloc_sg(struct sock *sk, int len, struct scatterlist *sg,
 		pfrag->offset += use;
 
 		sge = sg + sg_curr - 1;
-		if (sg_curr > first_coalesce && sg_page(sg) == pfrag->page &&
-		    sg->offset + sg->length == orig_offset) {
-			sg->length += use;
+		if (sg_curr > first_coalesce && sg_page(sge) == pfrag->page &&
+		    sge->offset + sge->length == orig_offset) {
+			sge->length += use;
 		} else {
 			sge = sg + sg_curr;
 			sg_unmark_end(sge);
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] sock: fix sg page frag coalescing in sk_alloc_sg
  2018-07-23 20:37 [PATCH net] sock: fix sg page frag coalescing in sk_alloc_sg Daniel Borkmann
@ 2018-07-24  4:29 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-24  4:29 UTC (permalink / raw)
  To: daniel; +Cc: netdev, davejwatson, borisp, john.fastabend

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Mon, 23 Jul 2018 22:37:54 +0200

> 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>

Applied and queued up for -stable, thanks Daniel.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-24  5:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-23 20:37 [PATCH net] sock: fix sg page frag coalescing in sk_alloc_sg Daniel Borkmann
2018-07-24  4:29 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).