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 --- 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