* [PATCH 0/2] More IOMMU Fixes
@ 2014-08-21 21:37 Joerg Roedel
2014-08-21 21:37 ` [PATCH 1/2] iommu: Make iommu_group_get_for_dev() more robust Joerg Roedel
2014-08-21 21:37 ` [PATCH 2/2] iommu/vt-d: Check return value of acpi_bus_get_device() Joerg Roedel
0 siblings, 2 replies; 5+ messages in thread
From: Joerg Roedel @ 2014-08-21 21:37 UTC (permalink / raw)
To: iommu
Cc: linux-kernel, Alex Williamson, David Woodhouse, Joerg Roedel,
Joerg Roedel
Hi,
here are two patches that fix valid issues discovered by
Coverity. Please review.
Thanks,
Joerg
Joerg Roedel (2):
iommu: Make iommu_group_get_for_dev() more robust
iommu/vt-d: Check return value of acpi_bus_get_device()
drivers/iommu/dmar.c | 3 +--
drivers/iommu/iommu.c | 8 +++++---
2 files changed, 6 insertions(+), 5 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] iommu: Make iommu_group_get_for_dev() more robust
2014-08-21 21:37 [PATCH 0/2] More IOMMU Fixes Joerg Roedel
@ 2014-08-21 21:37 ` Joerg Roedel
2014-08-21 21:54 ` Alex Williamson
2014-08-21 21:37 ` [PATCH 2/2] iommu/vt-d: Check return value of acpi_bus_get_device() Joerg Roedel
1 sibling, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2014-08-21 21:37 UTC (permalink / raw)
To: iommu; +Cc: linux-kernel, Alex Williamson, David Woodhouse, Joerg Roedel
From: Joerg Roedel <jroedel@suse.de>
When a non-PCI device is passed to that function it might
pass group == NULL to iommu_group_add_device() which then
dereferences it and cause a crash this way. Fix it by
just returning an error for non-PCI devices.
Fixes: 104a1c13ac66e40cf8c6ae74d76ff14ff24b9b01
Cc: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/iommu.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 1698360..ef8da12 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -678,15 +678,17 @@ static struct iommu_group *iommu_group_get_for_pci_dev(struct pci_dev *pdev)
*/
struct iommu_group *iommu_group_get_for_dev(struct device *dev)
{
- struct iommu_group *group = ERR_PTR(-EIO);
+ struct iommu_group *group;
int ret;
group = iommu_group_get(dev);
if (group)
return group;
- if (dev_is_pci(dev))
- group = iommu_group_get_for_pci_dev(to_pci_dev(dev));
+ if (!dev_is_pci(dev))
+ return ERR_PTR(-EINVAL);
+
+ group = iommu_group_get_for_pci_dev(to_pci_dev(dev));
if (IS_ERR(group))
return group;
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] iommu/vt-d: Check return value of acpi_bus_get_device()
2014-08-21 21:37 [PATCH 0/2] More IOMMU Fixes Joerg Roedel
2014-08-21 21:37 ` [PATCH 1/2] iommu: Make iommu_group_get_for_dev() more robust Joerg Roedel
@ 2014-08-21 21:37 ` Joerg Roedel
2014-08-21 21:57 ` Alex Williamson
1 sibling, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2014-08-21 21:37 UTC (permalink / raw)
To: iommu; +Cc: linux-kernel, Alex Williamson, David Woodhouse, Joerg Roedel
From: Joerg Roedel <jroedel@suse.de>
Checking adev == NULL is not sufficient as
acpi_bus_get_device() might not touch the value of this
parameter in an error case, so check the return value
directly.
Fixes: ed40356b5fcf1ce28e026ab39c5b2b6939068b50
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/dmar.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 60ab474..06d268a 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -678,8 +678,7 @@ static int __init dmar_acpi_dev_scope_init(void)
andd->device_name);
continue;
}
- acpi_bus_get_device(h, &adev);
- if (!adev) {
+ if (acpi_bus_get_device(h, &adev)) {
pr_err("Failed to get device for ACPI object %s\n",
andd->device_name);
continue;
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] iommu: Make iommu_group_get_for_dev() more robust
2014-08-21 21:37 ` [PATCH 1/2] iommu: Make iommu_group_get_for_dev() more robust Joerg Roedel
@ 2014-08-21 21:54 ` Alex Williamson
0 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2014-08-21 21:54 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, David Woodhouse, Joerg Roedel
On Thu, 2014-08-21 at 23:37 +0200, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
>
> When a non-PCI device is passed to that function it might
> pass group == NULL to iommu_group_add_device() which then
> dereferences it and cause a crash this way. Fix it by
> just returning an error for non-PCI devices.
>
> Fixes: 104a1c13ac66e40cf8c6ae74d76ff14ff24b9b01
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
> drivers/iommu/iommu.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 1698360..ef8da12 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -678,15 +678,17 @@ static struct iommu_group *iommu_group_get_for_pci_dev(struct pci_dev *pdev)
> */
> struct iommu_group *iommu_group_get_for_dev(struct device *dev)
> {
> - struct iommu_group *group = ERR_PTR(-EIO);
> + struct iommu_group *group;
> int ret;
>
> group = iommu_group_get(dev);
> if (group)
> return group;
Hmm, I bet I had a second pointer for this case but mistakenly optimized
it out refining the patch. This solution works too though.
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Thanks!
Alex
>
> - if (dev_is_pci(dev))
> - group = iommu_group_get_for_pci_dev(to_pci_dev(dev));
> + if (!dev_is_pci(dev))
> + return ERR_PTR(-EINVAL);
> +
> + group = iommu_group_get_for_pci_dev(to_pci_dev(dev));
>
> if (IS_ERR(group))
> return group;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] iommu/vt-d: Check return value of acpi_bus_get_device()
2014-08-21 21:37 ` [PATCH 2/2] iommu/vt-d: Check return value of acpi_bus_get_device() Joerg Roedel
@ 2014-08-21 21:57 ` Alex Williamson
0 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2014-08-21 21:57 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, David Woodhouse, Joerg Roedel
On Thu, 2014-08-21 at 23:37 +0200, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
>
> Checking adev == NULL is not sufficient as
> acpi_bus_get_device() might not touch the value of this
> parameter in an error case, so check the return value
> directly.
>
> Fixes: ed40356b5fcf1ce28e026ab39c5b2b6939068b50
> Cc: David Woodhouse <dwmw2@infradead.org>
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
> drivers/iommu/dmar.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
> index 60ab474..06d268a 100644
> --- a/drivers/iommu/dmar.c
> +++ b/drivers/iommu/dmar.c
> @@ -678,8 +678,7 @@ static int __init dmar_acpi_dev_scope_init(void)
> andd->device_name);
> continue;
> }
> - acpi_bus_get_device(h, &adev);
> - if (!adev) {
> + if (acpi_bus_get_device(h, &adev)) {
> pr_err("Failed to get device for ACPI object %s\n",
> andd->device_name);
> continue;
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-21 21:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-21 21:37 [PATCH 0/2] More IOMMU Fixes Joerg Roedel
2014-08-21 21:37 ` [PATCH 1/2] iommu: Make iommu_group_get_for_dev() more robust Joerg Roedel
2014-08-21 21:54 ` Alex Williamson
2014-08-21 21:37 ` [PATCH 2/2] iommu/vt-d: Check return value of acpi_bus_get_device() Joerg Roedel
2014-08-21 21:57 ` Alex Williamson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome