Skip to contentSkip to conversation

virtio-net: fix pages leaking when building skb in big mode

PATCH Applied Jason Wang 3 participants 3 messages Sep 17, 2021 – Sep 19, 2021

Subsystems (4)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 virtio-net: fix pages leaking when building skb in big mode

We try to use build_skb() if we had sufficient tailroom. But we forget to release the unused pages chained via private in big mode which will leak pages. Fixing this by release the pages after building the skb in big mode.

Cc Xuan Zhuo <[email protected]>
Fixes fb32856b16ad ("virtio-net: page_to_skb() use build_skb when there's sufficient tailroom")
---
 drivers/net/virtio_net.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/virtio_net.c +4 -0
index 271d38c1d9f8..79bd2585ec6b 100644
@@ -423,6 +423,10 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
 
 		skb_reserve(skb, p - buf);
 		skb_put(skb, len);
+
+		page = (struct page *)page->private;
+		if (page)
+			give_pages(rq, page);
 		goto ok;
 	}
 
Signature · 6 lines
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jason Wang

We try to use build_skb() if we had sufficient tailroom. But we forget to release the unused pages chained via private in big mode which will leak pages. Fixing this by release the pages after building the skb in big mode.

Cc Xuan Zhuo <[email protected]>
Fixes fb32856b16ad ("virtio-net: page_to_skb() use build_skb when there's sufficient tailroom")

LGTM

Thanks.

Quoted 22 lines
---
 drivers/net/virtio_net.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/virtio_net.c +4 -1
index 271d38c1d9f8..79bd2585ec6b 100644
@@ -423,6 +423,10 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
 
 		skb_reserve(skb, p - buf);
 		skb_put(skb, len);
+
+		page = (struct page *)page->private;
+		if (page)
+			give_pages(rq, page);
 		goto ok;
 	}
 
--

2.25.1

#2 lore raw
In reply to Jason Wang
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

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

Quoted 10 lines · On Fri, 17 Sep 2021 16:34:06 +0800 you wrote:

We try to use build_skb() if we had sufficient tailroom. But we forget to release the unused pages chained via private in big mode which will leak pages. Fixing this by release the pages after building the skb in big mode.

Cc Xuan Zhuo <[email protected]>
Fixes fb32856b16ad ("virtio-net: page_to_skb() use build_skb when there's sufficient tailroom")

[...]

Here is the summary with links:
- [net] virtio-net: fix pages leaking when building skb in big mode

    https://git.kernel.org/netdev/net/c/afd92d82c9d7

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