mmap/mmap: Fix integer overflow in binary search

The integer overflow triggered for simple masks in the "badram"
command, such as "badram 0x0000000012340000,0xfffffffffffffff8".
This resulted in an infinite loop, locking up the machine.

Signed-off-by: Wanda Phinode <wanda@phinode.net>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Wanda Phinode authored and Daniel Kiper committed 2026-02-11 17:24:34 +01:00
1 parent eaa3b8f0f9
commit 170221b355
1 file changed
+1 -1
+1 -1
View File
@@ -409,7 +409,7 @@ badram_iter (grub_uint64_t addr, grub_uint64_t size,
*/
while (high - low > 1)
{
cur = (low + high) / 2;
cur = low + (high - low) / 2;
if (fill_mask (entry, cur) >= addr)
high = cur;
else