* [PATCH v2] vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation
@ 2021-02-23 10:00 Gautam Dawar
2021-02-23 10:13 ` Jason Wang
2021-02-23 12:12 ` Michael S. Tsirkin
0 siblings, 2 replies; 4+ messages in thread
From: Gautam Dawar @ 2021-02-23 10:00 UTC (permalink / raw)
To: virtualization, Jason Wang, mst, gdawar, martinh, hanand
[-- Attachment #1.1: Type: text/plain, Size: 1626 bytes --]
When qemu with vhost-vdpa netdevice is run for the first time, it works
well.
But after the VM is powered off, the next qemu run causes kernel panic due
to a
NULL pointer dereference in irq_bypass_register_producer().
When the VM is powered off, vhost_vdpa_clean_irq() misses on calling
irq_bypass_unregister_producer() for irq 0 because of the existing check.
This leaves stale producer nodes, which are reset in
vhost_vring_call_reset()
when vhost_dev_init() is invoked during the second qemu run.
As the node member of struct irq_bypass_producer is also initialized
to zero, traversal on the producers list causes crash due to NULL pointer
dereference.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211711
Signed-off-by: Gautam Dawar <gdawar@xilinx.com>
-----
changelog:
v1->v2:
- Addressed Jason's comment to remove the irq check and use
vhost_vdpa_unsetup_vq_irq() to avoid local variable vq
-----
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 62a9bb0efc55..e00573b87aba 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -844,14 +844,10 @@ static int vhost_vdpa_open(struct inode *inode,
struct file *filep)
static void vhost_vdpa_clean_irq(struct vhost_vdpa *v)
{
- struct vhost_virtqueue *vq;
int i;
- for (i = 0; i < v->nvqs; i++) {
- vq = &v->vqs[i];
- if (vq->call_ctx.producer.irq)
-
irq_bypass_unregister_producer(&vq->call_ctx.producer);
- }
+ for (i = 0; i < v->nvqs; i++)
+ vhost_vdpa_unsetup_vq_irq(v, i);
}
static int vhost_vdpa_release(struct inode *inode, struct file *filep)
[-- Attachment #1.2: Type: text/html, Size: 2050 bytes --]
[-- Attachment #2: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation
2021-02-23 10:00 [PATCH v2] vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation Gautam Dawar
@ 2021-02-23 10:13 ` Jason Wang
2021-02-23 12:12 ` Michael S. Tsirkin
1 sibling, 0 replies; 4+ messages in thread
From: Jason Wang @ 2021-02-23 10:13 UTC (permalink / raw)
To: Gautam Dawar, virtualization, mst, gdawar, martinh, hanand
[-- Attachment #1.1: Type: text/plain, Size: 1940 bytes --]
On 2021/2/23 6:00 下午, Gautam Dawar wrote:
> When qemu with vhost-vdpa netdevice is run for the first time, it
> works well.
> But after the VM is powered off, the next qemu run causes kernel panic
> due to a
> NULL pointer dereference in irq_bypass_register_producer().
>
> When the VM is powered off, vhost_vdpa_clean_irq() misses on calling
> irq_bypass_unregister_producer() for irq 0 because of the existing check.
>
> This leaves stale producer nodes, which are reset in
> vhost_vring_call_reset()
> when vhost_dev_init() is invoked during the second qemu run.
>
> As the node member of struct irq_bypass_producer is also initialized
> to zero, traversal on the producers list causes crash due to NULL pointer
> dereference.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211711
> <https://bugzilla.kernel.org/show_bug.cgi?id=211711>
> Signed-off-by: Gautam Dawar <gdawar@xilinx.com <mailto:gdawar@xilinx.com>>
>
> -----
> changelog:
> v1->v2:
> - Addressed Jason's comment to remove the irq check and use
> vhost_vdpa_unsetup_vq_irq() to avoid local variable vq
> -----
>
Acked-by: Jason Wang <jasowang@redhat.com>
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 62a9bb0efc55..e00573b87aba 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -844,14 +844,10 @@ static int vhost_vdpa_open(struct inode *inode,
> struct file *filep)
>
> static void vhost_vdpa_clean_irq(struct vhost_vdpa *v)
> {
> - struct vhost_virtqueue *vq;
> int i;
>
> - for (i = 0; i < v->nvqs; i++) {
> - vq = &v->vqs[i];
> - if (vq->call_ctx.producer.irq)
> - irq_bypass_unregister_producer(&vq->call_ctx.producer);
> - }
> + for (i = 0; i < v->nvqs; i++)
> + vhost_vdpa_unsetup_vq_irq(v, i);
> }
>
> static int vhost_vdpa_release(struct inode *inode, struct file *filep)
[-- Attachment #1.2: Type: text/html, Size: 3541 bytes --]
[-- Attachment #2: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation
2021-02-23 10:00 [PATCH v2] vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation Gautam Dawar
2021-02-23 10:13 ` Jason Wang
@ 2021-02-23 12:12 ` Michael S. Tsirkin
2021-02-23 12:46 ` Gautam Dawar
1 sibling, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2021-02-23 12:12 UTC (permalink / raw)
To: Gautam Dawar; +Cc: martinh, hanand, gdawar, virtualization
On Tue, Feb 23, 2021 at 03:30:45PM +0530, Gautam Dawar wrote:
> When qemu with vhost-vdpa netdevice is run for the first time, it works well.
> But after the VM is powered off, the next qemu run causes kernel panic due to a
> NULL pointer dereference in irq_bypass_register_producer().
>
> When the VM is powered off, vhost_vdpa_clean_irq() misses on calling
> irq_bypass_unregister_producer() for irq 0 because of the existing check.
>
> This leaves stale producer nodes, which are reset in vhost_vring_call_reset()
> when vhost_dev_init() is invoked during the second qemu run.
>
> As the node member of struct irq_bypass_producer is also initialized
> to zero, traversal on the producers list causes crash due to NULL pointer
> dereference.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211711
> Signed-off-by: Gautam Dawar <gdawar@xilinx.com>
Could you please repost without HTML? Otherwise git am fails on this patch:
error: corrupt patch at line 6
error: could not build fake ancestor
Patch failed at 0001 vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation
Also, which commit introduces the bug? A Fixes: tag would be helpful.
Thanks!
> -----
> changelog:
> v1->v2:
> - Addressed Jason's comment to remove the irq check and use
> vhost_vdpa_unsetup_vq_irq() to avoid local variable vq
> -----
>
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 62a9bb0efc55..e00573b87aba 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -844,14 +844,10 @@ static int vhost_vdpa_open(struct inode *inode, struct
> file *filep)
>
> static void vhost_vdpa_clean_irq(struct vhost_vdpa *v)
> {
> - struct vhost_virtqueue *vq;
> int i;
>
> - for (i = 0; i < v->nvqs; i++) {
> - vq = &v->vqs[i];
> - if (vq->call_ctx.producer.irq)
> - irq_bypass_unregister_producer(&vq->call_ctx.producer);
> - }
> + for (i = 0; i < v->nvqs; i++)
> + vhost_vdpa_unsetup_vq_irq(v, i);
> }
>
> static int vhost_vdpa_release(struct inode *inode, struct file *filep)
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation
2021-02-23 12:12 ` Michael S. Tsirkin
@ 2021-02-23 12:46 ` Gautam Dawar
0 siblings, 0 replies; 4+ messages in thread
From: Gautam Dawar @ 2021-02-23 12:46 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: martinh, hanand, gdawar, virtualization
On Tue, 23 Feb 2021 at 17:43, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Tue, Feb 23, 2021 at 03:30:45PM +0530, Gautam Dawar wrote:
> > When qemu with vhost-vdpa netdevice is run for the first time, it works well.
> > But after the VM is powered off, the next qemu run causes kernel panic due to a
> > NULL pointer dereference in irq_bypass_register_producer().
> >
> > When the VM is powered off, vhost_vdpa_clean_irq() misses on calling
> > irq_bypass_unregister_producer() for irq 0 because of the existing check.
> >
> > This leaves stale producer nodes, which are reset in vhost_vring_call_reset()
> > when vhost_dev_init() is invoked during the second qemu run.
> >
> > As the node member of struct irq_bypass_producer is also initialized
> > to zero, traversal on the producers list causes crash due to NULL pointer
> > dereference.
> >
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211711
> > Signed-off-by: Gautam Dawar <gdawar@xilinx.com>
>
> Could you please repost without HTML? Otherwise git am fails on this patch:
>
> error: corrupt patch at line 6
> error: could not build fake ancestor
> Patch failed at 0001 vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation
>
> Also, which commit introduces the bug? A Fixes: tag would be helpful.
>
> Thanks!
>
I've added the fixes tag and submitted patch v3 in plain-text format.
Thanks,
Gautam
> > -----
> > changelog:
> > v1->v2:
> > - Addressed Jason's comment to remove the irq check and use
> > vhost_vdpa_unsetup_vq_irq() to avoid local variable vq
> > -----
> >
> >
> > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > index 62a9bb0efc55..e00573b87aba 100644
> > --- a/drivers/vhost/vdpa.c
> > +++ b/drivers/vhost/vdpa.c
> > @@ -844,14 +844,10 @@ static int vhost_vdpa_open(struct inode *inode, struct
> > file *filep)
> >
> > static void vhost_vdpa_clean_irq(struct vhost_vdpa *v)
> > {
> > - struct vhost_virtqueue *vq;
> > int i;
> >
> > - for (i = 0; i < v->nvqs; i++) {
> > - vq = &v->vqs[i];
> > - if (vq->call_ctx.producer.irq)
> > - irq_bypass_unregister_producer(&vq->call_ctx.producer);
> > - }
> > + for (i = 0; i < v->nvqs; i++)
> > + vhost_vdpa_unsetup_vq_irq(v, i);
> > }
> >
> > static int vhost_vdpa_release(struct inode *inode, struct file *filep)
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-23 12:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-23 10:00 [PATCH v2] vhost vdpa: fix the missing irq_bypass_unregister_producer() invocation Gautam Dawar
2021-02-23 10:13 ` Jason Wang
2021-02-23 12:12 ` Michael S. Tsirkin
2021-02-23 12:46 ` Gautam Dawar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.