All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu@kernel.org>
To: "Michael Kelley (LINUX)" <mikelley@microsoft.com>
Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"kexec@lists.infradead.org" <kexec@lists.infradead.org>,
	"kernel@gpiccoli.net" <kernel@gpiccoli.net>,
	Tianyu Lan <Tianyu.Lan@microsoft.com>,
	KY Srinivasan <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	Dexuan Cui <decui@microsoft.com>
Subject: Re: [PATCH] Drivers: hv: vmbus: Fix potential crash on module unload
Date: Tue, 29 Mar 2022 12:05:33 +0000	[thread overview]
Message-ID: <20220329120533.pbmzmq7oqybrtlfd@liuwe-devbox-debian-v2> (raw)
In-Reply-To: <PH0PR21MB302540E78316B06885EBE72AD7149@PH0PR21MB3025.namprd21.prod.outlook.com>

On Sat, Mar 19, 2022 at 03:30:16PM +0000, Michael Kelley (LINUX) wrote:
> From: Guilherme G. Piccoli <gpiccoli@igalia.com> Sent: Tuesday, March 15, 2022 1:36 PM
> > 
> > The vmbus driver relies on the panic notifier infrastructure to perform
> > some operations when a panic event is detected. Since vmbus can be built
> > as module, it is required that the driver handles both registering and
> > unregistering such panic notifier callback.
> > 
> > After commit 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic
> > callback")
> > though, the panic notifier registration is done unconditionally in the module
> > initialization routine whereas the unregistering procedure is conditionally
> > guarded and executes only if HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE capability
> > is set.
> > 
> > This patch fixes that by unconditionally unregistering the panic notifier
> > in the module's exit routine as well.
> > 
> > Fixes: 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callback")
> > Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
> > ---
> > 
> > 
> > Hi folks, thanks in advance for any reviews! This was build-tested
> > with Debian config, on 5.17-rc7.
> > 
> > This patch is a result of code analysis - I didn't experience this
> > issue but seems a valid/feasible case.
> > 
> > Also, this is part of an ongoing effort of clearing/refactoring the panic
> > notifiers, more will be done soon, but I prefer to send the simple bug
> > fixes quickly, or else it might take a while since the next steps are more
> > complex and subject to many iterations I expect.
> > 
> > Cheers,
> > 
> > Guilherme
> > 
> > 
> >  drivers/hv/vmbus_drv.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index 12a2b37e87f3..12585324cc4a 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -2780,10 +2780,15 @@ static void __exit vmbus_exit(void)
> >  	if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
> >  		kmsg_dump_unregister(&hv_kmsg_dumper);
> >  		unregister_die_notifier(&hyperv_die_block);
> > -		atomic_notifier_chain_unregister(&panic_notifier_list,
> > -						 &hyperv_panic_block);
> >  	}
> > 
> > +	/*
> > +	 * The panic notifier is always registered, hence we should
> > +	 * also unconditionally unregister it here as well.
> > +	 */
> > +	atomic_notifier_chain_unregister(&panic_notifier_list,
> > +					 &hyperv_panic_block);
> > +
> >  	free_page((unsigned long)hv_panic_page);
> >  	unregister_sysctl_table(hv_ctl_table_hdr);
> >  	hv_ctl_table_hdr = NULL;
> > --
> > 2.35.1
> 
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> 

Applied to hyperv-fixes. Thanks.

WARNING: multiple messages have this Message-ID (diff)
From: Wei Liu <wei.liu@kernel.org>
To: kexec@lists.infradead.org
Subject: [PATCH] Drivers: hv: vmbus: Fix potential crash on module unload
Date: Tue, 29 Mar 2022 12:05:33 +0000	[thread overview]
Message-ID: <20220329120533.pbmzmq7oqybrtlfd@liuwe-devbox-debian-v2> (raw)
In-Reply-To: <PH0PR21MB302540E78316B06885EBE72AD7149@PH0PR21MB3025.namprd21.prod.outlook.com>

On Sat, Mar 19, 2022 at 03:30:16PM +0000, Michael Kelley (LINUX) wrote:
> From: Guilherme G. Piccoli <gpiccoli@igalia.com> Sent: Tuesday, March 15, 2022 1:36 PM
> > 
> > The vmbus driver relies on the panic notifier infrastructure to perform
> > some operations when a panic event is detected. Since vmbus can be built
> > as module, it is required that the driver handles both registering and
> > unregistering such panic notifier callback.
> > 
> > After commit 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic
> > callback")
> > though, the panic notifier registration is done unconditionally in the module
> > initialization routine whereas the unregistering procedure is conditionally
> > guarded and executes only if HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE capability
> > is set.
> > 
> > This patch fixes that by unconditionally unregistering the panic notifier
> > in the module's exit routine as well.
> > 
> > Fixes: 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callback")
> > Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
> > ---
> > 
> > 
> > Hi folks, thanks in advance for any reviews! This was build-tested
> > with Debian config, on 5.17-rc7.
> > 
> > This patch is a result of code analysis - I didn't experience this
> > issue but seems a valid/feasible case.
> > 
> > Also, this is part of an ongoing effort of clearing/refactoring the panic
> > notifiers, more will be done soon, but I prefer to send the simple bug
> > fixes quickly, or else it might take a while since the next steps are more
> > complex and subject to many iterations I expect.
> > 
> > Cheers,
> > 
> > Guilherme
> > 
> > 
> >  drivers/hv/vmbus_drv.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index 12a2b37e87f3..12585324cc4a 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -2780,10 +2780,15 @@ static void __exit vmbus_exit(void)
> >  	if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
> >  		kmsg_dump_unregister(&hv_kmsg_dumper);
> >  		unregister_die_notifier(&hyperv_die_block);
> > -		atomic_notifier_chain_unregister(&panic_notifier_list,
> > -						 &hyperv_panic_block);
> >  	}
> > 
> > +	/*
> > +	 * The panic notifier is always registered, hence we should
> > +	 * also unconditionally unregister it here as well.
> > +	 */
> > +	atomic_notifier_chain_unregister(&panic_notifier_list,
> > +					 &hyperv_panic_block);
> > +
> >  	free_page((unsigned long)hv_panic_page);
> >  	unregister_sysctl_table(hv_ctl_table_hdr);
> >  	hv_ctl_table_hdr = NULL;
> > --
> > 2.35.1
> 
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> 

Applied to hyperv-fixes. Thanks.


  reply	other threads:[~2022-03-29 12:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 20:35 [PATCH] Drivers: hv: vmbus: Fix potential crash on module unload Guilherme G. Piccoli
2022-03-15 20:35 ` Guilherme G. Piccoli
2022-03-19 15:30 ` Michael Kelley (LINUX)
2022-03-19 15:30   ` Michael Kelley
2022-03-29 12:05   ` Wei Liu [this message]
2022-03-29 12:05     ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220329120533.pbmzmq7oqybrtlfd@liuwe-devbox-debian-v2 \
    --to=wei.liu@kernel.org \
    --cc=Tianyu.Lan@microsoft.com \
    --cc=decui@microsoft.com \
    --cc=gpiccoli@igalia.com \
    --cc=haiyangz@microsoft.com \
    --cc=kernel@gpiccoli.net \
    --cc=kexec@lists.infradead.org \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=sthemmin@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.