Skip to contentSkip to conversation

vfio: fix boundary check in region search

PATCH Applied Xiao Wang 3 participants 3 messages Apr 20, 2018 – Apr 23, 2018

lore
Share & tools
lore

Xiao Wang

author
#0 lore raw

PATCH 1/1 vfio: fix boundary check in region search

A previously mapped region is skipped during the search, leading to DMA unmap fails.

This patch fixes it and rewords the comment.

Fixes 73a639085938 ("vfio: allow to map other memory regions")
---
 lib/librte_eal/linuxapp/eal/eal_vfio.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/librte_eal/linuxapp/eal/eal_vfio.c +4 -4
index 7cf3f0285..7afa33d3a 100644
@@ -230,15 +230,15 @@ find_user_mem_map(struct user_mem_maps *user_mem_maps, uint64_t addr,
 		/* check start VA */
 		if (addr < map->addr || addr >= map_va_end)
 			continue;
-		/* check if IOVA end is within boundaries */
-		if (va_end <= map->addr || va_end >= map_va_end)
+		/* check if VA end is within boundaries */
+		if (va_end <= map->addr || va_end > map_va_end)
 			continue;
 
-		/* check start PA */
+		/* check start IOVA */
 		if (iova < map->iova || iova >= map_iova_end)
 			continue;
 		/* check if IOVA end is within boundaries */
-		if (iova_end <= map->iova || iova_end >= map_iova_end)
+		if (iova_end <= map->iova || iova_end > map_iova_end)
 			continue;
 
 		/* we've found our map */
Signature · 1 line
2.15.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Xiao Wang

A previously mapped region is skipped during the search, leading to DMA unmap fails.

This patch fixes it and rewords the comment.

Fixes 73a639085938 ("vfio: allow to map other memory regions")

---

<insert Homer Simpson "D'oh!" pic here>

Signature · 2 lines
Thanks,
Anatoly
#2 lore raw

20/04/2018 17:23, Burakov, Anatoly:

Quoted 12 lines · Xiao Wang
Quoted 9 lines

A previously mapped region is skipped during the search, leading to DMA unmap fails.

This patch fixes it and rewords the comment.

Fixes 73a639085938 ("vfio: allow to map other memory regions")

---

<insert Homer Simpson "D'oh!" pic here>

                       _ ,___,-'",-=-. 
           __,-- _ _,-'_)_  (""`'-._\ `. 
        _,'  __ |,' ,-' __)  ,-     /. | 
      ,'_,--'   |     -'  _)/         `\ 
    ,','      ,'       ,-'_,`           : 
    ,'     ,-'       ,(,-(              : 
         ,'       ,-' ,    _            ; 
        /        ,-._/`---'            / 
       /        (____)(----. )       ,' 
      /         (      `.__,     /\ /, 
     :           ;-.___         /__\/| 
     |         ,'      `--.      -,\ | 
     :        /            \    .__/ 
      \      (__            \    |_ 
       \       ,`-, *       /   _|,\ 
        \    ,'   `-.     ,'_,-'    \ 
       (_\,-'    ,'\")--,'-'       __\ 
        \       /  // ,'|      ,--'  `-. 
         `-.    `-/ \'  |   _,'         `. 
            `-._ /      `--'/             \ 
    -hrr-      ,'           |              \ 
              /             |               \ 
           ,-'              |               / 
          /                 |             -' 
Quoted 1 line

Applied, thanks