kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: kvm@vger.kernel.org, Colin Xu <colin.xu@gmail.com>,
	Dmitry Torokhov <dtor@chromium.org>,
	"Xu, Terrence" <terrence.xu@intel.com>,
	"Gao, Fred" <fred.gao@intel.com>
Subject: Re: [PATCH] vfio/pci: Fix OpRegion read
Date: Tue, 30 Nov 2021 12:30:21 -0700	[thread overview]
Message-ID: <20211130123021.2c4dd788.alex.williamson@redhat.com> (raw)
In-Reply-To: <20211125051328.3359902-1-zhenyuw@linux.intel.com>

On Thu, 25 Nov 2021 13:13:28 +0800
Zhenyu Wang <zhenyuw@linux.intel.com> wrote:

> This is to fix incorrect pointer arithmetic which caused wrong
> OpRegion version returned, then VM driver got error to get wanted
> VBT block. We need to be safe to return correct data, so force
> pointer type for byte access.
> 
> Fixes: 49ba1a2976c8 ("vfio/pci: Add OpRegion 2.0+ Extended VBT support.")
> Cc: Colin Xu <colin.xu@gmail.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Dmitry Torokhov <dtor@chromium.org>
> Cc: "Xu, Terrence" <terrence.xu@intel.com>
> Cc: "Gao, Fred" <fred.gao@intel.com>
> Acked-by: Colin Xu <colin.xu@gmail.com>
> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
> ---
>  drivers/vfio/pci/vfio_pci_igd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
> index 56cd551e0e04..dad6eeed5e80 100644
> --- a/drivers/vfio/pci/vfio_pci_igd.c
> +++ b/drivers/vfio/pci/vfio_pci_igd.c
> @@ -98,7 +98,7 @@ static ssize_t vfio_pci_igd_rw(struct vfio_pci_core_device *vdev,
>  			version = cpu_to_le16(0x0201);
>  
>  		if (igd_opregion_shift_copy(buf, &off,
> -					    &version + (pos - OPREGION_VERSION),
> +					    (u8 *)&version + (pos - OPREGION_VERSION),
>  					    &pos, &remaining, bytes))
>  			return -EFAULT;
>  	}
> @@ -121,7 +121,7 @@ static ssize_t vfio_pci_igd_rw(struct vfio_pci_core_device *vdev,
>  					  OPREGION_SIZE : 0);
>  
>  		if (igd_opregion_shift_copy(buf, &off,
> -					    &rvda + (pos - OPREGION_RVDA),
> +					    (u8 *)&rvda + (pos - OPREGION_RVDA),
>  					    &pos, &remaining, bytes))
>  			return -EFAULT;
>  	}

Applied to vfio for-linus branch for v5.16.  Thanks,

Alex


      reply	other threads:[~2021-11-30 19:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19  8:14 [PATCH] vfio/pci: Fix OpRegion read Zhenyu Wang
2021-11-21 14:01 ` Colin Xu
2021-11-24  0:56 ` Colin Xu
2021-11-25  5:13   ` Zhenyu Wang
2021-11-30 19:30     ` Alex Williamson [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=20211130123021.2c4dd788.alex.williamson@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=colin.xu@gmail.com \
    --cc=dtor@chromium.org \
    --cc=fred.gao@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=terrence.xu@intel.com \
    --cc=zhenyuw@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).