* [PATCH 2/2] vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap()
@ 2020-10-23 11:29 Dan Carpenter
2020-11-02 21:45 ` Alex Williamson
2020-11-03 12:03 ` Diana Craciun OSS
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-10-23 11:29 UTC (permalink / raw)
To: Diana Craciun
Cc: Alex Williamson, Cornelia Huck, kvm, linux-kernel, kernel-janitors
My static analsysis tool complains that the "index" can be negative.
There are some checks in do_mmap() which try to prevent underflows but
I don't know if they are sufficient for this situation. Either way,
making "index" unsigned is harmless so let's do it just to be safe.
Fixes: 67247289688d ("vfio/fsl-mc: Allow userspace to MMAP fsl-mc device MMIO regions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/vfio/fsl-mc/vfio_fsl_mc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
index 21f22e3da11f..f27e25112c40 100644
--- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
+++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
@@ -472,7 +472,7 @@ static int vfio_fsl_mc_mmap(void *device_data, struct vm_area_struct *vma)
{
struct vfio_fsl_mc_device *vdev = device_data;
struct fsl_mc_device *mc_dev = vdev->mc_dev;
- int index;
+ unsigned int index;
index = vma->vm_pgoff >> (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT);
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap()
2020-10-23 11:29 [PATCH 2/2] vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap() Dan Carpenter
@ 2020-11-02 21:45 ` Alex Williamson
2020-11-03 12:03 ` Diana Craciun OSS
1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2020-11-02 21:45 UTC (permalink / raw)
To: Diana Craciun
Cc: Dan Carpenter, Cornelia Huck, kvm, linux-kernel, kernel-janitors
Hi Diana, same for this one. Thanks,
Alex
On Fri, 23 Oct 2020 14:29:47 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> My static analsysis tool complains that the "index" can be negative.
> There are some checks in do_mmap() which try to prevent underflows but
> I don't know if they are sufficient for this situation. Either way,
> making "index" unsigned is harmless so let's do it just to be safe.
>
> Fixes: 67247289688d ("vfio/fsl-mc: Allow userspace to MMAP fsl-mc device MMIO regions")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/vfio/fsl-mc/vfio_fsl_mc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> index 21f22e3da11f..f27e25112c40 100644
> --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> @@ -472,7 +472,7 @@ static int vfio_fsl_mc_mmap(void *device_data, struct vm_area_struct *vma)
> {
> struct vfio_fsl_mc_device *vdev = device_data;
> struct fsl_mc_device *mc_dev = vdev->mc_dev;
> - int index;
> + unsigned int index;
>
> index = vma->vm_pgoff >> (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap()
2020-10-23 11:29 [PATCH 2/2] vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap() Dan Carpenter
2020-11-02 21:45 ` Alex Williamson
@ 2020-11-03 12:03 ` Diana Craciun OSS
1 sibling, 0 replies; 3+ messages in thread
From: Diana Craciun OSS @ 2020-11-03 12:03 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alex Williamson, Cornelia Huck, kvm, linux-kernel, kernel-janitors
Acked-by: Diana Craciun <diana.craciun@oss.nxp.com>
On 10/23/2020 2:29 PM, Dan Carpenter wrote:
> My static analsysis tool complains that the "index" can be negative.
> There are some checks in do_mmap() which try to prevent underflows but
> I don't know if they are sufficient for this situation. Either way,
> making "index" unsigned is harmless so let's do it just to be safe.
>
> Fixes: 67247289688d ("vfio/fsl-mc: Allow userspace to MMAP fsl-mc device MMIO regions")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/vfio/fsl-mc/vfio_fsl_mc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> index 21f22e3da11f..f27e25112c40 100644
> --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> @@ -472,7 +472,7 @@ static int vfio_fsl_mc_mmap(void *device_data, struct vm_area_struct *vma)
> {
> struct vfio_fsl_mc_device *vdev = device_data;
> struct fsl_mc_device *mc_dev = vdev->mc_dev;
> - int index;
> + unsigned int index;
>
> index = vma->vm_pgoff >> (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT);
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-03 12:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23 11:29 [PATCH 2/2] vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap() Dan Carpenter
2020-11-02 21:45 ` Alex Williamson
2020-11-03 12:03 ` Diana Craciun OSS
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).