Skip to contentSkip to conversation

dmaengine: idxd: Fix leaking event log memory

PATCH In review Wenshan Lan 2 participants 3 messages May 7 – May 9 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: idxd: Fix leaking event log memory

From: Vinicius Costa Gomes <[email protected]>

[ Upstream commit ee66bc29578391c9b48523dc9119af67bd5c7c0f ]

During the device remove process, the device is reset, causing the configuration registers to go back to their default state, which is zero. As the driver is checking if the event log support was enabled before deallocating, it will fail if a reset happened before.

Do not check if the support was enabled, the check for 'idxd->evl' being valid (only allocated if the HW capability is available) is enough.

Fixes 244da66cda35 ("dmaengine: idxd: setup event log configuration")
[ Minor context conflict resolved. ]
---
 drivers/dma/idxd/device.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/dma/idxd/device.c +0 -4
index 44bbeb3acd14..10e54a050ea9 100644
@@ -810,10 +810,6 @@ static void idxd_device_evl_free(struct idxd_device *idxd)
 	struct device *dev = &idxd->pdev->dev;
 	struct idxd_evl *evl = idxd->evl;
 
-	gencfg.bits = ioread32(idxd->reg_base + IDXD_GENCFG_OFFSET);
-	if (!gencfg.evl_en)
-		return;
-
 	mutex_lock(&evl->lock);
 	gencfg.evl_en = 0;
 	iowrite32(gencfg.bits, idxd->reg_base + IDXD_GENCFG_OFFSET);
Signature · 1 line
2.43.0
maintainer
#1 lore raw

drivers/dma/idxd/device.c static void idxd_device_evl_free(struct idxd_device *idxd) · line 813

Quoted 9 lines · Wenshan Lan

From: Vinicius Costa Gomes <[email protected]>

[ Upstream commit ee66bc29578391c9b48523dc9119af67bd5c7c0f ]

drivers/dma/idxd/device.c +0 -4
-	gencfg.bits = ioread32(idxd->reg_base + IDXD_GENCFG_OFFSET);
-	if (!gencfg.evl_en)
-		return;
-
 	mutex_lock(&evl->lock);

This drops the only thing that protects no-evl-capable hardware (idxd->evl == NULL) from dereferencing evl in idxd_device_evl_free(). On 6.6, idxd_init_evl() returns 0 without allocating evl when hw.gen_cap.evl_support == 0, and idxd_device_evl_free() is still reachable in that path, so taking ee66bc29 alone will introduce a NULL deref on hardware without event-log support.

The required prerequisite is upstream commit 52d2edea0d63c ("dmaengine: idxd: Fix crash when the event log is disabled"), which adds the "if (!evl) return;" guard at the top of idxd_device_evl_free(). It landed as patch 2 of the same v3 series and is missing from 6.6.y.

Could you resend as a 2-patch series with 52d2edea0d63c as the prerequisite? Then I'm happy to queue both for 6.6.y.

--
Thanks,
Sasha

#2 lore raw
Quoted 17 lines · Sasha Levin

drivers/dma/idxd/device.c static void idxd_device_evl_free(struct idxd_device *idxd) · line 813

Quoted 9 lines · Wenshan Lan

From: Vinicius Costa Gomes <[email protected]>

[ Upstream commit ee66bc29578391c9b48523dc9119af67bd5c7c0f ]

drivers/dma/idxd/device.c +0 -4
-	gencfg.bits = ioread32(idxd->reg_base + IDXD_GENCFG_OFFSET);
-	if (!gencfg.evl_en)
-		return;
-
  	mutex_lock(&evl->lock);

This drops the only thing that protects no-evl-capable hardware (idxd->evl == NULL) from dereferencing evl in idxd_device_evl_free(). On 6.6, idxd_init_evl() returns 0 without allocating evl when hw.gen_cap.evl_support == 0, and idxd_device_evl_free() is still reachable in that path, so taking ee66bc29 alone will introduce a NULL deref on hardware without event-log support.

Quoted 7 lines

The required prerequisite is upstream commit 52d2edea0d63c ("dmaengine: idxd: Fix crash when the event log is disabled"), which adds the "if (!evl) return;" guard at the top of idxd_device_evl_free(). It landed as patch 2 of the same v3 series and is missing from 6.6.y.

Could you resend as a 2-patch series with 52d2edea0d63c as the prerequisite? Then I'm happy to queue both for 6.6.y.

Thank you for your review. I will resend v2.

Wenshan Lan

Quoted 4 lines

--
Thanks,
Sasha