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]
Date:   Tue, 21 Jun 2022 11:32:21 -0600
From:   Alex Williamson <alex.williamson@...hat.com>
To:     Bo Liu <liubo03@...pur.com>
Cc:     <cohuck@...hat.com>, <kvm@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] vfio: check vfio_register_iommu_driver() return value

On Tue, 21 Jun 2022 02:21:12 -0400
Bo Liu <liubo03@...pur.com> wrote:

> As vfio_register_iommu_driver() can fail, we should check the return value.
> 
> Signed-off-by: Bo Liu <liubo03@...pur.com>
> ---
>  drivers/vfio/vfio.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> index 61e71c1154be..7d4b6dfafd27 100644
> --- a/drivers/vfio/vfio.c
> +++ b/drivers/vfio/vfio.c
> @@ -2159,10 +2159,16 @@ static int __init vfio_init(void)
>  	pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");

If we're going to acknowledge that the below can fail, then we should
move the pr_info so that we only advertise that vfio has loaded after
all potential failure points.

>  
>  #ifdef CONFIG_VFIO_NOIOMMU
> -	vfio_register_iommu_driver(&vfio_noiommu_ops);
> +	ret = vfio_register_iommu_driver(&vfio_noiommu_ops);
> +	if (ret)
> +		goto err_driver_register;
>  #endif

We could move this #endif above the ret test so that the goto exists
outside of the #ifdef, then we don't need to wrap the goto target in
#ifdefs below.  Thanks,

Alex

>  	return 0;
>  
> +#ifdef CONFIG_VFIO_NOIOMMU
> +err_driver_register:
> +	unregister_chrdev_region(vfio.group_devt, MINORMASK + 1);
> +#endif
>  err_alloc_chrdev:
>  	class_destroy(vfio.class);
>  	vfio.class = NULL;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ