DMA Engine development
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Nathan Lynch <nathan.lynch@amd.com>,
	Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	Vinod Koul <vkoul@kernel.org>,
	Arjan van de Ven <arjan@linux.intel.com>,
	Nikhil Rao <nikhil.rao@intel.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] dmaengine: idxd: Fix allowing write() from different address spaces
Date: Mon, 21 Apr 2025 08:57:54 -0700	[thread overview]
Message-ID: <90296464-fec1-4885-a8bb-0f1fd21b6dab@intel.com> (raw)
In-Reply-To: <87mscgkuqf.fsf@AUSNATLYNCH.amd.com>



On 4/16/25 8:10 AM, Nathan Lynch wrote:
> Vinicius Costa Gomes <vinicius.gomes@intel.com> writes:
>> 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?

Seems reasonable. Vinicius is on sabbatical. I'll respin his code and add the suggested checks. Thanks Nathan.

DJ

> 
>>
>> Fixes: 6827738dc684 ("dmaengine: idxd: add a write() method for applications to submit work")
>> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>> ---
>>  drivers/dma/idxd/cdev.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
>> index ff94ee892339..373c622fcddc 100644
>> --- a/drivers/dma/idxd/cdev.c
>> +++ b/drivers/dma/idxd/cdev.c
>> @@ -473,6 +473,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);
>>  
>> -- 
>> 2.49.0


      reply	other threads:[~2025-04-21 15:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16  2:52 [PATCH v1] dmaengine: idxd: Fix allowing write() from different address spaces Vinicius Costa Gomes
2025-04-16 14:52 ` Dave Jiang
2025-04-16 15:10 ` Nathan Lynch
2025-04-21 15:57   ` Dave Jiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90296464-fec1-4885-a8bb-0f1fd21b6dab@intel.com \
    --to=dave.jiang@intel.com \
    --cc=arjan@linux.intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan.lynch@amd.com \
    --cc=nikhil.rao@intel.com \
    --cc=vinicius.gomes@intel.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox