* [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash
@ 2018-11-27 8:41 Markus Armbruster
2018-11-27 9:04 ` Cornelia Huck
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Markus Armbruster @ 2018-11-27 8:41 UTC (permalink / raw)
To: qemu-devel; +Cc: coli, fam, stefanha, pbonzini
qemu_vfio_open_common() initializes s->lock only after passing s to
qemu_vfio_dma_map() via qemu_vfio_init_ramblock().
qemu_vfio_dma_map() tries to lock the uninitialized lock and crashes.
Fix by initializing s->lock first.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1645840
Fixes: 418026ca43bc2626db092d7558258f9594366f28
Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
Compile-tested only, as I lack suitable hardware. Cong Li (cc'ed) is
going to test it for real. It looks obvious enough to me to put it
into -rc3 without waiting for the test results. We can also wait and
put it into -rc4.
util/vfio-helpers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 1d9272efa4..cccc9cd42e 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -411,13 +411,13 @@ static int qemu_vfio_init_ramblock(const char *block_name, void *host_addr,
static void qemu_vfio_open_common(QEMUVFIOState *s)
{
+ qemu_mutex_init(&s->lock);
s->ram_notifier.ram_block_added = qemu_vfio_ram_block_added;
s->ram_notifier.ram_block_removed = qemu_vfio_ram_block_removed;
ram_block_notifier_add(&s->ram_notifier);
s->low_water_mark = QEMU_VFIO_IOVA_MIN;
s->high_water_mark = QEMU_VFIO_IOVA_MAX;
qemu_ram_foreach_block(qemu_vfio_init_ramblock, s);
- qemu_mutex_init(&s->lock);
}
/**
--
2.17.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash
2018-11-27 8:41 [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash Markus Armbruster
@ 2018-11-27 9:04 ` Cornelia Huck
2018-11-27 9:18 ` Stefan Hajnoczi
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Cornelia Huck @ 2018-11-27 9:04 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, fam, pbonzini, coli, stefanha
On Tue, 27 Nov 2018 09:41:43 +0100
Markus Armbruster <armbru@redhat.com> wrote:
> qemu_vfio_open_common() initializes s->lock only after passing s to
> qemu_vfio_dma_map() via qemu_vfio_init_ramblock().
> qemu_vfio_dma_map() tries to lock the uninitialized lock and crashes.
>
> Fix by initializing s->lock first.
>
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1645840
> Fixes: 418026ca43bc2626db092d7558258f9594366f28
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> Compile-tested only, as I lack suitable hardware. Cong Li (cc'ed) is
> going to test it for real. It looks obvious enough to me to put it
> into -rc3 without waiting for the test results. We can also wait and
> put it into -rc4.
This looks obvious to me as well.
>
> util/vfio-helpers.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
> index 1d9272efa4..cccc9cd42e 100644
> --- a/util/vfio-helpers.c
> +++ b/util/vfio-helpers.c
> @@ -411,13 +411,13 @@ static int qemu_vfio_init_ramblock(const char *block_name, void *host_addr,
>
> static void qemu_vfio_open_common(QEMUVFIOState *s)
> {
> + qemu_mutex_init(&s->lock);
> s->ram_notifier.ram_block_added = qemu_vfio_ram_block_added;
> s->ram_notifier.ram_block_removed = qemu_vfio_ram_block_removed;
> ram_block_notifier_add(&s->ram_notifier);
> s->low_water_mark = QEMU_VFIO_IOVA_MIN;
> s->high_water_mark = QEMU_VFIO_IOVA_MAX;
> qemu_ram_foreach_block(qemu_vfio_init_ramblock, s);
> - qemu_mutex_init(&s->lock);
> }
>
> /**
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash
2018-11-27 8:41 [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash Markus Armbruster
2018-11-27 9:04 ` Cornelia Huck
@ 2018-11-27 9:18 ` Stefan Hajnoczi
2018-11-27 20:59 ` Peter Maydell
2018-11-28 5:47 ` Cong Li
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2018-11-27 9:18 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, coli, fam, pbonzini
[-- Attachment #1: Type: text/plain, Size: 894 bytes --]
On Tue, Nov 27, 2018 at 09:41:43AM +0100, Markus Armbruster wrote:
> qemu_vfio_open_common() initializes s->lock only after passing s to
> qemu_vfio_dma_map() via qemu_vfio_init_ramblock().
> qemu_vfio_dma_map() tries to lock the uninitialized lock and crashes.
>
> Fix by initializing s->lock first.
>
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1645840
> Fixes: 418026ca43bc2626db092d7558258f9594366f28
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> Compile-tested only, as I lack suitable hardware. Cong Li (cc'ed) is
> going to test it for real. It looks obvious enough to me to put it
> into -rc3 without waiting for the test results. We can also wait and
> put it into -rc4.
>
> util/vfio-helpers.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash
2018-11-27 8:41 [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash Markus Armbruster
2018-11-27 9:04 ` Cornelia Huck
2018-11-27 9:18 ` Stefan Hajnoczi
@ 2018-11-27 20:59 ` Peter Maydell
2018-11-28 5:47 ` Cong Li
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2018-11-27 20:59 UTC (permalink / raw)
To: Markus Armbruster
Cc: QEMU Developers, fam, Paolo Bonzini, coli, Stefan Hajnoczi
On Tue, 27 Nov 2018 at 08:42, Markus Armbruster <armbru@redhat.com> wrote:
>
> qemu_vfio_open_common() initializes s->lock only after passing s to
> qemu_vfio_dma_map() via qemu_vfio_init_ramblock().
> qemu_vfio_dma_map() tries to lock the uninitialized lock and crashes.
>
> Fix by initializing s->lock first.
>
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1645840
> Fixes: 418026ca43bc2626db092d7558258f9594366f28
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> Compile-tested only, as I lack suitable hardware. Cong Li (cc'ed) is
> going to test it for real. It looks obvious enough to me to put it
> into -rc3 without waiting for the test results. We can also wait and
> put it into -rc4.
>
> util/vfio-helpers.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks (for rc3).
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash
2018-11-27 8:41 [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash Markus Armbruster
` (2 preceding siblings ...)
2018-11-27 20:59 ` Peter Maydell
@ 2018-11-28 5:47 ` Cong Li
3 siblings, 0 replies; 5+ messages in thread
From: Cong Li @ 2018-11-28 5:47 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, fam, stefanha, pbonzini
----- Original Message -----
> From: "Markus Armbruster" <armbru@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: coli@redhat.com, fam@euphon.net, stefanha@redhat.com, pbonzini@redhat.com
> Sent: Tuesday, November 27, 2018 4:41:43 PM
> Subject: [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash
>
> qemu_vfio_open_common() initializes s->lock only after passing s to
> qemu_vfio_dma_map() via qemu_vfio_init_ramblock().
> qemu_vfio_dma_map() tries to lock the uninitialized lock and crashes.
>
> Fix by initializing s->lock first.
>
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1645840
> Fixes: 418026ca43bc2626db092d7558258f9594366f28
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> Compile-tested only, as I lack suitable hardware. Cong Li (cc'ed) is
> going to test it for real. It looks obvious enough to me to put it
> into -rc3 without waiting for the test results. We can also wait and
> put it into -rc4.
Smoke test of nvme:// pass with this patch.
Ack.
>
> util/vfio-helpers.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
> index 1d9272efa4..cccc9cd42e 100644
> --- a/util/vfio-helpers.c
> +++ b/util/vfio-helpers.c
> @@ -411,13 +411,13 @@ static int qemu_vfio_init_ramblock(const char
> *block_name, void *host_addr,
>
> static void qemu_vfio_open_common(QEMUVFIOState *s)
> {
> + qemu_mutex_init(&s->lock);
> s->ram_notifier.ram_block_added = qemu_vfio_ram_block_added;
> s->ram_notifier.ram_block_removed = qemu_vfio_ram_block_removed;
> ram_block_notifier_add(&s->ram_notifier);
> s->low_water_mark = QEMU_VFIO_IOVA_MIN;
> s->high_water_mark = QEMU_VFIO_IOVA_MAX;
> qemu_ram_foreach_block(qemu_vfio_init_ramblock, s);
> - qemu_mutex_init(&s->lock);
> }
>
> /**
> --
> 2.17.2
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-11-28 5:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27 8:41 [Qemu-devel] [PATCH for-3.1] vfio-helpers: Fix qemu_vfio_open_pci() crash Markus Armbruster
2018-11-27 9:04 ` Cornelia Huck
2018-11-27 9:18 ` Stefan Hajnoczi
2018-11-27 20:59 ` Peter Maydell
2018-11-28 5:47 ` Cong Li
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.