Skip to contentSkip to conversation

xen/arm: efi: Avoid out-of-bounds write in meminfo_add_bank

PATCH In review Julien Grall 2 participants 2 messages May 4, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: efi: Avoid out-of-bounds write in meminfo_add_bank

Commit 2c77db77 "xen/arm: efi: Avoid duplicating the addition of a new bank", introduced a new function meminfo_add_bank that add a new bank. This new code fails to check correctly the size of the array which may result to an out-of-bounds write.

Coverity-ID: 1433183

---
The new function was introduced during the development of Xen 4.9 and should be fixed before the release.

---
 xen/arch/arm/efi/efi-boot.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/efi/efi-boot.h +1 -1
index e1e447ac8e..2986c83447 100644
@@ -128,7 +128,7 @@ static bool __init meminfo_add_bank(struct meminfo *mem,
 {
     struct membank *bank;
 
-    if ( mem->nr_banks > NR_MEM_BANKS )
+    if ( mem->nr_banks >= NR_MEM_BANKS )
         return false;
 
     bank = &mem->bank[mem->nr_banks];
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Julien Grall

Commit 2c77db77 "xen/arm: efi: Avoid duplicating the addition of a new bank", introduced a new function meminfo_add_bank that add a new bank. This new code fails to check correctly the size of the array which may result to an out-of-bounds write.

Coverity-ID: 1433183

Quoted 23 lines

---
The new function was introduced during the development of Xen 4.9 and should be fixed before the release.

---
 xen/arch/arm/efi/efi-boot.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/efi/efi-boot.h +1 -1
index e1e447ac8e..2986c83447 100644
@@ -128,7 +128,7 @@ static bool __init meminfo_add_bank(struct meminfo *mem,
 {
     struct membank *bank;
 
-    if ( mem->nr_banks > NR_MEM_BANKS )
+    if ( mem->nr_banks >= NR_MEM_BANKS )
         return false;
 
     bank = &mem->bank[mem->nr_banks];
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel