mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
iommufd: Fix return value of iommufd_fault_fops_write()
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.
Link: https://patch.msgid.link/r/20260330030755.12856-1-zhenzhong.duan@intel.com
Cc: stable@vger.kernel.org
Fixes: 07838f7fd5 ("iommufd: Add iommufd fault object")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
67cb50aee0
commit
aaca2aa927
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user