Skip to content

Commit 9283b73

Browse files
gcabidduawilliam
authored andcommitted
vfio/qat: fix overflow check in qat_vf_resume_write()
The unsigned variable `size_t len` is cast to the signed type `loff_t` when passed to the function check_add_overflow(). This function considers the type of the destination, which is of type loff_t (signed), potentially leading to an overflow. This issue is similar to the one described in the link below. Remove the cast. Note that even if check_add_overflow() is bypassed, by setting `len` to a value that is greater than LONG_MAX (which is considered as a negative value after the cast), the function copy_from_user(), invoked a few lines later, will not perform any copy and return `len` as (len > INT_MAX) causing qat_vf_resume_write() to fail with -EFAULT. Fixes: bb20881 ("vfio/qat: Add vfio_pci driver for Intel QAT SR-IOV VF devices") CC: [email protected] # 6.10+ Link: https://lore.kernel.org/all/[email protected] Reported-by: Zijie Zhao <[email protected]> Signed-off-by: Giovanni Cabiddu <[email protected]> Reviewed-by: Xin Zeng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent 12cd88a commit 9283b73

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/vfio/pci/qat/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static ssize_t qat_vf_resume_write(struct file *filp, const char __user *buf,
304304
offs = &filp->f_pos;
305305

306306
if (*offs < 0 ||
307-
check_add_overflow((loff_t)len, *offs, &end))
307+
check_add_overflow(len, *offs, &end))
308308
return -EOVERFLOW;
309309

310310
if (end > mig_dev->state_size)

0 commit comments

Comments
 (0)