]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/nvme: fix oob memory read in fdp events log
authorKlaus Jensen <k.jensen@samsung.com>
Thu, 3 Aug 2023 18:44:23 +0000 (20:44 +0200)
committerKlaus Jensen <k.jensen@samsung.com>
Mon, 7 Aug 2023 06:51:37 +0000 (08:51 +0200)
As reported by Trend Micro's Zero Day Initiative, an oob memory read
vulnerability exists in nvme_fdp_events(). The host-provided offset is
not verified.

Fix this.

This is only exploitable when Flexible Data Placement mode (fdp=on) is
enabled.

Fixes: CVE-2023-4135
Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
Reported-by: Trend Micro's Zero Day Initiative
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
hw/nvme/ctrl.c

index f2e5a2fa737b418dac27c616d820f05c00b1376f..e9b5a55811b81837013228f2475a17bedfec237e 100644 (file)
@@ -5120,6 +5120,11 @@ static uint16_t nvme_fdp_events(NvmeCtrl *n, uint32_t endgrpid,
     }
 
     log_size = sizeof(NvmeFdpEventsLog) + ebuf->nelems * sizeof(NvmeFdpEvent);
+
+    if (off >= log_size) {
+        return NVME_INVALID_FIELD | NVME_DNR;
+    }
+
     trans_len = MIN(log_size - off, buf_len);
     elog = g_malloc0(log_size);
     elog->num_events = cpu_to_le32(ebuf->nelems);