I have a file located on ext4 mounted with "dax". When I call mmap on that file with protection flag different than PROT_NONE
and pass the returned address to mprotect(..., PROT_NONE) it fails with:
mprotect: Permission denied
This bug affects PMDK (https://github.com/pmem/pmdk) and seems to be Ubuntu kernel-specific.
Problem was observer on kernel 4.15.0-36-generic and 4.15.0-34-generic
Below is a code which can be used to reproduce the issue.
I have a file located on ext4 mounted with "dax". When I call mmap on that file with protection flag different than PROT_NONE
and pass the returned address to mprotect(..., PROT_NONE) it fails with:
mprotect: Permission denied
This bug affects PMDK (https:/ /github. com/pmem/ pmdk) and seems to be Ubuntu kernel-specific.
Problem was observer on kernel 4.15.0-36-generic and 4.15.0-34-generic
Below is a code which can be used to reproduce the issue.
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char *argv[])
fprintf( stderr, "usage %s file size\n", argv[0]);
return 1;
{
if (argc < 3) {
}
int size = atoi(argv[2]);
int fd = open(argv[1], O_RDWR);
perror( "open") ;
return 1;
if (fd < 0) {
}
void *addr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
perror( "mmap") ;
return 1;
if (addr == MAP_FAILED) {
}
}
}