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: <20221223062832.069595f1.alex.williamson@redhat.com>
Date:   Fri, 23 Dec 2022 06:28:32 -0700
From:   Alex Williamson <alex.williamson@...hat.com>
To:     Li kunyu <kunyu@...china.com>
Cc:     cohuck@...hat.com, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vfio_iommu_type1: increase the validity check of
 function parameters

On Fri, 23 Dec 2022 15:24:18 +0800
Li kunyu <kunyu@...china.com> wrote:

> Added validity check for count variable, return if count variable does 
> not meet the execution condition (do not execute mutex_lock and 
> mutex_unlock function).
> 
> Signed-off-by: Li kunyu <kunyu@...china.com>
> ---
>  drivers/vfio/vfio_iommu_type1.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 23c24fe98c00..9bdf96d932e4 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -3137,6 +3137,9 @@ static int vfio_iommu_type1_dma_rw(void *iommu_data, dma_addr_t user_iova,
>  	int ret = 0;
>  	size_t done;
>  
> +	if (count <= 0)
> +		return ret;
> +
>  	mutex_lock(&iommu->lock);
>  	while (count > 0) {
>  		ret = vfio_iommu_type1_dma_rw_chunk(iommu, user_iova, data,

This is only optimizing a case that shouldn't exist, the return value
is the same.  Callers should be smart enough not to call the function
with such values.  As an internal API, we assume reasonable behavior by
the caller.  Thanks,

Alex

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ