Skip to contentSkip to conversation

hw/nvme: fix oob memory read in fdp events log

PATCH In review Klaus Jensen 1 participant 2 messages Aug 3, 2023 – Aug 8, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/nvme: fix oob memory read in fdp events log

From: Klaus Jensen <[email protected]>

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
---
 hw/nvme/ctrl.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/nvme/ctrl.c +5 -0
index f2e5a2fa737b..e9b5a55811b8 100644
@@ -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);
Signature · 1 line
2.41.0
#1 lore raw

+CC qemu-stable

Quoted 38 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

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
---
 hw/nvme/ctrl.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/nvme/ctrl.c +5 -0
index f2e5a2fa737b..e9b5a55811b8 100644
@@ -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);
Signature · 1 line
2.41.0
Signature · 1 line
One of us - No more doubt, silence or taboo about mental illness.