parlib: slab: mmap with PROT_EXEC
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 31 Jul 2017 19:37:28 +0000 (15:37 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 31 Jul 2017 19:50:44 +0000 (15:50 -0400)
We don't know what the user will do with the memory, so let's let them use
it for anything.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/parlib/slab.c

index 8c11d27..936981f 100644 (file)
@@ -261,7 +261,7 @@ static void kmem_cache_grow(struct kmem_cache *cp)
 
        if (cp->obj_size <= SLAB_LARGE_CUTOFF) {
                // Just get a single page for small slabs
-               a_page = mmap(0, PGSIZE, PROT_READ | PROT_WRITE,
+               a_page = mmap(0, PGSIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
                              MAP_POPULATE | MAP_ANONYMOUS, -1, 0);
                assert(a_page != MAP_FAILED);
                // the slab struct is stored at the end of the page
@@ -301,7 +301,7 @@ static void kmem_cache_grow(struct kmem_cache *cp)
                 * the kernel. */
                size_t nr_pgs = ROUNDUP(NUM_BUF_PER_SLAB * a_slab->obj_size, PGSIZE) /
                                         PGSIZE;
-               void *buf = mmap(0, nr_pgs * PGSIZE, PROT_READ | PROT_WRITE,
+               void *buf = mmap(0, nr_pgs * PGSIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
                                 MAP_POPULATE | MAP_ANONYMOUS, -1, 0);
                assert(buf != MAP_FAILED);
                a_slab->num_busy_obj = 0;