Skip to content

Commit 819cec1

Browse files
learjet5gregkh
authored andcommitted
drivers: virt: acrn: hsm: Use kzalloc to avoid info leak in pmcmd_ioctl
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: 3d679d5 ("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>
1 parent e77aff5 commit 819cec1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/virt/acrn/hsm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static int pmcmd_ioctl(u64 cmd, void __user *uptr)
4949
switch (cmd & PMCMD_TYPE_MASK) {
5050
case ACRN_PMCMD_GET_PX_CNT:
5151
case ACRN_PMCMD_GET_CX_CNT:
52-
pm_info = kmalloc(sizeof(u64), GFP_KERNEL);
52+
pm_info = kzalloc(sizeof(u64), GFP_KERNEL);
5353
if (!pm_info)
5454
return -ENOMEM;
5555

@@ -64,7 +64,7 @@ static int pmcmd_ioctl(u64 cmd, void __user *uptr)
6464
kfree(pm_info);
6565
break;
6666
case ACRN_PMCMD_GET_PX_DATA:
67-
px_data = kmalloc(sizeof(*px_data), GFP_KERNEL);
67+
px_data = kzalloc(sizeof(*px_data), GFP_KERNEL);
6868
if (!px_data)
6969
return -ENOMEM;
7070

@@ -79,7 +79,7 @@ static int pmcmd_ioctl(u64 cmd, void __user *uptr)
7979
kfree(px_data);
8080
break;
8181
case ACRN_PMCMD_GET_CX_DATA:
82-
cx_data = kmalloc(sizeof(*cx_data), GFP_KERNEL);
82+
cx_data = kzalloc(sizeof(*cx_data), GFP_KERNEL);
8383
if (!cx_data)
8484
return -ENOMEM;
8585

0 commit comments

Comments
 (0)