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, 23 Mar 2021 11:28:38 +0000
From:   Wei Liu <wei.liu@...nel.org>
To:     Lv Yunlong <lyl2019@...l.ustc.edu.cn>
Cc:     kys@...rosoft.com, haiyangz@...rosoft.com, sthemmin@...rosoft.com,
        wei.liu@...nel.org, linux-hyperv@...r.kernel.org,
        dri-devel@...ts.freedesktop.org, linux-fbdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] video/fbdev: Fix a double free in hvfb_probe

Thanks for your patch.

I would like to change the prefix to "video: hyperv_fb:" to be more
specific.

On Tue, Mar 23, 2021 at 12:33:50AM -0700, Lv Yunlong wrote:
> In function hvfb_probe in hyperv_fb.c, it calls hvfb_getmem(hdev, info)
> and return err when info->apertures is freed.
> 
> In the error1 label of hvfb_probe, info->apertures will be freed twice
> by framebuffer_release(info).
> 

I would say "freed for the second time" here. What you wrote reads to me
fraembuffer_release frees the buffer twice all by itself.

> My patch sets info->apertures to NULL after it was freed to avoid
> double free.
> 

I think this approach works. I would like to give other people a chance
to comment though.

Fixes: 3a6fb6c4255c ("video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.")

> Signed-off-by: Lv Yunlong <lyl2019@...l.ustc.edu.cn>
> ---
>  drivers/video/fbdev/hyperv_fb.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
> index c8b0ae676809..2fc9b507e73a 100644
> --- a/drivers/video/fbdev/hyperv_fb.c
> +++ b/drivers/video/fbdev/hyperv_fb.c
> @@ -1032,6 +1032,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
>  		if (!pdev) {
>  			pr_err("Unable to find PCI Hyper-V video\n");
>  			kfree(info->apertures);
> +			info->apertures = NULL;
>  			return -ENODEV;
>  		}
>  
> @@ -1130,6 +1131,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
>  		pci_dev_put(pdev);
>  	}
>  	kfree(info->apertures);
> +	info->apertures = NULL;
>  
>  	return 0;
>  
> @@ -1142,6 +1144,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
>  	if (!gen2vm)
>  		pci_dev_put(pdev);
>  	kfree(info->apertures);
> +	info->apertures = NULL;
>  
>  	return -ENOMEM;
>  }
> -- 
> 2.25.1
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ