Re: [PATCH 4/6] misc: ibmvmc: initialize HMC state before device registration

From: Arnd Bergmann

Date: Wed Oct 28 2026 - 05:26:23 EST


On Wed, Oct 28, 2026, at 05:48, Jiale Yao wrote:
> misc_register() exposes the IBM VMC device before the HMC state and
> spinlocks are initialized. A userspace operation racing module
> initialization can therefore access an HMC through an uninitialized
> spinlock.
>
> Initialize all HMC state before registering the misc device.

It took me a bit to understand the exact race, as it's only
ibmvmc_setup_hmc() that has the race, not open(), but this looks
correct.

> Fixes: 0eca353e7ae7 ("misc: IBM Virtual Management Channel Driver (VMC)")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>

Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx>

> + rc = misc_register(&ibmvmc_miscdev);
> + if (rc) {
> + pr_err("ibmvmc: misc registration failed\n");
> + goto misc_register_failed;
> + }
> + pr_info("ibmvmc: node %d:%d\n", MISC_MAJOR,
> + ibmvmc_miscdev.minor);
> +
> /* Sanity check module parms */
> ibmvmc_scrub_module_parms();

I would probably move it further down, either just before
the vio_register_driver(), or reordering the two and adding
the misc_device last, to make it really clear that it does
not depend on any of those.

Arnd