]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mshv_vtl: bounds-check cpu index in vtl mmap fault handler
authorYi Xie <xieyi@kylinos.cn>
Thu, 9 Jul 2026 02:19:47 +0000 (10:19 +0800)
committerWei Liu <wei.liu@kernel.org>
Fri, 31 Jul 2026 20:02:04 +0000 (20:02 +0000)
cpu is taken from pgoff & 0xffff.  cpu_online() does not reject cpu >=
nr_cpu_ids, and per_cpu_ptr() can then walk off __per_cpu_offset.

Signed-off-by: Yi Xie <xieyi@kylinos.cn>
Reviewed-by: Naman Jain <namjain@linux.microsoft.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/hv/mshv_vtl_main.c

index 5ba1efb3b4e7ea11181e85feff7928655708f001..6e3c11c681717b16976b4de4fca712762b296f2d 100644 (file)
@@ -802,7 +802,7 @@ static vm_fault_t mshv_vtl_fault(struct vm_fault *vmf)
        int cpu = vmf->pgoff & MSHV_PG_OFF_CPU_MASK;
        int real_off = vmf->pgoff >> MSHV_REAL_OFF_SHIFT;
 
-       if (!cpu_online(cpu))
+       if (cpu >= nr_cpu_ids || !cpu_online(cpu))
                return VM_FAULT_SIGBUS;
        /*
         * CPU Hotplug is not supported in VTL2 in OpenHCL, where this kernel driver exists.