Skip to contentSkip to conversation

macvtap: fix use after free for skb_array during release

PATCH Applied Jason Wang 2 participants 2 messages Aug 11, 2016

Subsystems (2)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 macvtap: fix use after free for skb_array during release

We've clean skb_array in macvtap_put_queue() but still try to pop from it during macvtap_sock_destruct(). Fix this use after free by moving the skb array cleanup to macvtap_sock_destruct() instead.

Fixes 362899b8725b ("macvtap: switch to use skb array")
---
 drivers/net/macvtap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/macvtap.c +1 -4
index a38c0da..070e329 100644
@@ -275,7 +275,6 @@ static void macvtap_put_queue(struct macvtap_queue *q)
 	rtnl_unlock();
 
 	synchronize_rcu();
-	skb_array_cleanup(&q->skb_array);
 	sock_put(&q->sk);
 }
 
@@ -533,10 +532,8 @@ static void macvtap_sock_write_space(struct sock *sk)
 static void macvtap_sock_destruct(struct sock *sk)
 {
 	struct macvtap_queue *q = container_of(sk, struct macvtap_queue, sk);
-	struct sk_buff *skb;
 
-	while ((skb = skb_array_consume(&q->skb_array)) != NULL)
-		kfree_skb(skb);
+	skb_array_cleanup(&q->skb_array);
 }
 
 static int macvtap_open(struct inode *inode, struct file *file)
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

From: Jason Wang <[email protected]>
Date: Thu, 11 Aug 2016 18:15:56 +0800

Quoted 8 lines

We've clean skb_array in macvtap_put_queue() but still try to pop from it during macvtap_sock_destruct(). Fix this use after free by moving the skb array cleanup to macvtap_sock_destruct() instead.

Fixes 362899b8725b ("macvtap: switch to use skb array")

Applied, thanks for fixing this so quickly Jason.