Skip to content

Commit aaca2aa

Browse files
duanzhenzhongjgunthorpe
authored andcommitted
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: 07838f7 ("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>
1 parent 67cb50a commit aaca2aa

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/iommu/iommufd/eventq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,10 @@ static ssize_t iommufd_fault_fops_write(struct file *filep, const char __user *b
187187

188188
mutex_lock(&fault->mutex);
189189
while (count > done) {
190-
rc = copy_from_user(&response, buf + done, response_size);
191-
if (rc)
190+
if (copy_from_user(&response, buf + done, response_size)) {
191+
rc = -EFAULT;
192192
break;
193+
}
193194

194195
static_assert((int)IOMMUFD_PAGE_RESP_SUCCESS ==
195196
(int)IOMMU_PAGE_RESP_SUCCESS);

0 commit comments

Comments
 (0)