From f1d4db7e9d92a3f51f2d1dc0475404dae751b9fd Mon Sep 17 00:00:00 2001 From: Humza Ikram Date: Sat, 25 Jul 2026 01:03:17 -0400 Subject: [PATCH] Fix two crashes in the R3 monitor - alignShadowMemRange: unsigned size - N underflows for size < N (any memory.copy shorter than 16 bytes), driving out-of-bounds shadow reads. - onFuncEntry: don't error when the entered function is neither exported nor table-reachable (start functions; direct calls from excluded code). Co-Authored-By: Claude Fable 5 --- src/monitors/R3Monitor.v3 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/monitors/R3Monitor.v3 b/src/monitors/R3Monitor.v3 index 57f60e652..1bd88fa29 100644 --- a/src/monitors/R3Monitor.v3 +++ b/src/monitors/R3Monitor.v3 @@ -224,8 +224,6 @@ private class EventHandler { } if (index_match_found) break; } - if (!index_match_found) - System.error("R3MonitorError", "external call with table_get failed"); } checkMemGrow(instance); checkTableGrow(instance); @@ -383,17 +381,17 @@ private class EventHandler { private def alignShadowMemRange(mem: Memory, addr: u64, size: u64) { var scanned_size: u64 = 0; - while (scanned_size <= size - 16) { + while (scanned_size + 16 <= size) { alignShadowMemFixedRange(mem, addr, 16); scanned_size += 16; addr += 16; } - if (scanned_size <= size - 8) { + if (scanned_size + 8 <= size) { alignShadowMemFixedRange(mem, addr, 8); scanned_size += 8; addr += 8; } - if (scanned_size <= size - 4) { + if (scanned_size + 4 <= size) { alignShadowMemFixedRange(mem, addr, 4); scanned_size += 4; addr += 4;