Quellcode durchsuchen

[arbel] Avoid potential integer overflow when calculating memory mappings

When the area to be mapped straddles the 2GB boundary, the expression
(high+size) will overflow on the first loop iteration.  Fix by using
(end-size), which cannot underflow.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 7 Jahren
Ursprung
Commit
a5affc832e
1 geänderte Dateien mit 1 neuen und 1 gelöschten Zeilen
  1. 1
    1
      src/drivers/infiniband/arbel.c

+ 1
- 1
src/drivers/infiniband/arbel.c Datei anzeigen

@@ -1994,7 +1994,7 @@ static int arbel_map_vpm ( struct arbel *arbel,
1994 1994
 		if ( ( low - size ) >= start ) {
1995 1995
 			low -= size;
1996 1996
 			pa = low;
1997
-		} else if ( ( high + size ) <= end ) {
1997
+		} else if ( high <= ( end - size ) ) {
1998 1998
 			pa = high;
1999 1999
 			high += size;
2000 2000
 		} else {

Laden…
Abbrechen
Speichern