]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drivers: virt: acrn: hsm: Use kzalloc to avoid info leak in pmcmd_ioctl
authorHaoyu Li <lihaoyu499@gmail.com>
Thu, 30 Jan 2025 11:58:11 +0000 (19:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Feb 2025 14:20:34 +0000 (15:20 +0100)
In the "pmcmd_ioctl" function, three memory objects allocated by
kmalloc are initialized by "hcall_get_cpu_state", which are then
copied to user space. The initializer is indeed implemented in
"acrn_hypercall2" (arch/x86/include/asm/acrn.h). There is a risk of
information leakage due to uninitialized bytes.

Fixes: 3d679d5aec64 ("virt: acrn: Introduce interfaces to query C-states and P-states allowed by hypervisor")
Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
Cc: stable <stable@kernel.org>
Acked-by: Fei Li <fei1.li@intel.com>
Link: https://lore.kernel.org/r/20250130115811.92424-1-lihaoyu499@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/virt/acrn/hsm.c

index c24036c4e51ecd333ccbc5d32e3b84b0194370d3..e4e196abdaac9455f18d26f09947bfbacbd35398 100644 (file)
@@ -49,7 +49,7 @@ static int pmcmd_ioctl(u64 cmd, void __user *uptr)
        switch (cmd & PMCMD_TYPE_MASK) {
        case ACRN_PMCMD_GET_PX_CNT:
        case ACRN_PMCMD_GET_CX_CNT:
-               pm_info = kmalloc(sizeof(u64), GFP_KERNEL);
+               pm_info = kzalloc(sizeof(u64), GFP_KERNEL);
                if (!pm_info)
                        return -ENOMEM;
 
@@ -64,7 +64,7 @@ static int pmcmd_ioctl(u64 cmd, void __user *uptr)
                kfree(pm_info);
                break;
        case ACRN_PMCMD_GET_PX_DATA:
-               px_data = kmalloc(sizeof(*px_data), GFP_KERNEL);
+               px_data = kzalloc(sizeof(*px_data), GFP_KERNEL);
                if (!px_data)
                        return -ENOMEM;
 
@@ -79,7 +79,7 @@ static int pmcmd_ioctl(u64 cmd, void __user *uptr)
                kfree(px_data);
                break;
        case ACRN_PMCMD_GET_CX_DATA:
-               cx_data = kmalloc(sizeof(*cx_data), GFP_KERNEL);
+               cx_data = kzalloc(sizeof(*cx_data), GFP_KERNEL);
                if (!cx_data)
                        return -ENOMEM;