Last active
October 1, 2015 20:45
-
-
Save avagin/9d9c8af63a5d2eadea79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9adc21d0236d9ef28da9064299789092388aa7e9 Mon Sep 17 00:00:00 2001 | |
From: Andrey Vagin <avagin@openvz.org> | |
Date: Thu, 1 Oct 2015 23:28:07 +0300 | |
Subject: [PATCH] net/unix: fix logic about sk_peek_offset | |
Now send with MSG_PEEK can return data from multiple SKBs. | |
Unfortunately we take into account the peek offset for each skb, | |
that is wrong. We need to skip data only once. | |
In addition, the peek offset should be used only if MSG_PEEK is set. | |
Cc: Aaron Conole <aconole@bytheb.org> | |
Fixes: 9f389e35674f ("af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag") | |
Signed-off-by: Andrey Vagin <avagin@openvz.org> | |
--- | |
net/unix/af_unix.c | 10 ++++++---- | |
1 file changed, 6 insertions(+), 4 deletions(-) | |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c | |
index ef31b40..9e275ff 100644 | |
--- a/net/unix/af_unix.c | |
+++ b/net/unix/af_unix.c | |
@@ -2064,6 +2064,11 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state) | |
goto out; | |
} | |
+ if (flags & MSG_PEEK) | |
+ skip = sk_peek_offset(sk, flags); | |
+ else | |
+ skip = 0; | |
+ | |
do { | |
int chunk; | |
struct sk_buff *skb, *last; | |
@@ -2112,7 +2117,6 @@ unlock: | |
break; | |
} | |
- skip = sk_peek_offset(sk, flags); | |
while (skip >= unix_skb_len(skb)) { | |
skip -= unix_skb_len(skb); | |
last = skb; | |
@@ -2179,14 +2183,12 @@ unlock: | |
if (UNIXCB(skb).fp) | |
scm.fp = scm_fp_dup(UNIXCB(skb).fp); | |
- if (skip) { | |
- sk_peek_offset_fwd(sk, chunk); | |
- skip -= chunk; | |
- } | |
+ sk_peek_offset_fwd(sk, chunk); | |
if (UNIXCB(skb).fp) | |
break; | |
+ skip = 0; | |
last = skb; | |
last_len = skb->len; | |
unix_state_lock(sk); | |
-- | |
2.4.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment