public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Shuai Xue <xueshuai@linux.alibaba.com>
To: Zhenzhong Duan <zhenzhong.duan@intel.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: jgg@ziepe.ca, kevin.tian@intel.com, joro@8bytes.org,
	will@kernel.org, robin.murphy@arm.com, baolu.lu@linux.intel.com,
	stable@vger.kernel.org
Subject: Re: [PATCH] iommufd: Fix return value of iommufd_fault_fops_write()
Date: Mon, 30 Mar 2026 14:27:44 +0800	[thread overview]
Message-ID: <9bd1cd45-df2d-45a3-ab9e-1668310e9ac4@linux.alibaba.com> (raw)
In-Reply-To: <20260330030755.12856-1-zhenzhong.duan@intel.com>



On 3/30/26 11:07 AM, Zhenzhong Duan wrote:
> copy_from_user() may return number of bytes failed to copy, we should
> not pass over this number to user space to cheat that write() succeed.
> Instead, -EFAULT should be returned.
> 
> Cc: stable@vger.kernel.org
> Fixes: 07838f7fd529 ("iommufd: Add iommufd fault object")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>   drivers/iommu/iommufd/eventq.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/iommufd/eventq.c b/drivers/iommu/iommufd/eventq.c
> index f1e686b3a265..710eef0b6004 100644
> --- a/drivers/iommu/iommufd/eventq.c
> +++ b/drivers/iommu/iommufd/eventq.c
> @@ -187,9 +187,10 @@ static ssize_t iommufd_fault_fops_write(struct file *filep, const char __user *b
>   
>   	mutex_lock(&fault->mutex);
>   	while (count > done) {
> -		rc = copy_from_user(&response, buf + done, response_size);
> -		if (rc)
> +		if (copy_from_user(&response, buf + done, response_size)) {
> +			rc = -EFAULT;
>   			break;
> +		}
>   
>   		static_assert((int)IOMMUFD_PAGE_RESP_SUCCESS ==
>   			      (int)IOMMU_PAGE_RESP_SUCCESS);

Good catch.

Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>

Thanks.
Shuai

  reply	other threads:[~2026-03-30  6:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30  3:07 [PATCH] iommufd: Fix return value of iommufd_fault_fops_write() Zhenzhong Duan
2026-03-30  6:27 ` Shuai Xue [this message]
2026-03-30  9:38 ` Pranjal Shrivastava
2026-03-31  7:46 ` Tian, Kevin
2026-03-31 16:25 ` Jason Gunthorpe

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=9bd1cd45-df2d-45a3-ab9e-1668310e9ac4@linux.alibaba.com \
    --to=xueshuai@linux.alibaba.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=will@kernel.org \
    --cc=zhenzhong.duan@intel.com \
    /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