vppinfra: fix SIGBUS in bihash init when running unpriviledged, take two 89/27289/1
authorDamjan Marion <damarion@cisco.com>
Wed, 27 May 2020 14:43:35 +0000 (16:43 +0200)
committerDamjan Marion <damarion@cisco.com>
Wed, 27 May 2020 14:43:35 +0000 (16:43 +0200)
Looks like MAP_LOCK is not enough, so call mlock(...) instead....

Type: fix
Change-Id: I1bc668a2bf3c861ca1c2d376c0fb6bfea87d4f48
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vppinfra/bihash_template.c

index 2305436..dac42a8 100644 (file)
@@ -53,7 +53,7 @@ static inline void *BV (alloc_aligned) (BVT (clib_bihash) * h, uword nbytes)
       rv = mmap (base, alloc, PROT_READ | PROT_WRITE, mmap_flags_huge, -1, 0);
 
       /* fallback - maybe we are still able to allocate normal pages */
-      if (rv == MAP_FAILED)
+      if (rv == MAP_FAILED || mlock (base, alloc) != 0)
        rv = mmap (base, alloc, PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
 
       if (rv == MAP_FAILED)