* [PATCH] vhost_vdpa: Fix potential underflow in vhost_vdpa_mmap()
@ 2020-06-10 8:58 Dan Carpenter
2020-06-10 9:39 ` Michael S. Tsirkin
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-06-10 8:58 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang; +Cc: kvm, virtualization, kernel-janitors
The "vma->vm_pgoff" variable is an unsigned long so if it's larger than
INT_MAX then "index" can be negative leading to an underflow. Fix this
by changing the type of "index" to "unsigned long".
Fixes: ddd89d0a059d ("vhost_vdpa: support doorbell mapping via mmap")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/vhost/vdpa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 7580e34f76c10..a54b60d6623f0 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -818,7 +818,7 @@ static int vhost_vdpa_mmap(struct file *file, struct vm_area_struct *vma)
struct vdpa_device *vdpa = v->vdpa;
const struct vdpa_config_ops *ops = vdpa->config;
struct vdpa_notification_area notify;
- int index = vma->vm_pgoff;
+ unsigned long index = vma->vm_pgoff;
if (vma->vm_end - vma->vm_start != PAGE_SIZE)
return -EINVAL;
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] vhost_vdpa: Fix potential underflow in vhost_vdpa_mmap()
2020-06-10 8:58 [PATCH] vhost_vdpa: Fix potential underflow in vhost_vdpa_mmap() Dan Carpenter
@ 2020-06-10 9:39 ` Michael S. Tsirkin
0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2020-06-10 9:39 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Jason Wang, kvm, virtualization, kernel-janitors
On Wed, Jun 10, 2020 at 11:58:52AM +0300, Dan Carpenter wrote:
> The "vma->vm_pgoff" variable is an unsigned long so if it's larger than
> INT_MAX then "index" can be negative leading to an underflow. Fix this
> by changing the type of "index" to "unsigned long".
>
> Fixes: ddd89d0a059d ("vhost_vdpa: support doorbell mapping via mmap")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied, thanks!
> ---
> drivers/vhost/vdpa.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 7580e34f76c10..a54b60d6623f0 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -818,7 +818,7 @@ static int vhost_vdpa_mmap(struct file *file, struct vm_area_struct *vma)
> struct vdpa_device *vdpa = v->vdpa;
> const struct vdpa_config_ops *ops = vdpa->config;
> struct vdpa_notification_area notify;
> - int index = vma->vm_pgoff;
> + unsigned long index = vma->vm_pgoff;
>
> if (vma->vm_end - vma->vm_start != PAGE_SIZE)
> return -EINVAL;
> --
> 2.26.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-10 9:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 8:58 [PATCH] vhost_vdpa: Fix potential underflow in vhost_vdpa_mmap() Dan Carpenter
2020-06-10 9:39 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).