RE: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

From: Tian, Kevin
Date: Thu Feb 18 2021 - 20:47:47 EST


> From: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Sent: Wednesday, February 17, 2021 5:33 AM
>
> On Tue, Feb 16, 2021 at 12:04:55PM -0700, Dave Jiang wrote:
>
> > > > + return remap_pfn_range(vma, vma->vm_start, pgoff, req_size,
> pg_prot);
> > > Nothing validated req_size - did you copy this from the Intel RDMA
> > > driver? It had a huge security bug just like this.
>
> > Thanks. Will add. Some of the code came from the Intel i915 mdev
> > driver.
>
> Please make sure it is fixed as well, the security bug is huge.
>

It's already been fixed 2yrs ago:

commit 51b00d8509dc69c98740da2ad07308b630d3eb7d
Author: Zhenyu Wang <zhenyuw@xxxxxxxxxxxxxxx>
Date: Fri Jan 11 13:58:53 2019 +0800

drm/i915/gvt: Fix mmap range check

This is to fix missed mmap range check on vGPU bar2 region
and only allow to map vGPU allocated GMADDR range, which means
user space should support sparse mmap to get proper offset for
mmap vGPU aperture. And this takes care of actual pgoff in mmap
request as original code always does from beginning of vGPU
aperture.

Fixes: 659643f7d814 ("drm/i915/gvt/kvmgt: add vfio/mdev support to KVMGT")
Cc: "Monroy, Rodrigo Axel" <rodrigo.axel.monroy@xxxxxxxxx>
Cc: "Orrala Contreras, Alfredo" <alfredo.orrala.contreras@xxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # v4.10+
Reviewed-by: Hang Yuan <hang.yuan@xxxxxxxxx>
Signed-off-by: Zhenyu Wang <zhenyuw@xxxxxxxxxxxxxxx>

Thanks
Kevin