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:   Fri, 13 May 2022 14:53:39 +0000
From:   "Michael Kelley (LINUX)" <mikelley@...rosoft.com>
To:     Shradha Gupta <shradhagupta@...rosoft.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>
Subject: RE: [PATCH] hv_balloon: Fix balloon_probe() and balloon_remove()
 error handling

From: Shradha Gupta <shradhagupta@...rosoft.com>
> Sent: Friday, May 13, 2022 3:21 AM
> To: linux-kernel@...r.kernel.org; linux-hyperv@...r.kernel.org
> Subject: [PATCH] hv_balloon: Fix balloon_probe() and balloon_remove() error handling
> 
> <haiyangz@...rosoft.com>, Stephen Hemminger <sthemmin@...rosoft.com>,
> Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>
> 
> Add missing cleanup in balloon_probe() if the call to
> balloon_connect_vsp() fails.  Also correctly handle cleanup in
> balloon_remove() when dm_state is DM_INIT_ERROR because
> balloon_resume() failed.
> 
> Signed-off-by: Shradha Gupta <shradhagupta@...rosoft.com>
> ---
>  drivers/hv/hv_balloon.c | 21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 

I think these changes look good now, but there are some
formatting and process problems with this patch email.  Let me
get with you offline on the details.

Michael


> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
> index eee7402cfc02..98fcfb516bbc 100644
> --- a/drivers/hv/hv_balloon.c
> +++ b/drivers/hv/hv_balloon.c
> @@ -1842,7 +1842,7 @@ static int balloon_probe(struct hv_device *dev,
> 
>  	ret = balloon_connect_vsp(dev);
>  	if (ret != 0)
> -		return ret;
> +		goto connect_error;
> 
>  	enable_page_reporting();
>  	dm_device.state = DM_INITIALIZED;
> @@ -1861,6 +1861,7 @@ static int balloon_probe(struct hv_device *dev,
>  	dm_device.thread  = NULL;
>  	disable_page_reporting();
>  	vmbus_close(dev->channel);
> +connect_error:
>  #ifdef CONFIG_MEMORY_HOTPLUG
>  	unregister_memory_notifier(&hv_memory_nb);
>  	restore_online_page_callback(&hv_online_page);
> @@ -1882,12 +1883,21 @@ static int balloon_remove(struct hv_device *dev)
>  	cancel_work_sync(&dm->ha_wrk.wrk);
> 
>  	kthread_stop(dm->thread);
> -	disable_page_reporting();
> -	vmbus_close(dev->channel);
> +
> +	/*
> +	 * This is to handle the case when balloon_resume()
> +	 * call has failed and some cleanup has been done as
> +	 * a part of the error handling.
> +	 */
> +	if (dm_device.state != DM_INIT_ERROR) {
> +		disable_page_reporting();
> +		vmbus_close(dev->channel);
>  #ifdef CONFIG_MEMORY_HOTPLUG
> -	unregister_memory_notifier(&hv_memory_nb);
> -	restore_online_page_callback(&hv_online_page);
> +		unregister_memory_notifier(&hv_memory_nb);
> +		restore_online_page_callback(&hv_online_page);
>  #endif
> +	}
> +
>  	spin_lock_irqsave(&dm_device.ha_lock, flags);
>  	list_for_each_entry_safe(has, tmp, &dm->ha_region_list, list) {
>  		list_for_each_entry_safe(gap, tmp_gap, &has->gap_list, list) {
> @@ -1948,6 +1958,7 @@ static int balloon_resume(struct hv_device *dev)
>  	vmbus_close(dev->channel);
>  out:
>  	dm_device.state = DM_INIT_ERROR;
> +	disable_page_reporting();
>  #ifdef CONFIG_MEMORY_HOTPLUG
>  	unregister_memory_notifier(&hv_memory_nb);
>  	restore_online_page_callback(&hv_online_page);
> --
> 2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ