vfio/mlx5: fix error code in mlx5vf_precopy_ioctl()
Subsystems (5)
PATCH 1/2 vfio/mlx5: fix error code in mlx5vf_precopy_ioctl()
The copy_to_user() function returns the number of bytes remaining to be copied but we want to return a negative error code here.
--- drivers/vfio/pci/mlx5/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/vfio/pci/mlx5/main.c +4 -1
@@ -404,7 +404,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd, done:mlx5vf_state_mutex_unlock (mvdev); -return copy_to_user ((void __user *)arg, &info, minsz); +if (copy_to_user ((void __user *)arg, &info, minsz)) +return -EFAULT ; +return 0 ; + err_migf_unlock:mutex_unlock (&migf->lock); err_state_unlock:
Signature · 1 line
2.35.1
PATCH 2/2 vfio/mlx5: error pointer dereference in error handling
This code frees the wrong "buf" variable and results in an error pointer dereference.
---
Why did get_maintainer.pl not add Yishai to the CC list?
drivers/vfio/pci/mlx5/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/pci/mlx5/main.c +1 -1
@@ -826,7 +826,7 @@ mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev)spin_lock_init (&migf->list_lock);return migf; out_buf: -mlx5vf_free_data_buffer (buf); +mlx5vf_free_data_buffer (migf->buf); out_pd:mlx5vf_cmd_dealloc_pd (migf); out_free:
Signature · 1 line
2.35.1
Re: [PATCH 2/2] vfio/mlx5: error pointer dereference in error handling
Quoted 16 lines · Dan Carpenter
This code frees the wrong "buf" variable and results in an error pointer dereference.
Fixes 34e2f27143d1 ("vfio/mlx5: Introduce multiple loads")Signed-off-by Dan Carpenter <[email protected]>---
Why did get_maintainer.pl not add Yishai to the CC list?drivers/vfio/pci/mlx5/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/vfio/pci/mlx5/main.c +0
-0
drivers/vfio/pci/mlx5/main.c mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev) · line 832
Quoted 8 lines
drivers/vfio/pci/mlx5/main.c +1
-1@@ -826,7 +826,7 @@ mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev)spin_lock_init (&migf->list_lock);return migf; out_buf: -mlx5vf_free_data_buffer (buf); +mlx5vf_free_data_buffer (migf->buf); out_pd:mlx5vf_cmd_dealloc_pd (migf); out_free:
Thanks Dan
Quoted 15 lines · Dan Carpenter
The
copy_to_user()function returns the number of bytes remaining to be copied but we want to return a negative error code here.Fixes 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation")Signed-off-by Dan Carpenter <[email protected]>--- drivers/vfio/pci/mlx5/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/vfio/pci/mlx5/main.c +0
-0@@ -404,7 +404,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd,
drivers/vfio/pci/mlx5/main.c static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd, · line 413
Quoted 10 lines
drivers/vfio/pci/mlx5/main.c +4
-1done:mlx5vf_state_mutex_unlock (mvdev); -return copy_to_user ((void __user *)arg, &info, minsz); +if (copy_to_user ((void __user *)arg, &info, minsz)) +return -EFAULT ; +return 0 ; + err_migf_unlock:mutex_unlock (&migf->lock); err_state_unlock:
Thanks Dan
Alex Williamson
AppliedQuoted 8 lines · On Thu, 8 Dec 2022 19:01:26 +0300 Dan Carpenter <[email protected]> wrote:
The
copy_to_user()function returns the number of bytes remaining to be copied but we want to return a negative error code here.Fixes 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation")Signed-off-by Dan Carpenter <[email protected]>--- drivers/vfio/pci/mlx5/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Applied both to vfio next branch for v6.2. Thanks,
Alex