Sfoglia il codice sorgente

[hermon] 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 7 anni fa
parent
commit
6ee62eb242
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1
    1
      src/drivers/infiniband/hermon.c

+ 1
- 1
src/drivers/infiniband/hermon.c Vedi File

@@ -2135,7 +2135,7 @@ static int hermon_map_vpm ( struct hermon *hermon,
2135 2135
 		if ( ( low - size ) >= start ) {
2136 2136
 			low -= size;
2137 2137
 			pa = low;
2138
-		} else if ( ( high + size ) <= end ) {
2138
+		} else if ( high <= ( end - size ) ) {
2139 2139
 			pa = high;
2140 2140
 			high += size;
2141 2141
 		} else {

Loading…
Annulla
Salva