RE: [PATCH 1/1] Drivers: hv: vmbus: Fail VMBus module init for non-nested root partition

Michael Kelley <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kernel.vger.linux-hyperv
Message-ID <SN6PR02MB415758E1637A763B06911B8AD4D42@SN6PR02MB4157.namprd02.prod.outlook.com>
From: Easwar Hariharan <[email protected]> Sent: Tuesday, August 4, 2026 12:40 PM
> 
> On 8/4/2026 12:05, Michael Kelley wrote:
> > The VMBus module should not be loaded when Linux is running directly
> > in the root partition and root is not nested in another VM. Current
> > code checks this condition and skips VMBus module initialization, which
> > works. But it returns 0 as the result, so Linux thinks the module has
> > successfully loaded. Later, if the module were to be unloaded, the
> > VMBus module unload code tries to clean up things that were never
> > initialized, resulting in memory faults and a panic.
> >
> > Fix this by having VMBus module initialization return -ENODEV for this
> > case. The module is then not loaded, and the unload path can never run.
> >
> > Reported-by: Sashiko <[email protected]>
> > Closes: https://lore.kernel.org/linux-
> hyperv/[email protected]/
> > Fixes: 7e279d78664aa ("Drivers: hv: vmbus: skip VMBus initialization if Linux is root")
> > Signed-off-by: Michael Kelley <[email protected]>
> > ---
> >  drivers/hv/vmbus_drv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index e19ec73b0187..849d7e1a7320 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -2976,7 +2976,7 @@ static int __init hv_acpi_init(void)
> >  		return -ENODEV;
> >
> >  	if (hv_root_partition() && !hv_nested)
> > -		return 0;
> > +		return -ENODEV;
> >
> >  	/*
> >  	 * Get ACPI resources first.
> 
> This seems straightforward:

Alas, it's not so straightforward, as Sashiko pointed out.  I knew that
the mshv module has a dependency on the vmbus module, but had
forgotten. There's a reason for the dependency as described in the
commit message for 840b740a35bf.

There's another easy way to fix the VMBus module unload problem.
I'll send a v2. :-)

Michael

> 
> 
> Reviewed-by: Easwar Hariharan <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.