* [PATCH] vhost: initialize vq->nheads properly
@ 2025-07-29 7:39 Jason Wang
2025-07-29 8:09 ` Dawid Osuchowski
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Jason Wang @ 2025-07-29 7:39 UTC (permalink / raw)
To: mst, jasowang, eperezma
Cc: kvm, virtualization, netdev, linux-kernel, sgarzare, will,
JAEHOON KIM, Breno Leitao
Commit 7918bb2d19c9 ("vhost: basic in order support") introduces
vq->nheads to store the number of batched used buffers per used elem
but it forgets to initialize the vq->nheads to NULL in
vhost_dev_init() this will cause kfree() that would try to free it
without be allocated if SET_OWNER is not called.
Reported-by: JAEHOON KIM <jhkim@linux.ibm.com>
Reported-by: Breno Leitao <leitao@debian.org>
Fixes: 7918bb2d19c9 ("vhost: basic in order support")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/vhost/vhost.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index a4873d116df1..b4dfe38c7008 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -615,6 +615,7 @@ void vhost_dev_init(struct vhost_dev *dev,
vq->log = NULL;
vq->indirect = NULL;
vq->heads = NULL;
+ vq->nheads = NULL;
vq->dev = dev;
mutex_init(&vq->mutex);
vhost_vq_reset(dev, vq);
--
2.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] vhost: initialize vq->nheads properly
2025-07-29 7:39 [PATCH] vhost: initialize vq->nheads properly Jason Wang
@ 2025-07-29 8:09 ` Dawid Osuchowski
2025-07-29 9:11 ` Breno Leitao
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Dawid Osuchowski @ 2025-07-29 8:09 UTC (permalink / raw)
To: Jason Wang, mst, eperezma
Cc: kvm, virtualization, netdev, linux-kernel, sgarzare, will,
JAEHOON KIM, Breno Leitao
On 2025-07-29 9:39 AM, Jason Wang wrote:
> Commit 7918bb2d19c9 ("vhost: basic in order support") introduces
> vq->nheads to store the number of batched used buffers per used elem
> but it forgets to initialize the vq->nheads to NULL in
> vhost_dev_init() this will cause kfree() that would try to free it
> without be allocated if SET_OWNER is not called.
nit: as someone who is not familiar with vhost code, it took me a while
to figure out you meant VHOST_SET_OWNER and the corresponding
vhost_dev_set_owner()
>
> Reported-by: JAEHOON KIM <jhkim@linux.ibm.com>
> Reported-by: Breno Leitao <leitao@debian.org>
> Fixes: 7918bb2d19c9 ("vhost: basic in order support")
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
Thanks,
Dawid
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] vhost: initialize vq->nheads properly
2025-07-29 7:39 [PATCH] vhost: initialize vq->nheads properly Jason Wang
2025-07-29 8:09 ` Dawid Osuchowski
@ 2025-07-29 9:11 ` Breno Leitao
2025-07-29 9:56 ` Stefano Garzarella
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Breno Leitao @ 2025-07-29 9:11 UTC (permalink / raw)
To: Jason Wang
Cc: mst, eperezma, kvm, virtualization, netdev, linux-kernel,
sgarzare, will, JAEHOON KIM
On Tue, Jul 29, 2025 at 03:39:16PM +0800, Jason Wang wrote:
> Commit 7918bb2d19c9 ("vhost: basic in order support") introduces
> vq->nheads to store the number of batched used buffers per used elem
> but it forgets to initialize the vq->nheads to NULL in
> vhost_dev_init() this will cause kfree() that would try to free it
> without be allocated if SET_OWNER is not called.
>
> Reported-by: JAEHOON KIM <jhkim@linux.ibm.com>
> Reported-by: Breno Leitao <leitao@debian.org>
> Fixes: 7918bb2d19c9 ("vhost: basic in order support")
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Tested-by: Breno Leitao <leitao@debian.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] vhost: initialize vq->nheads properly
2025-07-29 7:39 [PATCH] vhost: initialize vq->nheads properly Jason Wang
2025-07-29 8:09 ` Dawid Osuchowski
2025-07-29 9:11 ` Breno Leitao
@ 2025-07-29 9:56 ` Stefano Garzarella
2025-07-29 13:51 ` JAEHOON KIM
2025-08-04 9:05 ` Jason Wang
4 siblings, 0 replies; 7+ messages in thread
From: Stefano Garzarella @ 2025-07-29 9:56 UTC (permalink / raw)
To: Jason Wang
Cc: mst, eperezma, kvm, virtualization, netdev, linux-kernel, will,
JAEHOON KIM, Breno Leitao
On Tue, Jul 29, 2025 at 03:39:16PM +0800, Jason Wang wrote:
>Commit 7918bb2d19c9 ("vhost: basic in order support") introduces
>vq->nheads to store the number of batched used buffers per used elem
>but it forgets to initialize the vq->nheads to NULL in
>vhost_dev_init() this will cause kfree() that would try to free it
>without be allocated if SET_OWNER is not called.
>
>Reported-by: JAEHOON KIM <jhkim@linux.ibm.com>
>Reported-by: Breno Leitao <leitao@debian.org>
>Fixes: 7918bb2d19c9 ("vhost: basic in order support")
>Signed-off-by: Jason Wang <jasowang@redhat.com>
>---
> drivers/vhost/vhost.c | 1 +
> 1 file changed, 1 insertion(+)
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
>
>diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
>index a4873d116df1..b4dfe38c7008 100644
>--- a/drivers/vhost/vhost.c
>+++ b/drivers/vhost/vhost.c
>@@ -615,6 +615,7 @@ void vhost_dev_init(struct vhost_dev *dev,
> vq->log = NULL;
> vq->indirect = NULL;
> vq->heads = NULL;
>+ vq->nheads = NULL;
> vq->dev = dev;
> mutex_init(&vq->mutex);
> vhost_vq_reset(dev, vq);
>--
>2.39.5
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] vhost: initialize vq->nheads properly
2025-07-29 7:39 [PATCH] vhost: initialize vq->nheads properly Jason Wang
` (2 preceding siblings ...)
2025-07-29 9:56 ` Stefano Garzarella
@ 2025-07-29 13:51 ` JAEHOON KIM
2025-08-04 9:05 ` Jason Wang
4 siblings, 0 replies; 7+ messages in thread
From: JAEHOON KIM @ 2025-07-29 13:51 UTC (permalink / raw)
To: Jason Wang, mst, eperezma
Cc: kvm, virtualization, netdev, linux-kernel, sgarzare, will,
Breno Leitao
On 7/29/2025 2:39 AM, Jason Wang wrote:
> Commit 7918bb2d19c9 ("vhost: basic in order support") introduces
> vq->nheads to store the number of batched used buffers per used elem
> but it forgets to initialize the vq->nheads to NULL in
> vhost_dev_init() this will cause kfree() that would try to free it
> without be allocated if SET_OWNER is not called.
>
> Reported-by: JAEHOON KIM <jhkim@linux.ibm.com>
> Reported-by: Breno Leitao <leitao@debian.org>
> Fixes: 7918bb2d19c9 ("vhost: basic in order support")
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> drivers/vhost/vhost.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index a4873d116df1..b4dfe38c7008 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -615,6 +615,7 @@ void vhost_dev_init(struct vhost_dev *dev,
> vq->log = NULL;
> vq->indirect = NULL;
> vq->heads = NULL;
> + vq->nheads = NULL;
> vq->dev = dev;
> mutex_init(&vq->mutex);
> vhost_vq_reset(dev, vq);
>
checked and confirmed no crash occurs.
Thanks for the fast update.
Tested-by: Jaehoon Kim <jhkim@linux.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] vhost: initialize vq->nheads properly
2025-07-29 7:39 [PATCH] vhost: initialize vq->nheads properly Jason Wang
` (3 preceding siblings ...)
2025-07-29 13:51 ` JAEHOON KIM
@ 2025-08-04 9:05 ` Jason Wang
2025-08-04 15:57 ` Michael S. Tsirkin
4 siblings, 1 reply; 7+ messages in thread
From: Jason Wang @ 2025-08-04 9:05 UTC (permalink / raw)
To: mst, jasowang, eperezma
Cc: kvm, virtualization, netdev, linux-kernel, sgarzare, will,
JAEHOON KIM, Breno Leitao
Hi Michael:
On Tue, Jul 29, 2025 at 3:39 PM Jason Wang <jasowang@redhat.com> wrote:
>
> Commit 7918bb2d19c9 ("vhost: basic in order support") introduces
> vq->nheads to store the number of batched used buffers per used elem
> but it forgets to initialize the vq->nheads to NULL in
> vhost_dev_init() this will cause kfree() that would try to free it
> without be allocated if SET_OWNER is not called.
>
> Reported-by: JAEHOON KIM <jhkim@linux.ibm.com>
> Reported-by: Breno Leitao <leitao@debian.org>
> Fixes: 7918bb2d19c9 ("vhost: basic in order support")
> Signed-off-by: Jason Wang <jasowang@redhat.com>
I didn't see this in your pull request.
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] vhost: initialize vq->nheads properly
2025-08-04 9:05 ` Jason Wang
@ 2025-08-04 15:57 ` Michael S. Tsirkin
0 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2025-08-04 15:57 UTC (permalink / raw)
To: Jason Wang
Cc: eperezma, kvm, virtualization, netdev, linux-kernel, sgarzare,
will, JAEHOON KIM, Breno Leitao
On Mon, Aug 04, 2025 at 05:05:57PM +0800, Jason Wang wrote:
> Hi Michael:
>
> On Tue, Jul 29, 2025 at 3:39 PM Jason Wang <jasowang@redhat.com> wrote:
> >
> > Commit 7918bb2d19c9 ("vhost: basic in order support") introduces
> > vq->nheads to store the number of batched used buffers per used elem
> > but it forgets to initialize the vq->nheads to NULL in
> > vhost_dev_init() this will cause kfree() that would try to free it
> > without be allocated if SET_OWNER is not called.
> >
> > Reported-by: JAEHOON KIM <jhkim@linux.ibm.com>
> > Reported-by: Breno Leitao <leitao@debian.org>
> > Fixes: 7918bb2d19c9 ("vhost: basic in order support")
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
>
> I didn't see this in your pull request.
>
> Thanks
in next now. Will be in the next pull, thanks!
--
MST
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-04 15:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29 7:39 [PATCH] vhost: initialize vq->nheads properly Jason Wang
2025-07-29 8:09 ` Dawid Osuchowski
2025-07-29 9:11 ` Breno Leitao
2025-07-29 9:56 ` Stefano Garzarella
2025-07-29 13:51 ` JAEHOON KIM
2025-08-04 9:05 ` Jason Wang
2025-08-04 15:57 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).