linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: Test for PCI root bus to avoid NULL pointer dereference
@ 2014-08-27 18:57 Alex Williamson
  2014-08-27 19:01 ` Alex Deucher
  2014-10-03 18:01 ` Bronek Kozicki
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Williamson @ 2014-08-27 18:57 UTC (permalink / raw)
  To: airlied, dri-devel; +Cc: linux-kernel, alex.williamson

If we have a GPU on the PCI root bus that calls
drm_pcie_get_speed_cap_mask() we end up with a NULL pointer
dereference since pdev->bus->self is NULL.  We already protect
against callers passing non-PCI devices, so let's also catch this
case and return -EINVAL.

Root complex graphics are not terribly likely outside of IGD, but
when we assign a standard plugin GPU to a virtual machine, our
assumption that we have a parent device quickly becomes invalid.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 drivers/gpu/drm/drm_pci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 020cfd9..411e806 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -390,7 +390,7 @@ int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask)
 	u32 lnkcap, lnkcap2;
 
 	*mask = 0;
-	if (!dev->pdev)
+	if (!dev->pdev || pci_is_root_bus(dev->pdev->bus))
 		return -EINVAL;
 
 	root = dev->pdev->bus->self;


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm: Test for PCI root bus to avoid NULL pointer dereference
  2014-08-27 18:57 [PATCH] drm: Test for PCI root bus to avoid NULL pointer dereference Alex Williamson
@ 2014-08-27 19:01 ` Alex Deucher
  2014-10-03 18:01 ` Bronek Kozicki
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2014-08-27 19:01 UTC (permalink / raw)
  To: Alex Williamson; +Cc: Dave Airlie, Maling list - DRI developers, LKML

On Wed, Aug 27, 2014 at 2:57 PM, Alex Williamson
<alex.williamson@redhat.com> wrote:
> If we have a GPU on the PCI root bus that calls
> drm_pcie_get_speed_cap_mask() we end up with a NULL pointer
> dereference since pdev->bus->self is NULL.  We already protect
> against callers passing non-PCI devices, so let's also catch this
> case and return -EINVAL.
>
> Root complex graphics are not terribly likely outside of IGD, but
> when we assign a standard plugin GPU to a virtual machine, our
> assumption that we have a parent device quickly becomes invalid.
>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>
>  drivers/gpu/drm/drm_pci.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index 020cfd9..411e806 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -390,7 +390,7 @@ int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask)
>         u32 lnkcap, lnkcap2;
>
>         *mask = 0;
> -       if (!dev->pdev)
> +       if (!dev->pdev || pci_is_root_bus(dev->pdev->bus))
>                 return -EINVAL;
>
>         root = dev->pdev->bus->self;
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm: Test for PCI root bus to avoid NULL pointer dereference
  2014-08-27 18:57 [PATCH] drm: Test for PCI root bus to avoid NULL pointer dereference Alex Williamson
  2014-08-27 19:01 ` Alex Deucher
@ 2014-10-03 18:01 ` Bronek Kozicki
  1 sibling, 0 replies; 3+ messages in thread
From: Bronek Kozicki @ 2014-10-03 18:01 UTC (permalink / raw)
  To: Alex Williamson; +Cc: linux-kernel

On 27/08/2014 19:57, Alex Williamson wrote:
> If we have a GPU on the PCI root bus that calls
> drm_pcie_get_speed_cap_mask() we end up with a NULL pointer
> dereference since pdev->bus->self is NULL.  We already protect
> against callers passing non-PCI devices, so let's also catch this
> case and return -EINVAL.
>
> Root complex graphics are not terribly likely outside of IGD, but
> when we assign a standard plugin GPU to a virtual machine, our
> assumption that we have a parent device quickly becomes invalid.


What happend to this patch? I don't see it applied on 
https://github.com/torvalds/linux/tree/master/drivers/gpu/drm


B.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-03 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-27 18:57 [PATCH] drm: Test for PCI root bus to avoid NULL pointer dereference Alex Williamson
2014-08-27 19:01 ` Alex Deucher
2014-10-03 18:01 ` Bronek Kozicki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).