Skip to contentSkip to conversation

hw/display: refine upper limit for offset value in assert check

PATCH New [email protected] 1 participant 1 message Jul 22, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/display: refine upper limit for offset value in assert check

From: Denis Rastyogin <[email protected]>

Accessing s->core_registers (size 236) could overflow if the offset goes beyond the valid range.

Since the memory region matches core_registers size exactly, guest cannot write out-of-bounds.

Therefore, the debug assert has been refined to ensure the offset remains within DP_CORE_REG_ARRAY_SIZE, preventing internal errors.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 hw/display/xlnx_dp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/display/xlnx_dp.c +5 -1
index 7c980ee642..b35ee2f869 100644
@@ -896,7 +896,11 @@ static void xlnx_dp_write(void *opaque, hwaddr offset, uint64_t value,
         xlnx_dp_update_irq(s);
         break;
     default:
-        assert(offset <= (0x504C >> 2));
+        /*
+         * Check to ensure the offset is within the bounds of
+         * the core_registers[] array.
+         */
+        assert(offset < DP_CORE_REG_ARRAY_SIZE);
         s->core_registers[offset] = value;
         break;
     }
Signature · 1 line
2.42.2