Skip to contentSkip to conversation

acpi: validate hotplug selector on access

PATCH In review Michael S. Tsirkin 4 participants 10 messages Dec 21, 2021 – Dec 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi: validate hotplug selector on access

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>
---
 hw/acpi/pcihp.c | 3 +++
 1 file changed, 3 insertions(+)
hw/acpi/pcihp.c +3 -0
index 30405b5113..a5e182dd3a 100644
@@ -491,6 +491,9 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data,
         }
 
         bus = acpi_pcihp_find_hotplug_bus(s, s->hotplug_select);
+        if (!bus) {
+            break;
+        }
         QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) {
             Object *o = OBJECT(kid->child);
             PCIDevice *dev = PCI_DEVICE(o);
Signature · 1 line
MST
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Quoted 7 lines
Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>
---
 hw/acpi/pcihp.c | 3 +++
 1 file changed, 3 insertions(+)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 4 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Good fix. Nice catch.

Quoted 5 lines
Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>
Quoted 22 lines
---
 hw/acpi/pcihp.c | 3 +++
 1 file changed, 3 insertions(+)
hw/acpi/pcihp.c +3 -1
index 30405b5113..a5e182dd3a 100644
@@ -491,6 +491,9 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data,
         }
 
         bus = acpi_pcihp_find_hotplug_bus(s, s->hotplug_select);
+        if (!bus) {
+            break;
+        }
         QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) {
             Object *o = OBJECT(kid->child);
             PCIDevice *dev = PCI_DEVICE(o);
--

MST

#3 lore raw
In reply to Michael S. Tsirkin

+Mauro & Alex

Quoted 9 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>

It seems this problem is important enough to get a CVE assigned.

Mauro, please update us when you get the CVE number. Michael, please amend the CVE number before committing the fix.

FWIW Paolo asked every fuzzed bug reproducer to be committed as qtest, see tests/qtest/fuzz*c. Alex has a way to generate reproducer in plain C.

Regards,

Phil.

#4 lore raw
Quoted 8 lines · Philippe Mathieu-Daudé

+Mauro & Alex

Quoted 5 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Quoted 6 lines
Quoted 4 lines
Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>

It seems this problem is important enough to get a CVE assigned.

Guest root can crash guest.
I don't see why we would assign a CVE.

Quoted 10 lines

Mauro, please update us when you get the CVE number. Michael, please amend the CVE number before committing the fix.

FWIW Paolo asked every fuzzed bug reproducer to be committed as qtest, see tests/qtest/fuzz*c. Alex has a way to generate reproducer in plain C.

Regards,

Phil.

#5 lore raw
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Philippe Mathieu-Daudé

+Mauro & Alex

Quoted 9 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>
Quoted 4 lines
Quoted 1 line

It seems this problem is important enough to get a CVE assigned.

Guest root can crash guest.
I don't see why we would assign a CVE.

Well thinking about downstream distributions, if there is a CVE assigned, it helps them to have it written in the commit. Maybe I am mistaken.

Unrelated but it seems there is a coordination problem with the qemu-security@ list,
if this isn't a security issue, why was a CVE requested?

Quoted 11 lines
Quoted 10 lines

Mauro, please update us when you get the CVE number. Michael, please amend the CVE number before committing the fix.

FWIW Paolo asked every fuzzed bug reproducer to be committed as qtest, see tests/qtest/fuzz*c. Alex has a way to generate reproducer in plain C.

Regards,

Phil.

#6 lore raw
Quoted 20 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Philippe Mathieu-Daudé

+Mauro & Alex

Quoted 9 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>
Quoted 4 lines
Quoted 1 line

It seems this problem is important enough to get a CVE assigned.

Guest root can crash guest.
I don't see why we would assign a CVE.

Quoted 6 lines

Well thinking about downstream distributions, if there is a CVE assigned, it helps them to have it written in the commit. Maybe I am mistaken.

Unrelated but it seems there is a coordination problem with the qemu-security@ list,
if this isn't a security issue, why was a CVE requested?

Right. I don't think a priveleged user crashing VM warrants a CVE, it can just halt a CPU or whatever. Just cancel the CVE request pls.

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Mauro, please update us when you get the CVE number. Michael, please amend the CVE number before committing the fix.

FWIW Paolo asked every fuzzed bug reproducer to be committed as qtest, see tests/qtest/fuzz*c. Alex has a way to generate reproducer in plain C.

Regards,

Phil.

#7 lore raw

Hi,

Quoted 25 lines · Michael S. Tsirkin
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Philippe Mathieu-Daudé

+Mauro & Alex

Quoted 9 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>
Quoted 4 lines
Quoted 1 line

It seems this problem is important enough to get a CVE assigned.

Guest root can crash guest.
I don't see why we would assign a CVE.

Well thinking about downstream distributions, if there is a CVE assigned, it helps them to have it written in the commit. Maybe I am mistaken.

Quoted 6 lines
Quoted 3 lines

Unrelated but it seems there is a coordination problem with the qemu-security@ list,
if this isn't a security issue, why was a CVE requested?

Right. I don't think a priveleged user crashing VM warrants a CVE, it can just halt a CPU or whatever. Just cancel the CVE request pls.

While I agree with you that this is kind of borderline and I expressed similar concerns in the past, I was told that:

1) root guest users are not necessarily trustworthy (from the host perspective).
2) NULL pointer deref and similar issues caused by an ill-handled/error condition are CVE worthy, even if triggered by root.
3) In other cases, DoS triggered by root is not a security issue because it's an expected behavior and not an ill-handled/error condition (think of assert failures, for example).

In other words, "ill-handled condition" is the crucial factor that makes a bug CVE worthy or not.

+Prasad, can you shed some light on this? Is my understanding correct?

Also, please note that we regularly get CVE requests for bugs like this and many CVEs have been assigned in the past. Of course that doesn't mean we can't change things going forward, but I think we should make it clear (probably here:
https://www.qemu.org/docs/master/system/security.html) that these kinds of bugs are not eligible for CVE assignment.

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Mauro, please update us when you get the CVE number. Michael, please amend the CVE number before committing the fix.

FWIW Paolo asked every fuzzed bug reproducer to be committed as qtest, see tests/qtest/fuzz*c. Alex has a way to generate reproducer in plain C.

Regards,

Phil.

Signature · 3 lines
Mauro Matteo Cascella
Red Hat Product Security
PGP-Key ID: BB3410B0
#8 lore raw
Quoted 45 lines · Mauro Matteo Cascella

Hi,

Quoted 25 lines · Michael S. Tsirkin
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Philippe Mathieu-Daudé

+Mauro & Alex

Quoted 9 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>
Quoted 4 lines
Quoted 1 line

It seems this problem is important enough to get a CVE assigned.

Guest root can crash guest.
I don't see why we would assign a CVE.

Well thinking about downstream distributions, if there is a CVE assigned, it helps them to have it written in the commit. Maybe I am mistaken.

Quoted 6 lines
Quoted 3 lines

Unrelated but it seems there is a coordination problem with the qemu-security@ list,
if this isn't a security issue, why was a CVE requested?

Right. I don't think a priveleged user crashing VM warrants a CVE, it can just halt a CPU or whatever. Just cancel the CVE request pls.

While I agree with you that this is kind of borderline and I expressed similar concerns in the past, I was told that:

1) root guest users are not necessarily trustworthy (from the host perspective).
2) NULL pointer deref and similar issues caused by an ill-handled/error condition are CVE worthy, even if triggered by root.
3) In other cases, DoS triggered by root is not a security issue because it's an expected behavior and not an ill-handled/error condition (think of assert failures, for example).

Quoted 2 lines

In other words, "ill-handled condition" is the crucial factor that makes a bug CVE worthy or not.

I guess the point is that a downstream might have a slightly different code path where it would be more serious ...
OK then, not a big deal for me. So what's the CVE # then?

Quoted 8 lines

+Prasad, can you shed some light on this? Is my understanding correct?

Also, please note that we regularly get CVE requests for bugs like this and many CVEs have been assigned in the past. Of course that doesn't mean we can't change things going forward, but I think we should make it clear (probably here:
https://www.qemu.org/docs/master/system/security.html) that these kinds of bugs are not eligible for CVE assignment.

That would be good, yes.

Quoted 17 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Mauro, please update us when you get the CVE number. Michael, please amend the CVE number before committing the fix.

FWIW Paolo asked every fuzzed bug reproducer to be committed as qtest, see tests/qtest/fuzz*c. Alex has a way to generate reproducer in plain C.

Regards,

Phil.

Signature · 3 lines
Mauro Matteo Cascella
Red Hat Product Security
PGP-Key ID: BB3410B0
#9 lore raw
Quoted 47 lines · Michael S. Tsirkin
Quoted 45 lines · Mauro Matteo Cascella

Hi,

Quoted 25 lines · Michael S. Tsirkin
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Philippe Mathieu-Daudé

+Mauro & Alex

Quoted 9 lines · Michael S. Tsirkin

When bus is looked up on a pci write, we didn't validate that the lookup succeeded.
Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer.

Fixes b32bd763a1 ("pci: introduce acpi-index property for PCI device")
Cc "Igor Mammedov" <[email protected]>
Quoted 4 lines
Quoted 1 line

It seems this problem is important enough to get a CVE assigned.

Guest root can crash guest.
I don't see why we would assign a CVE.

Well thinking about downstream distributions, if there is a CVE assigned, it helps them to have it written in the commit. Maybe I am mistaken.

Quoted 6 lines
Quoted 3 lines

Unrelated but it seems there is a coordination problem with the qemu-security@ list,
if this isn't a security issue, why was a CVE requested?

Right. I don't think a priveleged user crashing VM warrants a CVE, it can just halt a CPU or whatever. Just cancel the CVE request pls.

While I agree with you that this is kind of borderline and I expressed similar concerns in the past, I was told that:

1) root guest users are not necessarily trustworthy (from the host perspective).
2) NULL pointer deref and similar issues caused by an ill-handled/error condition are CVE worthy, even if triggered by root.
3) In other cases, DoS triggered by root is not a security issue because it's an expected behavior and not an ill-handled/error condition (think of assert failures, for example).

Quoted 6 lines
Quoted 2 lines

In other words, "ill-handled condition" is the crucial factor that makes a bug CVE worthy or not.

I guess the point is that a downstream might have a slightly different code path where it would be more serious ...
OK then, not a big deal for me. So what's the CVE # then?

CVE-2021-4158 has been assigned for this issue.

Quoted 8 lines
Quoted 8 lines

+Prasad, can you shed some light on this? Is my understanding correct?

Also, please note that we regularly get CVE requests for bugs like this and many CVEs have been assigned in the past. Of course that doesn't mean we can't change things going forward, but I think we should make it clear (probably here:
https://www.qemu.org/docs/master/system/security.html) that these kinds of bugs are not eligible for CVE assignment.

Thanks.

Signature · 3 lines
Mauro Matteo Cascella
Red Hat Product Security
PGP-Key ID: BB3410B0