[v1] vhost: set zmbufs to NULL when freed

Message ID 20200715155848.9501-1-patrick.fu@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Maxime Coquelin
Headers
Series [v1] vhost: set zmbufs to NULL when freed |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Patrick Fu July 15, 2020, 3:58 p.m. UTC
  From: Patrick Fu <patrick.fu@intel.com>

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")

Signed-off-by: Patrick Fu <patrick.fu@intel.com>
---
 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Xiao, QimaiX July 16, 2020, 8:23 a.m. UTC | #1
Tested-by: Xiao Qimai <qimaix.xiao@intel.com>

Regards,
Xiao Qimai

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of patrick.fu@intel.com
> Sent: Wednesday, July 15, 2020 11:59 PM
> To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> <chenbo.xia@intel.com>
> Cc: Wang, Yinan <yinan.wang@intel.com>; Fu, Patrick <patrick.fu@intel.com>
> Subject: [dpdk-dev] [PATCH v1] vhost: set zmbufs to NULL when freed
> 
> From: Patrick Fu <patrick.fu@intel.com>
> 
> 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")
> 
> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> ---
>  lib/librte_vhost/vhost_user.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index df0db8a07..9ddeae362 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
>  	drain_zmbuf_list(vq);
> 
>  	rte_free(vq->zmbufs);
> +	vq->zmbufs = NULL;
>  }
> 
>  /*
> --
> 2.17.1
  
Chenbo Xia July 17, 2020, 3:19 a.m. UTC | #2
> -----Original Message-----
> From: Fu, Patrick <patrick.fu@intel.com>
> Sent: Wednesday, July 15, 2020 11:59 PM
> To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> <chenbo.xia@intel.com>
> Cc: Wang, Yinan <yinan.wang@intel.com>; Fu, Patrick <patrick.fu@intel.com>
> Subject: [PATCH v1] vhost: set zmbufs to NULL when freed
> 
> From: Patrick Fu <patrick.fu@intel.com>
> 
> 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")
> 
> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> ---
>  lib/librte_vhost/vhost_user.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index
> df0db8a07..9ddeae362 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -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: Chenbo Xia <chenbo.xia@intel.com>
  
Ferruh Yigit July 17, 2020, 12:35 p.m. UTC | #3
On 7/17/2020 4:19 AM, Xia, Chenbo wrote:
> 
>> -----Original Message-----
>> From: Fu, Patrick <patrick.fu@intel.com>
>> Sent: Wednesday, July 15, 2020 11:59 PM
>> To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
>> <chenbo.xia@intel.com>
>> Cc: Wang, Yinan <yinan.wang@intel.com>; Fu, Patrick <patrick.fu@intel.com>
>> Subject: [PATCH v1] vhost: set zmbufs to NULL when freed
>>
>> From: Patrick Fu <patrick.fu@intel.com>
>>
>> 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")
>>
>> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
>> ---
>>  lib/librte_vhost/vhost_user.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index
>> df0db8a07..9ddeae362 100644
>> --- a/lib/librte_vhost/vhost_user.c
>> +++ b/lib/librte_vhost/vhost_user.c
>> @@ -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: Chenbo Xia <chenbo.xia@intel.com>
> 

Applied to dpdk-next-net/master, thanks.
  
Maxime Coquelin July 20, 2020, 3:51 p.m. UTC | #4
Do you agree with below title?
vhost: fix double-free with zero-copy

Thanks,
Maxime

On 7/15/20 5:58 PM, patrick.fu@intel.com wrote:
> From: Patrick Fu <patrick.fu@intel.com>
> 
> 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")
> 
> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> ---
>  lib/librte_vhost/vhost_user.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index df0db8a07..9ddeae362 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
>  	drain_zmbuf_list(vq);
>  
>  	rte_free(vq->zmbufs);
> +	vq->zmbufs = NULL;
>  }
>  
>  /*
>
  
Ferruh Yigit July 20, 2020, 4:49 p.m. UTC | #5
On 7/20/2020 4:51 PM, Maxime Coquelin wrote:
> Do you agree with below title?
> vhost: fix double-free with zero-copy

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

> 
> Thanks,
> Maxime
> 
> On 7/15/20 5:58 PM, patrick.fu@intel.com wrote:
>> From: Patrick Fu <patrick.fu@intel.com>
>>
>> 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")
>>
>> Signed-off-by: Patrick Fu <patrick.fu@intel.com>

<...>
  
Patrick Fu July 21, 2020, 3:18 a.m. UTC | #6
V2 patch sent with revised title

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Monday, July 20, 2020 11:52 PM
> To: Fu, Patrick <patrick.fu@intel.com>; dev@dpdk.org; Xia, Chenbo
> <chenbo.xia@intel.com>
> Cc: Wang, Yinan <yinan.wang@intel.com>
> 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
> 
> On 7/15/20 5:58 PM, patrick.fu@intel.com wrote:
> > From: Patrick Fu <patrick.fu@intel.com>
> >
> > 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")
> >
> > Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> > ---
> >  lib/librte_vhost/vhost_user.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/librte_vhost/vhost_user.c
> > b/lib/librte_vhost/vhost_user.c index df0db8a07..9ddeae362 100644
> > --- a/lib/librte_vhost/vhost_user.c
> > +++ b/lib/librte_vhost/vhost_user.c
> > @@ -1934,6 +1934,7 @@ free_zmbufs(struct vhost_virtqueue *vq)
> >  	drain_zmbuf_list(vq);
> >
> >  	rte_free(vq->zmbufs);
> > +	vq->zmbufs = NULL;
> >  }
> >
> >  /*
> >
  

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index df0db8a07..9ddeae362 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1934,6 +1934,7 @@  free_zmbufs(struct vhost_virtqueue *vq)
 	drain_zmbuf_list(vq);
 
 	rte_free(vq->zmbufs);
+	vq->zmbufs = NULL;
 }
 
 /*