Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Amelia Crate <acrate@waldn.net>
To: gregkh@linuxfoundation.org
Cc: dimitri.ledkov@surgut.co.uk, stable@vger.kernel.org,
	Kees Bakker <kees@ijzerbout.nl>, Amelia Crate <acrate@waldn.net>
Subject: [PATCH v2 1/4] iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE
Date: Thu, 30 Oct 2025 11:08:31 -0500	[thread overview]
Message-ID: <20251030160942.19490-2-acrate@waldn.net> (raw)
In-Reply-To: <20251030160942.19490-1-acrate@waldn.net>

From: Kees Bakker <kees@ijzerbout.nl>

[ Upstream commit 60f030f7418d3f1d94f2fb207fe3080e1844630b ]

There is a WARN_ON_ONCE to catch an unlikely situation when
domain_remove_dev_pasid can't find the `pasid`. In case it nevertheless
happens we must avoid using a NULL pointer.

Signed-off-by: Kees Bakker <kees@ijzerbout.nl>
Link: https://lore.kernel.org/r/20241218201048.E544818E57E@bout3.ijzerbout.nl
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Amelia Crate <acrate@waldn.net>
---
 drivers/iommu/intel/iommu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 667407974e23..c799cc67db34 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4328,13 +4328,14 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
 			break;
 		}
 	}
-	WARN_ON_ONCE(!dev_pasid);
 	spin_unlock_irqrestore(&dmar_domain->lock, flags);
 
 	cache_tag_unassign_domain(dmar_domain, dev, pasid);
 	domain_detach_iommu(dmar_domain, iommu);
-	intel_iommu_debugfs_remove_dev_pasid(dev_pasid);
-	kfree(dev_pasid);
+	if (!WARN_ON_ONCE(!dev_pasid)) {
+		intel_iommu_debugfs_remove_dev_pasid(dev_pasid);
+		kfree(dev_pasid);
+	}
 	intel_pasid_tear_down_entry(iommu, dev, pasid, false);
 	intel_drain_pasid_prq(dev, pasid);
 }
-- 
2.50.1


  reply	other threads:[~2025-10-30 16:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29 22:24 [PATCH 0/4] Backport CVE fixes to 6.12.y Amelia Crate
2025-10-29 22:25 ` [PATCH 1/4] iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE Amelia Crate
2025-10-29 22:26   ` [PATCH 2/4] udmabuf: fix a buf size overflow issue during udmabuf creation Amelia Crate
2025-10-29 22:27     ` [PATCH 3/4] wifi: ath12k: fix read pointer after free in ath12k_mac_assign_vif_to_vdev() Amelia Crate
2025-10-29 22:27       ` [PATCH 4/4] sfc: fix NULL dereferences in ef100_process_design_param() Amelia Crate
2025-10-30  5:26 ` [PATCH 0/4] Backport CVE fixes to 6.12.y Greg KH
2025-10-30 16:08   ` [PATCH v2 " Amelia Crate
2025-10-30 16:08     ` Amelia Crate [this message]
2025-10-30 16:08     ` [PATCH v2 2/4] udmabuf: fix a buf size overflow issue during udmabuf creation Amelia Crate
2025-10-30 16:08     ` [PATCH v2 3/4] wifi: ath12k: fix read pointer after free in ath12k_mac_assign_vif_to_vdev() Amelia Crate
2025-10-30 16:08     ` [PATCH v2 4/4] sfc: fix NULL dereferences in ef100_process_design_param() Amelia Crate

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251030160942.19490-2-acrate@waldn.net \
    --to=acrate@waldn.net \
    --cc=dimitri.ledkov@surgut.co.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=kees@ijzerbout.nl \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox