36 lines
1.2 KiB
Diff
36 lines
1.2 KiB
Diff
|
|
From 80f4d02d7afa212fba4420a3af04f3a670b9a5d4 Mon Sep 17 00:00:00 2001
|
||
|
|
From: qihao <qihao_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 26 Aug 2024 10:40:40 +0800
|
||
|
|
Subject: [PATCH] hw/nvme: fix leak of uninitialized memory in io_mgmt_recv
|
||
|
|
|
||
|
|
cheery-pick from 6a22121c4f25b181e99479f65958ecde65da1c92
|
||
|
|
|
||
|
|
Yutaro Shimizu from the Cyber Defense Institute discovered a bug in the
|
||
|
|
NVMe emulation that leaks contents of an uninitialized heap buffer if
|
||
|
|
subsystem and FDP emulation are enabled.
|
||
|
|
|
||
|
|
Cc: qemu-stable@nongnu.org
|
||
|
|
Reported-by: Yutaro Shimizu <shimizu@cyberdefense.jp>
|
||
|
|
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
|
||
|
|
Signed-off-by: qihao_yewu <qihao_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
hw/nvme/ctrl.c | 2 +-
|
||
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
|
||
|
|
index aecf7c37bb..104aebc5ea 100644
|
||
|
|
--- a/hw/nvme/ctrl.c
|
||
|
|
+++ b/hw/nvme/ctrl.c
|
||
|
|
@@ -4302,7 +4302,7 @@ static uint16_t nvme_io_mgmt_recv_ruhs(NvmeCtrl *n, NvmeRequest *req,
|
||
|
|
|
||
|
|
nruhsd = ns->fdp.nphs * endgrp->fdp.nrg;
|
||
|
|
trans_len = sizeof(NvmeRuhStatus) + nruhsd * sizeof(NvmeRuhStatusDescr);
|
||
|
|
- buf = g_malloc(trans_len);
|
||
|
|
+ buf = g_malloc0(trans_len);
|
||
|
|
|
||
|
|
trans_len = MIN(trans_len, len);
|
||
|
|
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|