summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliuyacan <liuyacan@corp.netease.com>2021-12-22 16:41:21 +0800
committerDamjan Marion <dmarion@me.com>2021-12-22 15:19:12 +0000
commit9b8dc824d8c5b88b25eae6aa431256746d26d95b (patch)
tree5ad973779c03614b49b08ddfd9eb691c5e66efcc
parent657936f665c18441bddcc2524bb3ad3dfe0e20bc (diff)
vppinfra: fix map_lock issue
The release of the map_lock is a bit too early, it needs to wrap mprotect(), otherwise the access rights of hdr may be deprived of other worker threads. Type: fix Signed-off-by: liuyacan <liuyacan@corp.netease.com> Change-Id: I9cb89d49a097ec6d5ae9fd2af2bddf967ec946e9
-rw-r--r--src/vppinfra/linux/mem.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index 3b752cf43cf..6c3e036d951 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -461,8 +461,6 @@ clib_mem_vm_map_internal (void *base, clib_mem_page_sz_t log2_page_sz,
snprintf (hdr->name, CLIB_VM_MAP_HDR_NAME_MAX_LEN - 1, "%s", (char *) name);
mm->last_map = hdr;
- map_unlock ();
-
hdr->base_addr = (uword) base;
hdr->log2_page_sz = log2_page_sz;
hdr->num_pages = size >> log2_page_sz;
@@ -470,6 +468,8 @@ clib_mem_vm_map_internal (void *base, clib_mem_page_sz_t log2_page_sz,
hdr->name[CLIB_VM_MAP_HDR_NAME_MAX_LEN - 1] = 0;
mprotect (hdr, sys_page_sz, PROT_NONE);
+ map_unlock ();
+
CLIB_MEM_UNPOISON (base, size);
return base;
}