Skip to content

Commit 8dfa57a

Browse files
vcgomesvinodkoul
authored andcommitted
dmaengine: idxd: Fix allowing write() from different address spaces
Check if the process submitting the descriptor belongs to the same address space as the one that opened the file, reject otherwise. Fixes: 6827738 ("dmaengine: idxd: add a write() method for applications to submit work") Signed-off-by: Vinicius Costa Gomes <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent fca2809 commit 8dfa57a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/dma/idxd/cdev.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ static int idxd_cdev_mmap(struct file *filp, struct vm_area_struct *vma)
407407
if (!idxd->user_submission_safe && !capable(CAP_SYS_RAWIO))
408408
return -EPERM;
409409

410+
if (current->mm != ctx->mm)
411+
return -EPERM;
412+
410413
rc = check_vma(wq, vma, __func__);
411414
if (rc < 0)
412415
return rc;
@@ -473,6 +476,9 @@ static ssize_t idxd_cdev_write(struct file *filp, const char __user *buf, size_t
473476
ssize_t written = 0;
474477
int i;
475478

479+
if (current->mm != ctx->mm)
480+
return -EPERM;
481+
476482
for (i = 0; i < len/sizeof(struct dsa_hw_desc); i++) {
477483
int rc = idxd_submit_user_descriptor(ctx, udesc + i);
478484

@@ -493,6 +499,9 @@ static __poll_t idxd_cdev_poll(struct file *filp,
493499
struct idxd_device *idxd = wq->idxd;
494500
__poll_t out = 0;
495501

502+
if (current->mm != ctx->mm)
503+
return -EPERM;
504+
496505
poll_wait(filp, &wq->err_queue, wait);
497506
spin_lock(&idxd->dev_lock);
498507
if (idxd->sw_err.valid)

0 commit comments

Comments
 (0)