DMA Engine development
 help / color / mirror / Atom feed
* [PATCH v2] dmaengine: idxd: Fix allowing write() from different address spaces
@ 2025-04-21 17:03 Dave Jiang
  2025-04-24  5:36 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Jiang @ 2025-04-21 17:03 UTC (permalink / raw)
  To: dmaengine; +Cc: vinicius.gomes, vkoul, arjan, nathan.lynch

From: Vinicius Costa Gomes <vinicius.gomes@intel.com>

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")
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
v2:
- Add check also for mmap() and poll(). (Nathan)
---
 drivers/dma/idxd/cdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
index ff94ee892339..b847b74949f1 100644
--- a/drivers/dma/idxd/cdev.c
+++ b/drivers/dma/idxd/cdev.c
@@ -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)
-- 
2.49.0


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

* Re: [PATCH v2] dmaengine: idxd: Fix allowing write() from different address spaces
  2025-04-21 17:03 [PATCH v2] dmaengine: idxd: Fix allowing write() from different address spaces Dave Jiang
@ 2025-04-24  5:36 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2025-04-24  5:36 UTC (permalink / raw)
  To: dmaengine, Dave Jiang; +Cc: vinicius.gomes, arjan, nathan.lynch


On Mon, 21 Apr 2025 10:03:37 -0700, Dave Jiang wrote:
> 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,
-- 
~Vinod



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

end of thread, other threads:[~2025-04-24  5:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 17:03 [PATCH v2] dmaengine: idxd: Fix allowing write() from different address spaces Dave Jiang
2025-04-24  5:36 ` Vinod Koul

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