lib/elsewhere: Reject allocations above 4 GiB
diff --git a/common/lib/elsewhere.c b/common/lib/elsewhere.c
index 58ab247b..67d63f8b 100644
--- a/common/lib/elsewhere.c
+++ b/common/lib/elsewhere.c
@@ -41,6 +41,11 @@ retry:
for (size_t i = 0; i < *ranges_count; i++) {
uint64_t t_top = *target + t_length;
+ // Ensure allocation stays within 32-bit address space.
+ if (t_top > 0x100000000) {
+ return false;
+ }
+
// Does it overlap with other elsewhere ranges targets?
{
uint64_t base = ranges[i].target;
