vhost: initialize vq->nheads properly
Subsystems (5)
PATCH 1/1 vhost: initialize vq->nheads properly
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.
--- drivers/vhost/vhost.c | 1 + 1 file changed, 1 insertion(+)
drivers/vhost/vhost.c +1 -0
@@ -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);
Signature · 1 line
2.39.5
Quoted 5 lines · Jason Wang
Commit
7918bb2d19c9("vhost: basic in order support") introducesvq->nheadsto store the number of batched used buffers per used elem but it forgets to initialize thevq->nheadsto NULL invhost_dev_init()this will causekfree()that would try to free it without be allocated ifSET_OWNERis 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()
Quoted 5 lines
Reported-by JAEHOON KIM <[email protected]>Reported-by Breno Leitao <[email protected]>Fixes 7918bb2d19c9 ("vhost: basic in order support")Signed-off-by Jason Wang <[email protected]>
Thanks,
Dawid
Quoted 10 lines · Jason Wang
Commit
7918bb2d19c9("vhost: basic in order support") introducesvq->nheadsto store the number of batched used buffers per used elem but it forgets to initialize thevq->nheadsto NULL invhost_dev_init()this will causekfree()that would try to free it without be allocated ifSET_OWNERis not called.Reported-by JAEHOON KIM <[email protected]>Reported-by Breno Leitao <[email protected]>Fixes 7918bb2d19c9 ("vhost: basic in order support")Signed-off-by Jason Wang <[email protected]>
Quoted 6 lines · Jason Wang
Commit
7918bb2d19c9("vhost: basic in order support") introducesvq->nheadsto store the number of batched used buffers per used elem but it forgets to initialize thevq->nheadsto NULL invhost_dev_init()this will causekfree()that would try to free it without be allocated ifSET_OWNERis not called.
Quoted 7 lines
Reported-by JAEHOON KIM <[email protected]>Reported-by Breno Leitao <[email protected]>Fixes 7918bb2d19c9 ("vhost: basic in order support")Signed-off-by Jason Wang <[email protected]>---
drivers/vhost/vhost.c| 1 +1 file changed, 1 insertion(+)
Quoted 16 lines
drivers/vhost/vhost.c +1
-0@@ -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);Signature · 1 line
2.39.5
Quoted 20 lines · Jason Wang
Commit
7918bb2d19c9("vhost: basic in order support") introducesvq->nheadsto store the number of batched used buffers per used elem but it forgets to initialize thevq->nheadsto NULL invhost_dev_init()this will causekfree()that would try to free it without be allocated ifSET_OWNERis not called.Reported-by JAEHOON KIM <[email protected]>Reported-by Breno Leitao <[email protected]>Fixes 7918bb2d19c9 ("vhost: basic in order support")Signed-off-by Jason Wang <[email protected]>--- drivers/vhost/vhost.c | 1 + 1 file changed, 1 insertion(+)drivers/vhost/vhost.c +0
-0
drivers/vhost/vhost.c void vhost_dev_init(struct vhost_dev *dev, · line 621
Quoted 7 lines
drivers/vhost/vhost.c +1
-0@@ -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.
Hi Michael:
Quoted 11 lines · Jason Wang
Commit
7918bb2d19c9("vhost: basic in order support") introducesvq->nheadsto store the number of batched used buffers per used elem but it forgets to initialize thevq->nheadsto NULL invhost_dev_init()this will causekfree()that would try to free it without be allocated ifSET_OWNERis not called.Reported-by JAEHOON KIM <[email protected]>Reported-by Breno Leitao <[email protected]>Fixes 7918bb2d19c9 ("vhost: basic in order support")Signed-off-by Jason Wang <[email protected]>
I didn't see this in your pull request.
Thanks
Michael S. Tsirkin
maintainerQuoted 10 lines · Jason Wang
Hi Michael:
Quoted 7 lines · Jason Wang
Commit
7918bb2d19c9("vhost: basic in order support") introducesvq->nheadsto store the number of batched used buffers per used elem but it forgets to initialize thevq->nheadsto NULL invhost_dev_init()this will causekfree()that would try to free it without be allocated ifSET_OWNERis not called.
Quoted 8 lines
Quoted 4 lines
Reported-by JAEHOON KIM <[email protected]>Reported-by Breno Leitao <[email protected]>Fixes 7918bb2d19c9 ("vhost: basic in order support")Signed-off-by Jason Wang <[email protected]>I didn't see this in your pull request.
Thanks
in next now. Will be in the next pull, thanks!
Signature · 1 line
MST