[PATCH 1/2] libwine: fix incorrect usage of mincore() by try_mmap_fixed()

Damjan Jovanovic damjan.jov at gmail.com
Mon May 18 14:04:19 CDT 2020


The return value of mincore() only tells us whether the system call
succeeded, not whether the memory is resident. Check the result in
the "vec" parameter like we're supposed to.

Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
---
 libs/wine/mmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
-------------- next part --------------
diff --git a/libs/wine/mmap.c b/libs/wine/mmap.c
index f2b5adc1d2..6bcd15619c 100644
--- a/libs/wine/mmap.c
+++ b/libs/wine/mmap.c
@@ -133,13 +133,13 @@ static int try_mmap_fixed (void *addr, size_t len, int prot, int flags,
     if ( pid == 0 )
     {
         int i;
-        char vec;
+        char vec = 0;
 
         /* We call mincore() for every page in the desired range.
            If any of these calls succeeds, the page is already
            mapped and we must fail. */
         for ( i = 0; i < len; i += pagesize )
-            if ( mincore( (caddr_t)addr + i, pagesize, &vec ) != -1 )
+            if ( mincore( (caddr_t)addr + i, pagesize, &vec ) != -1 || vec )
                _exit(1);
 
         /* Perform the mapping with MAP_FIXED set.  This is safe


More information about the wine-devel mailing list