Skip to contentSkip to conversation

vhost: set zmbufs to NULL when freed

PATCH Applied [email protected] 5 participants 10 messages Jul 15, 2020 – Jul 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: set zmbufs to NULL when freed

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")
---
 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_user.c +1 -0
index df0db8a07..9ddeae362 100644
@@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
 /*
Signature · 1 line
2.17.1
Tested-by on v1 1/1
#1 lore raw

Regards,
Xiao Qimai

Quoted 34 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of [email protected]
Sent: Wednesday, July 15, 2020 11:59 PM
To: [email protected]; [email protected]; Xia, Chenbo <[email protected]>
Cc: Wang, Yinan <[email protected]>; Fu, Patrick <[email protected]>
Subject: [dpdk-dev] [PATCH v1] vhost: set zmbufs to NULL when freed

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")
---
 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_user.c +1 -1
index df0db8a07..9ddeae362 100644
@@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
 /*
--

2.17.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 34 lines

-----Original Message-----
From: Fu, Patrick <[email protected]>
Sent: Wednesday, July 15, 2020 11:59 PM
To: [email protected]; [email protected]; Xia, Chenbo <[email protected]>
Cc: Wang, Yinan <[email protected]>; Fu, Patrick <[email protected]>
Subject: [PATCH v1] vhost: set zmbufs to NULL when freed

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")
---
 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_user.c index renamed from lib/librte_vhost/vhost_user.c +0 -0

df0db8a07..9ddeae362 100644

lib/librte_vhost/vhost_user.c +1 -1
@@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
 /*
--
Quoted 1 line

2.17.1

Applied
#3 lore raw
Quoted 32 lines · Chenbo
Quoted 32 lines

-----Original Message-----
From: Fu, Patrick <[email protected]>
Sent: Wednesday, July 15, 2020 11:59 PM
To: [email protected]; [email protected]; Xia, Chenbo <[email protected]>
Cc: Wang, Yinan <[email protected]>; Fu, Patrick <[email protected]>
Subject: [PATCH v1] vhost: set zmbufs to NULL when freed

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")
---
 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_user.c index renamed from lib/librte_vhost/vhost_user.c +0 -0

df0db8a07..9ddeae362 100644

lib/librte_vhost/vhost_user.c +1 -0
@@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
Quoted 6 lines
Quoted 3 lines
lib/librte_vhost/vhost_user.c +0 -1
 /*
--

2.17.1

Applied to dpdk-next-net/master, thanks.

#4 lore raw
In reply to [email protected]

Do you agree with below title?
vhost: fix double-free with zero-copy

Thanks,
Maxime

Quoted 25 lines · On 7/15/20 5:58 PM, [email protected] wrote:

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")
---
 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_user.c +1 -0
index df0db8a07..9ddeae362 100644
@@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
 /*
#5 lore raw
Quoted 2 lines · Maxime Coquelin

Do you agree with below title?
vhost: fix double-free with zero-copy

Existing commit dropped from next-net and patchwork status updated.

Quoted 13 lines

Thanks,
Maxime

Quoted 8 lines · On 7/15/20 5:58 PM, [email protected] wrote:

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")

<...>

#6 lore raw
In reply to Maxime Coquelin

V2 patch sent with revised title

Quoted 40 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Monday, July 20, 2020 11:52 PM
To: Fu, Patrick <[email protected]>; [email protected]; Xia, Chenbo <[email protected]>
Cc: Wang, Yinan <[email protected]>
Subject: Re: [PATCH v1] vhost: set zmbufs to NULL when freed

Do you agree with below title?
vhost: fix double-free with zero-copy

Thanks,
Maxime

Quoted 25 lines · On 7/15/20 5:58 PM, [email protected] wrote:

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")
---
 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/lib/librte_vhost/vhost_user.c index df0db8a07..9ddeae362 100644

lib/librte_vhost/vhost_user.c +1 -0
@@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
 /*
#7 lore raw

PATCH v2 1/1 vhost: fix double-free with zero-copy

In reply to [email protected]

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")

---
v2:
- revise commit message title

 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_user.c +1 -0
index df0db8a07..9ddeae362 100644
@@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
 /*
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#8 lore raw

Re: [dpdk-dev] [PATCH v2] vhost: fix double-free with zero-copy

Quoted 21 lines · On 7/21/20 2:10 PM, [email protected] wrote:

From: Patrick Fu <[email protected]>

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")

---
v2:
- revise commit message title

 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_vhost/vhost_user.c +0 -0
index df0db8a07..9ddeae362 100644

lib/librte_vhost/vhost_user.c free_zmbufs(struct vhost_virtqueue *vq) · line 1940

Quoted 7 lines
lib/librte_vhost/vhost_user.c +1 -0
@@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
 /*

Thanks,
Maxime

Applied
#9 lore raw

Re: [dpdk-dev] [PATCH v2] vhost: fix double-free with zero-copy

Quoted 5 lines · Maxime Coquelin
Quoted 2 lines · On 7/21/20 2:10 PM, [email protected] wrote:

From: Patrick Fu <[email protected]>

Quoted 9 lines
Quoted 6 lines

zmbufs should be set to NULL when getting freed to avoid double free on the same buffer pointer

Fixes b0a985d1f340 ("vhost: add dequeue zero copy")

Applied to dpdk-next-net/master, thanks.