qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/nvme: fix oob memory read in fdp events log
@ 2023-08-03 18:44 Klaus Jensen
  2023-08-08  6:15 ` Klaus Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Klaus Jensen @ 2023-08-03 18:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-security, Keith Busch, Mauro Matteo Cascella,
	zdi-disclosures, Klaus Jensen, Klaus Jensen

From: Klaus Jensen <k.jensen@samsung.com>

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 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index f2e5a2fa737b..e9b5a55811b8 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -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);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hw/nvme: fix oob memory read in fdp events log
  2023-08-03 18:44 [PATCH] hw/nvme: fix oob memory read in fdp events log Klaus Jensen
@ 2023-08-08  6:15 ` Klaus Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: Klaus Jensen @ 2023-08-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-security, Keith Busch, Mauro Matteo Cascella,
	zdi-disclosures, Klaus Jensen, qemu-stable

[-- Attachment #1: Type: text/plain, Size: 1317 bytes --]

+CC qemu-stable

On Aug  3 20:44, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> 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 | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index f2e5a2fa737b..e9b5a55811b8 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -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);
> -- 
> 2.41.0
> 

-- 
One of us - No more doubt, silence or taboo about mental illness.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-08  6:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 18:44 [PATCH] hw/nvme: fix oob memory read in fdp events log Klaus Jensen
2023-08-08  6:15 ` Klaus Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).