* [Qemu-devel] [PATCH] pci-devfn: check that device/slot number is within range
@ 2011-09-21 19:25 Donald Dutile
2011-09-22 8:08 ` Markus Armbruster
2011-09-23 16:06 ` Anthony Liguori
0 siblings, 2 replies; 3+ messages in thread
From: Donald Dutile @ 2011-09-21 19:25 UTC (permalink / raw)
To: qemu-devel
Need to check that guest slot/device number is not > 31 or walk off
the devfn table when checking if a devfn is available or not in a guest.
before this fix, passing in an addr=abc or addr=34,
can crash qemu, sometimes fail gracefully if data past end
of devfn table fails the availability test.
with this fix, get clean error:
Property 'pci-assign.addr' doesn't take value '34'
also tested when no addr= param passed for guest (pcicfg) address,
and that worked as well.
Signed-off-by: Don Dutile <ddutile@redhat.com>
---
hw/qdev-properties.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 7ce95b6..e0e54aa 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -524,6 +524,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str)
return -EINVAL;
if (fn > 7)
return -EINVAL;
+ if (slot > 31)
+ return -EINVAL;
*ptr = slot << 3 | fn;
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] pci-devfn: check that device/slot number is within range
2011-09-21 19:25 [Qemu-devel] [PATCH] pci-devfn: check that device/slot number is within range Donald Dutile
@ 2011-09-22 8:08 ` Markus Armbruster
2011-09-23 16:06 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2011-09-22 8:08 UTC (permalink / raw)
To: Donald Dutile; +Cc: qemu-devel
Donald Dutile <ddutile@redhat.com> writes:
> Need to check that guest slot/device number is not > 31 or walk off
> the devfn table when checking if a devfn is available or not in a guest.
Here in do_pci_register_device():
} else if (bus->devices[devfn]) {
error_report("PCI: devfn %d not available for %s, in use by %s",
devfn, name, bus->devices[devfn]->name);
return NULL;
}
> before this fix, passing in an addr=abc or addr=34,
> can crash qemu, sometimes fail gracefully if data past end
> of devfn table fails the availability test.
>
> with this fix, get clean error:
> Property 'pci-assign.addr' doesn't take value '34'
>
> also tested when no addr= param passed for guest (pcicfg) address,
> and that worked as well.
>
> Signed-off-by: Don Dutile <ddutile@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] pci-devfn: check that device/slot number is within range
2011-09-21 19:25 [Qemu-devel] [PATCH] pci-devfn: check that device/slot number is within range Donald Dutile
2011-09-22 8:08 ` Markus Armbruster
@ 2011-09-23 16:06 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2011-09-23 16:06 UTC (permalink / raw)
To: Donald Dutile; +Cc: qemu-devel
On 09/21/2011 02:25 PM, Donald Dutile wrote:
> Need to check that guest slot/device number is not> 31 or walk off
> the devfn table when checking if a devfn is available or not in a guest.
>
> before this fix, passing in an addr=abc or addr=34,
> can crash qemu, sometimes fail gracefully if data past end
> of devfn table fails the availability test.
>
> with this fix, get clean error:
> Property 'pci-assign.addr' doesn't take value '34'
>
> also tested when no addr= param passed for guest (pcicfg) address,
> and that worked as well.
>
> Signed-off-by: Don Dutile<ddutile@redhat.com>
Applied. Thanks.
Regards,
Anthony Liguori
>
> ---
> hw/qdev-properties.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 7ce95b6..e0e54aa 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -524,6 +524,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str)
> return -EINVAL;
> if (fn> 7)
> return -EINVAL;
> + if (slot> 31)
> + return -EINVAL;
> *ptr = slot<< 3 | fn;
> return 0;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-23 16:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-21 19:25 [Qemu-devel] [PATCH] pci-devfn: check that device/slot number is within range Donald Dutile
2011-09-22 8:08 ` Markus Armbruster
2011-09-23 16:06 ` Anthony Liguori
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.