Просмотр исходного кода

[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 лет назад
Родитель
Сommit
6ee62eb242
1 измененных файлов: 1 добавлений и 1 удалений
  1. 1
    1
      src/drivers/infiniband/hermon.c

+ 1
- 1
src/drivers/infiniband/hermon.c Просмотреть файл

@@ -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 {

Загрузка…
Отмена
Сохранить