dmaengine: idxd: Fix allowing write() from different address spaces
Subsystems (2)
Vinicius Costa Gomes
maintainerPATCH 1/1 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.
--- drivers/dma/idxd/cdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dma/idxd/cdev.c +3 -0
@@ -473,6 +473,9 @@ static ssize_t idxd_cdev_write(struct file *filp, const char __user *buf, size_tssize_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);
Signature · 1 line
2.49.0
Quoted 5 lines · Vinicius Costa Gomes
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 <[email protected]>
Quoted 18 lines
--- drivers/dma/idxd/cdev.c | 3 +++ 1 file changed, 3 insertions(+)drivers/dma/idxd/cdev.c +3
-0@@ -473,6 +473,9 @@ static ssize_t idxd_cdev_write(struct file *filp, const char __user *buf, size_tssize_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);
Quoted 2 lines · Vinicius Costa Gomes
Check if the process submitting the descriptor belongs to the same address space as the one that opened the file, reject otherwise.
I assume this can happen after a fork.
Do idxd_cdev_mmap() and idxd_cdev_poll() need similar protection?
Quoted 23 lines
Fixes 6827738dc684 ("dmaengine: idxd: add a write() method for applications to submit work")Signed-off-by Vinicius Costa Gomes <[email protected]>--- drivers/dma/idxd/cdev.c | 3 +++ 1 file changed, 3 insertions(+)drivers/dma/idxd/cdev.c +3
-0@@ -473,6 +473,9 @@ static ssize_t idxd_cdev_write(struct file *filp, const char __user *buf, size_tssize_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);Signature · 1 line
2.49.0
Dave Jiang
reviewerQuoted 7 lines · Nathan Lynch
Quoted 2 lines · Vinicius Costa Gomes
Check if the process submitting the descriptor belongs to the same address space as the one that opened the file, reject otherwise.
I assume this can happen after a fork.
Do
idxd_cdev_mmap()andidxd_cdev_poll()need similar protection?
Seems reasonable. Vinicius is on sabbatical. I'll respin his code and add the suggested checks. Thanks Nathan.
DJ
Quoted 24 lines
Quoted 24 lines
Fixes 6827738dc684 ("dmaengine: idxd: add a write() method for applications to submit work")Signed-off-by Vinicius Costa Gomes <[email protected]>--- drivers/dma/idxd/cdev.c | 3 +++ 1 file changed, 3 insertions(+)drivers/dma/idxd/cdev.c +3
-0@@ -473,6 +473,9 @@ static ssize_t idxd_cdev_write(struct file *filp, const char __user *buf, size_tssize_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);Signature · 1 line
2.49.0