mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu@kernel.org>
To: Jiale Yao <yaojiale02@163.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
	Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>,
	Anirudh Rayabharam <anrayabh@linux.microsoft.com>,
	Mukesh Rathor <mrathor@linux.microsoft.com>,
	Nuno Das Neves <nunodasneves@linux.microsoft.com>,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH 3/6] Drivers: hv: initialize partition table before device registration
Date: Mon, 2 Nov 2026 16:59:11 -0800	[thread overview]
Message-ID: <20261103005911.GC1862133@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <20261028044828.96177-4-yaojiale02@163.com>

On Wed, Oct 28, 2026 at 12:48:23PM +0800, Jiale Yao wrote:
> misc_register() exposes /dev/mshv before the partition hash table and
> its lock are initialized. A partition ioctl racing module initialization
> can therefore access the table through an uninitialized spinlock.
> 
> Initialize the partition table and lock before registering the misc
> device.
> 
> Fixes: 621191d709b1 ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiale Yao <yaojiale02@163.com>

If such races are really a problem, shouldn't the msic_register call be
the last in the function?

Wei

> ---
>  drivers/hv/mshv_root_main.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index cc2cfce2aefd..ce26320035b6 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -2369,6 +2369,9 @@ static int __init mshv_parent_partition_init(void)
>  	if (hv_get_hypervisor_version(&version_info))
>  		return -ENODEV;
>  
> +	spin_lock_init(&mshv_root.pt_ht_lock);
> +	hash_init(mshv_root.pt_htable);
> +
>  	ret = misc_register(&mshv_dev);
>  	if (ret)
>  		return ret;
> @@ -2407,9 +2410,6 @@ static int __init mshv_parent_partition_init(void)
>  	if (ret)
>  		goto exit_debugfs;
>  
> -	spin_lock_init(&mshv_root.pt_ht_lock);
> -	hash_init(mshv_root.pt_htable);
> -
>  	hv_setup_mshv_handler(mshv_isr);
>  
>  	return 0;
> -- 
> 2.34.1
> 

  reply	other threads:[~2026-11-03  0:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  4:48 [PATCH 0/6] Initialize device state before userspace registration Jiale Yao
2026-10-28  4:48 ` [PATCH 1/6] aoe: initialize error message synchronization before registration Jiale Yao
2026-10-28  4:48 ` [PATCH 2/6] bus: fsl-mc: initialize UAPI state before device registration Jiale Yao
2026-10-28  4:48 ` [PATCH 3/6] Drivers: hv: initialize partition table " Jiale Yao
2026-11-03  0:59   ` Wei Liu [this message]
2026-10-28  4:48 ` [PATCH 4/6] misc: ibmvmc: initialize HMC state " Jiale Yao
2026-10-28  9:25   ` Arnd Bergmann
2026-10-28 10:05   ` Greg Kroah-Hartman
2026-10-28  4:48 ` [PATCH 5/6] s390/dcssblk: initialize device semaphore before sysfs registration Jiale Yao
2026-10-28  7:03   ` Heiko Carstens
2026-10-28  4:48 ` [PATCH 6/6] watchdog: rdc321x: initialize device state before registration Jiale Yao
2026-10-28 14:53   ` Guenter Roeck

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=20261103005911.GC1862133@liuwe-devbox-debian-v2.local \
    --to=wei.liu@kernel.org \
    --cc=anrayabh@linux.microsoft.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mrathor@linux.microsoft.com \
    --cc=nunodasneves@linux.microsoft.com \
    --cc=skinsburskii@linux.microsoft.com \
    --cc=stable@vger.kernel.org \
    --cc=yaojiale02@163.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®