public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Diana Craciun OSS <diana.craciun@oss.nxp.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/2] vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap()
Date: Tue, 3 Nov 2020 14:03:08 +0200	[thread overview]
Message-ID: <de18ce14-9138-dcc4-253f-fa50d63b3ae2@oss.nxp.com> (raw)
In-Reply-To: <20201023112947.GF282278@mwanda>

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);
>   
> 


      parent reply	other threads:[~2020-11-03 12:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de18ce14-9138-dcc4-253f-fa50d63b3ae2@oss.nxp.com \
    --to=diana.craciun@oss.nxp.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox