lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 13 Apr 2021 10:24:14 +1000
From:   David Gibson <david@...son.dropbear.id.au>
To:     "Christian A. Ehrhardt" <lk@...e.de>
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Alex Williamson <alex.williamson@...hat.com>,
        Alexey Kardashevskiy <aik@...abs.ru>,
        Michael Ellerman <mpe@...erman.id.au>,
        Cornelia Huck <cohuck@...hat.com>
Subject: Re: [PATCH] vfio/pci: Add missing range check in vfio_pci_mmap

On Mon, Apr 12, 2021 at 11:41:24PM +0200, Christian A. Ehrhardt wrote:
> 
> When mmaping an extra device region verify that the region index
> derived from the mmap offset is valid.
> 
> Fixes: a15b1883fee1 ("vfio_pci: Allow mapping extra regions")
> Cc: stable@...r.kernel.org
> Signed-off-by: Christian A. Ehrhardt <lk@...e.de>

Reviewed-by: David Gibson <david@...son.dropbear.id.au>

> ---
>  drivers/vfio/pci/vfio_pci.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 65e7e6b44578..5023e23db3bc 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -1656,6 +1656,8 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
>  
>  	index = vma->vm_pgoff >> (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT);
>  
> +	if (index >= VFIO_PCI_NUM_REGIONS + vdev->num_regions)
> +		return -EINVAL;
>  	if (vma->vm_end < vma->vm_start)
>  		return -EINVAL;
>  	if ((vma->vm_flags & VM_SHARED) == 0)
> @@ -1664,7 +1666,7 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
>  		int regnum = index - VFIO_PCI_NUM_REGIONS;
>  		struct vfio_pci_region *region = vdev->region + regnum;
>  
> -		if (region && region->ops && region->ops->mmap &&
> +		if (region->ops && region->ops->mmap &&
>  		    (region->flags & VFIO_REGION_INFO_FLAG_MMAP))
>  			return region->ops->mmap(vdev, region, vma);
>  		return -EINVAL;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ