public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: Fix 'Null pointer dereferences' issue
@ 2024-09-03 14:46 Qianqiang Liu
  2024-09-04  1:07 ` Baolu Lu
  2024-09-04  9:49 ` Ethan Zhao
  0 siblings, 2 replies; 4+ messages in thread
From: Qianqiang Liu @ 2024-09-03 14:46 UTC (permalink / raw)
  To: dwmw2, baolu.lu; +Cc: iommu, linux-kernel, Qianqiang Liu

Passing null pointer "pdev" to "pci_enable_pasid", which dereferences it.
Check the "pdev" is null or not before passing to "pci_enable_pasid".

Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
 drivers/iommu/intel/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 9f6b0780f2ef..a1e54f334330 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3935,7 +3935,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
 	 * So always enable PASID support on devices which have it, even if
 	 * we can't yet know if we're ever going to use it.
 	 */
-	if (info->pasid_supported &&
+	if (info->pasid_supported && pdev &&
 	    !pci_enable_pasid(pdev, info->pasid_supported & ~1))
 		info->pasid_enabled = 1;
 
-- 
2.39.2


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

* Re: [PATCH] iommu/vt-d: Fix 'Null pointer dereferences' issue
  2024-09-03 14:46 [PATCH] iommu/vt-d: Fix 'Null pointer dereferences' issue Qianqiang Liu
@ 2024-09-04  1:07 ` Baolu Lu
  2024-09-04  9:49 ` Ethan Zhao
  1 sibling, 0 replies; 4+ messages in thread
From: Baolu Lu @ 2024-09-04  1:07 UTC (permalink / raw)
  To: Qianqiang Liu, dwmw2; +Cc: baolu.lu, iommu, linux-kernel

On 9/3/24 10:46 PM, Qianqiang Liu wrote:
> Passing null pointer "pdev" to "pci_enable_pasid", which dereferences it.
> Check the "pdev" is null or not before passing to "pci_enable_pasid".
> 
> Signed-off-by: Qianqiang Liu<qianqiang.liu@163.com>
> ---
>   drivers/iommu/intel/iommu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 9f6b0780f2ef..a1e54f334330 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -3935,7 +3935,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
>   	 * So always enable PASID support on devices which have it, even if
>   	 * we can't yet know if we're ever going to use it.
>   	 */
> -	if (info->pasid_supported &&
> +	if (info->pasid_supported && pdev &&
>   	    !pci_enable_pasid(pdev, info->pasid_supported & ~1))
>   		info->pasid_enabled = 1;

'info->pasid_supported=true' implies that pdev should never be NULL.
There's no need for an extra check.

Thanks,
baolu

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

* Re: [PATCH] iommu/vt-d: Fix 'Null pointer dereferences' issue
  2024-09-03 14:46 [PATCH] iommu/vt-d: Fix 'Null pointer dereferences' issue Qianqiang Liu
  2024-09-04  1:07 ` Baolu Lu
@ 2024-09-04  9:49 ` Ethan Zhao
  2024-09-04 10:14   ` Qianqiang Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Ethan Zhao @ 2024-09-04  9:49 UTC (permalink / raw)
  To: Qianqiang Liu, dwmw2, baolu.lu; +Cc: iommu, linux-kernel


On 9/3/2024 10:46 PM, Qianqiang Liu wrote:
> Passing null pointer "pdev" to "pci_enable_pasid", which dereferences it.
> Check the "pdev" is null or not before passing to "pci_enable_pasid".
>
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> ---
>   drivers/iommu/intel/iommu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 9f6b0780f2ef..a1e54f334330 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -3935,7 +3935,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
>   	 * So always enable PASID support on devices which have it, even if
>   	 * we can't yet know if we're ever going to use it.
>   	 */
> -	if (info->pasid_supported &&
> +	if (info->pasid_supported && pdev &&
>   	    !pci_enable_pasid(pdev, info->pasid_supported & ~1))

You hit any issue with specific ver kernel ? seems impossible to hit
such NULL pointer issue with the latest kernel for which you sent
this patch.

Thanks,
Ethan

>   		info->pasid_enabled = 1;
>   

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

* Re: [PATCH] iommu/vt-d: Fix 'Null pointer dereferences' issue
  2024-09-04  9:49 ` Ethan Zhao
@ 2024-09-04 10:14   ` Qianqiang Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Qianqiang Liu @ 2024-09-04 10:14 UTC (permalink / raw)
  To: Ethan Zhao; +Cc: dwmw2, baolu.lu, iommu, linux-kernel

Hi Ethan,

No, I don’t hit any issues so far.
It was scanned by Coverity, and I tried to fix it.
If you think it's not an issue, we can just ignore it.

On Wed, Sep 04, 2024 at 05:49:49PM +0800, Ethan Zhao wrote:
> 
> On 9/3/2024 10:46 PM, Qianqiang Liu wrote:
> > Passing null pointer "pdev" to "pci_enable_pasid", which dereferences it.
> > Check the "pdev" is null or not before passing to "pci_enable_pasid".
> > 
> > Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> > ---
> >   drivers/iommu/intel/iommu.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index 9f6b0780f2ef..a1e54f334330 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -3935,7 +3935,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
> >   	 * So always enable PASID support on devices which have it, even if
> >   	 * we can't yet know if we're ever going to use it.
> >   	 */
> > -	if (info->pasid_supported &&
> > +	if (info->pasid_supported && pdev &&
> >   	    !pci_enable_pasid(pdev, info->pasid_supported & ~1))
> 
> You hit any issue with specific ver kernel ? seems impossible to hit
> such NULL pointer issue with the latest kernel for which you sent
> this patch.
> 
> Thanks,
> Ethan
> 
> >   		info->pasid_enabled = 1;


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

end of thread, other threads:[~2024-09-04 10:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 14:46 [PATCH] iommu/vt-d: Fix 'Null pointer dereferences' issue Qianqiang Liu
2024-09-04  1:07 ` Baolu Lu
2024-09-04  9:49 ` Ethan Zhao
2024-09-04 10:14   ` Qianqiang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox