[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200310184720.GD38440@redhat.com>
Date: Tue, 10 Mar 2020 14:47:20 -0400
From: Vivek Goyal <vgoyal@...hat.com>
To: "Michael S. Tsirkin" <mst@...hat.com>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-nvdimm@...ts.01.org, virtio-fs@...hat.com, miklos@...redi.hu,
stefanha@...hat.com, dgilbert@...hat.com,
Sebastien Boeuf <sebastien.boeuf@...el.com>,
kbuild test robot <lkp@...el.com>
Subject: Re: [PATCH 04/20] virtio: Implement get_shm_region for PCI transport
On Tue, Mar 10, 2020 at 07:12:25AM -0400, Michael S. Tsirkin wrote:
[..]
> > +static bool vp_get_shm_region(struct virtio_device *vdev,
> > + struct virtio_shm_region *region, u8 id)
> > +{
> > + struct virtio_pci_device *vp_dev = to_vp_device(vdev);
> > + struct pci_dev *pci_dev = vp_dev->pci_dev;
> > + u8 bar;
> > + u64 offset, len;
> > + phys_addr_t phys_addr;
> > + size_t bar_len;
> > + int ret;
> > +
> > + if (!virtio_pci_find_shm_cap(pci_dev, id, &bar, &offset, &len)) {
> > + return false;
> > + }
> > +
> > + ret = pci_request_region(pci_dev, bar, "virtio-pci-shm");
> > + if (ret < 0) {
> > + dev_err(&pci_dev->dev, "%s: failed to request BAR\n",
> > + __func__);
> > + return false;
> > + }
> > +
> > + phys_addr = pci_resource_start(pci_dev, bar);
> > + bar_len = pci_resource_len(pci_dev, bar);
> > +
> > + if (offset + len > bar_len) {
> > + dev_err(&pci_dev->dev,
> > + "%s: bar shorter than cap offset+len\n",
> > + __func__);
> > + return false;
> > + }
> > +
>
> Something wrong with indentation here.
Will fix all indentation related issues in this patch.
> Also as long as you are validating things, it's worth checking
> offset + len does not overflow.
Something like addition of following lines?
+ if ((offset + len) < offset) {
+ dev_err(&pci_dev->dev, "%s: cap offset+len overflow detected\n",
+ __func__);
+ return false;
+ }
Vivek
Powered by blists - more mailing lists