Skip to contentSkip to conversation

hw/cxl: Avoid out of bounds read when userspace requests data off end of CDAT.

PATCH In review Jonathan Cameron via qemu development 2 participants 2 messages Apr 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/cxl: Avoid out of bounds read when userspace requests data off end of CDAT.

The requested entry is controlled by the guest so must be checked against the number of entries that actually exist.

Reported as a security issue, but CXL emulation has since been declared to not be suitable (yet) for virtualization use cases and so the security handling policy does not apply.

Fixes f5ee7413d592 ("hw/mem/cxl-type3: Add CXL CDAT Data Object Exchange")
Fixes 882877fc359d ("hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE")
---
 hw/mem/cxl_type3.c           | 4 ++++
 hw/pci-bridge/cxl_upstream.c | 4 ++++
 2 files changed, 8 insertions(+)
hw/mem/cxl_type3.c +4 -0
index 4739239da3c5..763b6a024403 100644
@@ -278,6 +278,10 @@ static bool cxl_doe_cdat_rsp(DOECap *doe_cap)
     }
 
     ent = req->entry_handle;
+    if (ent >= cdat->entry_len) {
+        return false;
+    }
+
     base = cdat->entry[ent].base;
     len = cdat->entry[ent].length;
 
hw/pci-bridge/cxl_upstream.c +4 -0
index b6281cbd4cb0..fa53fa2777fd 100644
@@ -158,6 +158,10 @@ static bool cxl_doe_cdat_rsp(DOECap *doe_cap)
     }
 
     ent = req->entry_handle;
+    if (ent >= cdat->entry_len) {
+        return false;
+    }
+
     base = cdat->entry[ent].base;
     len = cdat->entry[ent].length;
 
Signature · 1 line
2.51.0
#1 lore raw
Quoted 7 lines · On Thu, 16 Apr 2026 16:54:21 +0100 Jonathan Cameron via qemu development…

The requested entry is controlled by the guest so must be checked against the number of entries that actually exist.

Reported as a security issue, but CXL emulation has since been declared to not be suitable (yet) for virtualization use cases and so the security handling policy does not apply.

Quoted 5 lines
Fixes f5ee7413d592 ("hw/mem/cxl-type3: Add CXL CDAT Data Object Exchange")
Fixes 882877fc359d ("hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE")

I have a very short memory it seems and forgot to add linux-cxl despite adding it to the MAINTAINERS entry yesterday.

Quoted 35 lines
---
 hw/mem/cxl_type3.c           | 4 ++++
 hw/pci-bridge/cxl_upstream.c | 4 ++++
 2 files changed, 8 insertions(+)
hw/mem/cxl_type3.c +4 -0
index 4739239da3c5..763b6a024403 100644
@@ -278,6 +278,10 @@ static bool cxl_doe_cdat_rsp(DOECap *doe_cap)
     }
 
     ent = req->entry_handle;
+    if (ent >= cdat->entry_len) {
+        return false;
+    }
+
     base = cdat->entry[ent].base;
     len = cdat->entry[ent].length;
 
hw/pci-bridge/cxl_upstream.c +4 -0
index b6281cbd4cb0..fa53fa2777fd 100644
@@ -158,6 +158,10 @@ static bool cxl_doe_cdat_rsp(DOECap *doe_cap)
     }
 
     ent = req->entry_handle;
+    if (ent >= cdat->entry_len) {
+        return false;
+    }
+
     base = cdat->entry[ent].base;
     len = cdat->entry[ent].length;