Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Drivers: hv: vmbus: Fix potential crash on module unload

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>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20220315203535.682306-1-gpiccoli@igalia.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Guilherme G. Piccoli and committed by
Wei Liu
792f232d 3a546958

+7 -2
+7 -2
drivers/hv/vmbus_drv.c
··· 2787 2787 if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { 2788 2788 kmsg_dump_unregister(&hv_kmsg_dumper); 2789 2789 unregister_die_notifier(&hyperv_die_block); 2790 - atomic_notifier_chain_unregister(&panic_notifier_list, 2791 - &hyperv_panic_block); 2792 2790 } 2791 + 2792 + /* 2793 + * The panic notifier is always registered, hence we should 2794 + * also unconditionally unregister it here as well. 2795 + */ 2796 + atomic_notifier_chain_unregister(&panic_notifier_list, 2797 + &hyperv_panic_block); 2793 2798 2794 2799 free_page((unsigned long)hv_panic_page); 2795 2800 unregister_sysctl_table(hv_ctl_table_hdr);