Skip to contentSkip to conversation

skbuff: fix incorrect msg_zerocopy copy notifications

PATCH Applied Willem de Bruijn 4 participants 4 messages Jun 9, 2021 – Jun 10, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 skbuff: fix incorrect msg_zerocopy copy notifications

From: Willem de Bruijn <[email protected]>

msg_zerocopy signals if a send operation required copying with a flag in serr->ee.ee_code.

This field can be incorrect as of the below commit, as a result of both structs uarg and serr pointing into the same skb->cb[].

uarg->zerocopy must be read before skb->cb[] is reinitialized to hold serr. Similar to other fields len, hi and lo, use a local variable to temporarily hold the value.

This was not a problem before, when the value was passed as a function argument.

Fixes 75518851a2a0 ("skbuff: Push status and refcounts into sock_zerocopy_callback")
---
 net/core/skbuff.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/skbuff.c +3 -1
index 3ad22870298c..bbc3b4b62032 100644
@@ -1253,6 +1253,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg)
 	struct sock *sk = skb->sk;
 	struct sk_buff_head *q;
 	unsigned long flags;
+	bool is_zerocopy;
 	u32 lo, hi;
 	u16 len;
 
@@ -1267,6 +1268,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg)
 	len = uarg->len;
 	lo = uarg->id;
 	hi = uarg->id + len - 1;
+	is_zerocopy = uarg->zerocopy;
 
 	serr = SKB_EXT_ERR(skb);
 	memset(serr, 0, sizeof(*serr));
@@ -1274,7 +1276,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg)
 	serr->ee.ee_origin = SO_EE_ORIGIN_ZEROCOPY;
 	serr->ee.ee_data = hi;
 	serr->ee.ee_info = lo;
-	if (!uarg->zerocopy)
+	if (!is_zerocopy)
 		serr->ee.ee_code |= SO_EE_CODE_ZEROCOPY_COPIED;
 
 	q = &sk->sk_error_queue;
Signature · 1 line
2.32.0.rc1.229.g3e70b5a671-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

msg_zerocopy signals if a send operation required copying with a flag in serr->ee.ee_code.

This field can be incorrect as of the below commit, as a result of both structs uarg and serr pointing into the same skb->cb[].

uarg->zerocopy must be read before skb->cb[] is reinitialized to hold serr. Similar to other fields len, hi and lo, use a local variable to temporarily hold the value.

Quoted 6 lines

This was not a problem before, when the value was passed as a function argument.

Fixes 75518851a2a0 ("skbuff: Push status and refcounts into sock_zerocopy_callback")

Thank you for the fix!

Quoted 36 lines
---
 net/core/skbuff.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/skbuff.c +3 -2
index 3ad22870298c..bbc3b4b62032 100644
@@ -1253,6 +1253,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg)
        struct sock *sk = skb->sk;
        struct sk_buff_head *q;
        unsigned long flags;
+       bool is_zerocopy;
        u32 lo, hi;
        u16 len;
 
@@ -1267,6 +1268,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg)
        len = uarg->len;
        lo = uarg->id;
        hi = uarg->id + len - 1;
+       is_zerocopy = uarg->zerocopy;
 
        serr = SKB_EXT_ERR(skb);
        memset(serr, 0, sizeof(*serr));
@@ -1274,7 +1276,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg)
        serr->ee.ee_origin = SO_EE_ORIGIN_ZEROCOPY;
        serr->ee.ee_data = hi;
        serr->ee.ee_info = lo;
-       if (!uarg->zerocopy)
+       if (!is_zerocopy)
                serr->ee.ee_code |= SO_EE_CODE_ZEROCOPY_COPIED;
 
        q = &sk->sk_error_queue;
--

2.32.0.rc1.229.g3e70b5a671-goog

Reviewed-by on v1 1/1
#2 lore raw
In reply to Willem de Bruijn
Quoted 12 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

msg_zerocopy signals if a send operation required copying with a flag in serr->ee.ee_code.

This field can be incorrect as of the below commit, as a result of both structs uarg and serr pointing into the same skb->cb[].

uarg->zerocopy must be read before skb->cb[] is reinitialized to hold serr. Similar to other fields len, hi and lo, use a local variable to temporarily hold the value.

Quoted 7 lines

This was not a problem before, when the value was passed as a function argument.

Fixes 75518851a2a0 ("skbuff: Push status and refcounts into sock_zerocopy_callback")

---

#3 lore raw
In reply to Willem de Bruijn
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 9 lines · On Wed, 9 Jun 2021 18:41:57 -0400 you wrote:

From: Willem de Bruijn <[email protected]>

msg_zerocopy signals if a send operation required copying with a flag in serr->ee.ee_code.

This field can be incorrect as of the below commit, as a result of both structs uarg and serr pointing into the same skb->cb[].

[...]

Here is the summary with links:
- [net] skbuff: fix incorrect msg_zerocopy copy notifications

    https://git.kernel.org/netdev/net/c/3bdd5ee0ec8c

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html