Skip to contentSkip to conversation

dmaengine: idxd: Fix allowing write() from different address spaces

PATCH Applied Dave Jiang 2 participants 2 messages Apr 21, 2025 – Apr 24, 2025

Subsystems (2)
lore
Share & tools
lore

Dave Jiang

author reviewer
#0 lore raw

PATCH v2 1/1 dmaengine: idxd: Fix allowing write() from different address spaces

From: Vinicius Costa Gomes <[email protected]>

Check if the process submitting the descriptor belongs to the same address space as the one that opened the file, reject otherwise.

Fixes 6827738dc684 ("dmaengine: idxd: add a write() method for applications to submit work")

---
v2:
- Add check also for mmap() and poll(). (Nathan)

---
 drivers/dma/idxd/cdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/dma/idxd/cdev.c +9 -0
index ff94ee892339..b847b74949f1 100644
@@ -407,6 +407,9 @@ static int idxd_cdev_mmap(struct file *filp, struct vm_area_struct *vma)
 	if (!idxd->user_submission_safe && !capable(CAP_SYS_RAWIO))
 		return -EPERM;
 
+	if (current->mm != ctx->mm)
+		return -EPERM;
+
 	rc = check_vma(wq, vma, __func__);
 	if (rc < 0)
 		return rc;
@@ -473,6 +476,9 @@ static ssize_t idxd_cdev_write(struct file *filp, const char __user *buf, size_t
 	ssize_t written = 0;
 	int i;
 
+	if (current->mm != ctx->mm)
+		return -EPERM;
+
 	for (i = 0; i < len/sizeof(struct dsa_hw_desc); i++) {
 		int rc = idxd_submit_user_descriptor(ctx, udesc + i);
 
@@ -493,6 +499,9 @@ static __poll_t idxd_cdev_poll(struct file *filp,
 	struct idxd_device *idxd = wq->idxd;
 	__poll_t out = 0;
 
+	if (current->mm != ctx->mm)
+		return -EPERM;
+
 	poll_wait(filp, &wq->err_queue, wait);
 	spin_lock(&idxd->dev_lock);
 	if (idxd->sw_err.valid)
Signature · 1 line
2.49.0
maintainer Applied
#1 lore raw
Quoted 4 lines · Dave Jiang

Check if the process submitting the descriptor belongs to the same address space as the one that opened the file, reject otherwise.

Applied, thanks!

[1/1] dmaengine: idxd: Fix allowing write() from different address spaces

      commit: 8dfa57aabff625bf445548257f7711ef294cd30e

Best regards,

Signature · 1 line
~Vinod