Skip to contentSkip to conversation

net: fix rc7's __skb_datagram_iter()

PATCH Superseded Hugh Dickins 4 participants 8 messages Jul 8, 2024 – Jul 11, 2024

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

PATCH 1/1 net: fix rc7's __skb_datagram_iter()

X would not start in my old 32-bit partition (and the "n"-handling looks just as wrong on 64-bit, but for whatever reason did not show up there):
"n" must be accumulated over all pages before it's added to "offset" and compared with "copy", immediately after the skb_frag_foreach_page() loop.

Fixes d2d30a376d9c ("net: allow skb_datagram_iter to be called from any context")
---
 net/core/datagram.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/datagram.c +2 -1
index e9ba4c7b449d..ea69d01156e6 100644
@@ -420,6 +420,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 			struct page *p;
 			u8 *vaddr;
 
+			n = 0;
 			if (copy > len)
 				copy = len;
 
@@ -427,7 +428,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 					      skb_frag_off(frag) + offset - start,
 					      copy, p, p_off, p_len, copied) {
 				vaddr = kmap_local_page(p);
-				n = INDIRECT_CALL_1(cb, simple_copy_to_iter,
+				n += INDIRECT_CALL_1(cb, simple_copy_to_iter,
 					vaddr + p_off, p_len, data, to);
 				kunmap_local(vaddr);
 			}
Signature · 1 line
2.35.3
#1 lore raw
Quoted 4 lines · Hugh Dickins

X would not start in my old 32-bit partition (and the "n"-handling looks just as wrong on 64-bit, but for whatever reason did not show up there):
"n" must be accumulated over all pages before it's added to "offset" and compared with "copy", immediately after the skb_frag_foreach_page() loop.

That is indeed strange. I see the issue. It didn't happen in my local testing either.

Quoted 12 lines
Fixes d2d30a376d9c ("net: allow skb_datagram_iter to be called from any context")
---
  net/core/datagram.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/core/datagram.c +0 -0
index e9ba4c7b449d..ea69d01156e6 100644

net/core/datagram.c static int __skb_datagram_iter(const struct sk_buff *skb, int offset, · line 423

Quoted 4 lines
net/core/datagram.c +1 -0
@@ -420,6 +420,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
  			struct page *p;
  			u8 *vaddr;
 
+			n = 0;

I think its better to reset n right before the skb_frag_foreach_page() iteration.

Thanks Hugh for addressing this!

#2 lore raw

PATCH v2 1/1 net: fix rc7's __skb_datagram_iter()

X would not start in my old 32-bit partition (and the "n"-handling looks just as wrong on 64-bit, but for whatever reason did not show up there):
"n" must be accumulated over all pages before it's added to "offset" and compared with "copy", immediately after the skb_frag_foreach_page() loop.

Fixes d2d30a376d9c ("net: allow skb_datagram_iter to be called from any context")

---
v2: moved the "n = 0" down, per Sagi: no functional change.

 net/core/datagram.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/datagram.c +2 -1
index e9ba4c7b449d..e72dd78471a6 100644
@@ -423,11 +423,12 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 			if (copy > len)
 				copy = len;
 
+			n = 0;
 			skb_frag_foreach_page(frag,
 					      skb_frag_off(frag) + offset - start,
 					      copy, p, p_off, p_len, copied) {
 				vaddr = kmap_local_page(p);
-				n = INDIRECT_CALL_1(cb, simple_copy_to_iter,
+				n += INDIRECT_CALL_1(cb, simple_copy_to_iter,
 					vaddr + p_off, p_len, data, to);
 				kunmap_local(vaddr);
 			}
Signature · 1 line
2.35.3
Reviewed-by on v2 1/1
#3 lore raw
Quoted 7 lines · Hugh Dickins

X would not start in my old 32-bit partition (and the "n"-handling looks just as wrong on 64-bit, but for whatever reason did not show up there):
"n" must be accumulated over all pages before it's added to "offset" and compared with "copy", immediately after the skb_frag_foreach_page() loop.

Fixes d2d30a376d9c ("net: allow skb_datagram_iter to be called from any context")

Thanks Hugh,

#4 lore raw

PATCH v3 1/1 net: fix rc7's __skb_datagram_iter()

X would not start in my old 32-bit partition (and the "n"-handling looks just as wrong on 64-bit, but for whatever reason did not show up there):
"n" must be accumulated over all pages before it's added to "offset" and compared with "copy", immediately after the skb_frag_foreach_page() loop.

Fixes d2d30a376d9c ("net: allow skb_datagram_iter to be called from any context")

---
v3: added reviewed-by Sagi, try sending direct to Linus
v2: moved the "n = 0" down, per Sagi: no functional change.

 net/core/datagram.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/datagram.c +2 -1
index e9ba4c7b449d..e72dd78471a6 100644
@@ -423,11 +423,12 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 			if (copy > len)
 				copy = len;
 
+			n = 0;
 			skb_frag_foreach_page(frag,
 					      skb_frag_off(frag) + offset - start,
 					      copy, p, p_off, p_len, copied) {
 				vaddr = kmap_local_page(p);
-				n = INDIRECT_CALL_1(cb, simple_copy_to_iter,
+				n += INDIRECT_CALL_1(cb, simple_copy_to_iter,
 					vaddr + p_off, p_len, data, to);
 				kunmap_local(vaddr);
 			}
Signature · 1 line
2.35.3
maintainer
#5 lore raw
Quoted 10 lines · Hugh Dickins

X would not start in my old 32-bit partition (and the "n"-handling looks just as wrong on 64-bit, but for whatever reason did not show up there):
"n" must be accumulated over all pages before it's added to "offset" and compared with "copy", immediately after the skb_frag_foreach_page() loop.

Fixes d2d30a376d9c ("net: allow skb_datagram_iter to be called from any context")

---
v3: added reviewed-by Sagi, try sending direct to Linus

V2 is already applied to the 'net' tree and will be included in our next 'net' PR, coming tomorrow.

It looks like the netdev bot decided it needed an holiday (or was fooled by the threaded submission for v2), so no notification landed on the ML.

@Hugh: next time please check the current tree status or patchwork before submitting a new revision. And please avoid submitting the new version in reply to a previous one, it makes things difficult for our CI.

Thanks,

Paolo

#6 lore raw
Quoted 15 lines · Paolo Abeni
Quoted 10 lines · Hugh Dickins

X would not start in my old 32-bit partition (and the "n"-handling looks just as wrong on 64-bit, but for whatever reason did not show up there):
"n" must be accumulated over all pages before it's added to "offset" and compared with "copy", immediately after the skb_frag_foreach_page() loop.

Fixes d2d30a376d9c ("net: allow skb_datagram_iter to be called from any context")

---
v3: added reviewed-by Sagi, try sending direct to Linus

V2 is already applied to the 'net' tree and will be included in our next 'net' PR, coming tomorrow.

Quoted 8 lines

It looks like the netdev bot decided it needed an holiday (or was fooled by the threaded submission for v2), so no notification landed on the ML.

@Hugh: next time please check the current tree status or patchwork before submitting a new revision. And please avoid submitting the new version in reply to a previous one, it makes things difficult for our CI.

Ah, great, thanks. Yes, I'd heard only silence (and was worried because, although I only saw the effect of this on 32-bit, suspect it could cause lots of obscure trouble more generally).

Hugh

#7 lore raw
In reply to Hugh Dickins
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 10 Jul 2024 08:36:54 -0700 (PDT) you wrote:

X would not start in my old 32-bit partition (and the "n"-handling looks just as wrong on 64-bit, but for whatever reason did not show up there):
"n" must be accumulated over all pages before it's added to "offset" and compared with "copy", immediately after the skb_frag_foreach_page() loop.

Fixes d2d30a376d9c ("net: allow skb_datagram_iter to be called from any context")

[...]

Here is the summary with links:
- [v3] net: fix rc7's __skb_datagram_iter()

    https://git.kernel.org/netdev/net-next/c/f153831097b4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html