Skip to contentSkip to conversation

virtio_net: fix mergeable bufs error handling

PATCH In review Michael S. Tsirkin 3 participants 3 messages Mar 29, 2017 – Mar 30, 2017

Subsystems (4)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 virtio_net: fix mergeable bufs error handling

On xdp error we try to free head_skb without having initialized it, that's clearly bogus.

Fixes f600b6905015 ("virtio_net: Add XDP support")
Cc John Fastabend <[email protected]>
---
 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio_net.c +1 -1
index 11773d6..e0fb3707 100644
@@ -570,7 +570,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 	u16 num_buf;
 	struct page *page;
 	int offset;
-	struct sk_buff *head_skb, *curr_skb;
+	struct sk_buff *head_skb = NULL, *curr_skb;
 	struct bpf_prog *xdp_prog;
 	unsigned int truesize;
 
Signature · 1 line
MST
#1 lore raw
Quoted 15 lines · Michael S. Tsirkin

On xdp error we try to free head_skb without having initialized it, that's clearly bogus.

Fixes f600b6905015 ("virtio_net: Add XDP support")
Cc John Fastabend <[email protected]>
---
  drivers/net/virtio_net.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio_net.c +0 -0
index 11773d6..e0fb3707 100644

drivers/net/virtio_net.c static struct sk_buff *receive_mergeable(struct net_device *dev, · line 576

Quoted 8 lines
drivers/net/virtio_net.c +1 -1
@@ -570,7 +570,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
  	u16 num_buf;
  	struct page *page;
  	int offset;
-	struct sk_buff *head_skb, *curr_skb;
+	struct sk_buff *head_skb = NULL, *curr_skb;
  	struct bpf_prog *xdp_prog;
  	unsigned int truesize;
 

My tree (net.git HEAD is 8f1f7eeb22c16a197159cf7b35d1350695193ead) has:

    head_skb = NULL;

just after the above codes.

Thanks
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

maintainer
#2 lore raw
In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Wed, 29 Mar 2017 15:37:37 +0300

drivers/net/virtio_net.c static struct sk_buff *receive_mergeable(struct net_device *dev, · line 576

Quoted 9 lines
drivers/net/virtio_net.c +1 -1
@@ -570,7 +570,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 	u16 num_buf;
 	struct page *page;
 	int offset;
-	struct sk_buff *head_skb, *curr_skb;
+	struct sk_buff *head_skb = NULL, *curr_skb;
 	struct bpf_prog *xdp_prog;
 	unsigned int truesize;
 

Like Jason, I see the very next line is:

	head_skb = NULL;

so I don't think this is necessary.