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] [day] [month] [year] [list]
Message-ID: <20210406133756.4520772c@omen>
Date:   Tue, 6 Apr 2021 13:37:56 -0600
From:   Alex Williamson <alex.williamson@...hat.com>
To:     Shenming Lu <lushenming@...wei.com>
Cc:     Cornelia Huck <cohuck@...hat.com>, <kvm@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <wanghaibin.wang@...wei.com>,
        <yuzenghui@...wei.com>
Subject: Re: [PATCH v1] vfio/type1: Remove the almost unused check in
 vfio_iommu_type1_unpin_pages

On Tue, 6 Apr 2021 21:50:09 +0800
Shenming Lu <lushenming@...wei.com> wrote:

> The check i > npage at the end of vfio_iommu_type1_unpin_pages is unused
> unless npage < 0, but if npage < 0, this function will return npage, which
> should return -EINVAL instead. So let's just check the parameter npage at
> the start of the function. By the way, replace unpin_exit with break.
> 
> Signed-off-by: Shenming Lu <lushenming@...wei.com>
> ---
>  drivers/vfio/vfio_iommu_type1.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 45cbfd4879a5..fd4213c41743 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -960,7 +960,7 @@ static int vfio_iommu_type1_unpin_pages(void *iommu_data,
>  	bool do_accounting;
>  	int i;
>  
> -	if (!iommu || !user_pfn)
> +	if (!iommu || !user_pfn || npage <= 0)
>  		return -EINVAL;
>  
>  	/* Supported for v2 version only */
> @@ -977,13 +977,13 @@ static int vfio_iommu_type1_unpin_pages(void *iommu_data,
>  		iova = user_pfn[i] << PAGE_SHIFT;
>  		dma = vfio_find_dma(iommu, iova, PAGE_SIZE);
>  		if (!dma)
> -			goto unpin_exit;
> +			break;
> +
>  		vfio_unpin_page_external(dma, iova, do_accounting);
>  	}
>  
> -unpin_exit:
>  	mutex_unlock(&iommu->lock);
> -	return i > npage ? npage : (i > 0 ? i : -EINVAL);
> +	return i > 0 ? i : -EINVAL;
>  }
>  
>  static long vfio_sync_unpin(struct vfio_dma *dma, struct vfio_domain *domain,

Very odd behavior previously.  Applied to vfio next branch for v5.13.
Thanks,

Alex

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ