From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [bug report] vfio: hugepage support for vfio_iommu_type1
Date: Thu, 12 Oct 2017 19:54:29 +0300 [thread overview]
Message-ID: <20171012165248.3odwh37pkovwiodq@mwanda> (raw)
In-Reply-To: <20171012103241.297ab5a8@t450s.home>
On Thu, Oct 12, 2017 at 10:32:41AM -0600, Alex Williamson wrote:
> Hi Dan,
>
> On Thu, 12 Oct 2017 15:40:36 +0300
> Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> > Hello Alex Williamson,
> >
> > The patch 166fd7d94afd: "vfio: hugepage support for vfio_iommu_type1"
> > from Jun 21, 2013, leads to the following static checker warning:
> >
> > drivers/vfio/vfio_iommu_type1.c:819 vfio_dma_do_unmap()
> > warn: overflowed symbol reused: 'unmap->size'
> >
> > drivers/vfio/vfio_iommu_type1.c
> > 756 static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
> > 757 struct vfio_iommu_type1_dma_unmap *unmap)
> > 758 {
> > 759 uint64_t mask;
> > 760 struct vfio_dma *dma, *dma_last = NULL;
> > 761 size_t unmapped = 0;
> > 762 int ret = 0, retries = 0;
> > 763
> > 764 mask = ((uint64_t)1 << __ffs(vfio_pgsize_bitmap(iommu))) - 1;
> > 765
> > 766 if (unmap->iova & mask)
> > 767 return -EINVAL;
> > 768 if (!unmap->size || unmap->size & mask)
> > 769 return -EINVAL;
> >
> > unmap is controlled by the user from the ioctl. ->iova and ->size are
> > type u64. It would be simple enough to add an integer overflow check
> > here, but I'd be tempted to do something like:
> >
> > if (unmap->size + unmap->iova < unmap->size ||
> > unmap->size + unmap->iova > SIZE_MAX)
> > return -EINVAL;
> >
> > Because below we are passing it to vfio_find_dma() which only takes a
> > size_t and not a u64.
>
> Ok, but why test unmap->iova + unmap->size relative to SIZE_MAX rather
> than just unmap->size since we use a dma_addr_t for the iova in
> vfio_find_dma()?
Oh, yeah, you're right. I misread the code a bit. I'll send a check
for that then.
regards,
dan carpenter
prev parent reply other threads:[~2017-10-12 16:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 12:40 [bug report] vfio: hugepage support for vfio_iommu_type1 Dan Carpenter
2017-10-12 16:32 ` Alex Williamson
2017-10-12 16:54 ` Dan Carpenter [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=20171012165248.3odwh37pkovwiodq@mwanda \
--to=dan.carpenter@oracle.com \
--cc=alex.williamson@redhat.com \
--cc=kvm@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