public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Diana Craciun <diana.craciun@oss.nxp.com>
Cc: Dan Carpenter <dan.carpenter@oracle.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: Mon, 2 Nov 2020 14:45:38 -0700	[thread overview]
Message-ID: <20201102144538.2871369d@w520.home> (raw)
In-Reply-To: <20201023112947.GF282278@mwanda>


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


  reply	other threads:[~2020-11-02 21:45 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 [this message]
2020-11-03 12:03 ` Diana Craciun OSS

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=20201102144538.2871369d@w520.home \
    --to=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=diana.craciun@oss.nxp.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