Explorar el Código

[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 hace 7 años
padre
commit
6ee62eb242
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1
    1
      src/drivers/infiniband/hermon.c

+ 1
- 1
src/drivers/infiniband/hermon.c Ver fichero

@@ -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…
Cancelar
Guardar