-
Notifications
You must be signed in to change notification settings - Fork 30
Description
This is an informational post for other PSM2 users. In Red Hat Enterprise Linux 7.5, we found that some of our MPI executables exit with the following error:
hfi_userinit: mmap of status page (dabbad0008030000) failed: Operation not permitted
This error is thrown from this line of code in the PSM2 library:
We tracked this down to the execute bit being set in the GNU_STACK of the ELF headers in a binary. That in turn attempts to map the memory region with both the read and execute bits enabled, rather than just the read bit as PSM2 is requesting. As described in this post:
https://stackoverflow.com/questions/32730643/why-in-mmap-prot-read-equals-prot-exec
"For what I understand, GNU_STACK program header is designed to tell the kernel that you want some specific properties for the stack, one those properties is a non-executable stack. It appears that if you don't explicitly ask for a non-executable stack, all the ELF sections marked as readable will be executable too. And also all the memory mapping with mmap while have the same behavior."
One can inspect a binary for this setting using readelf:
readelf --program-headers a.out
We could reproduce this by running a simple MPI program that was compiled with PGI.
For example, a binary built with PGI shows:
readelf --program-headers mpiBench_pgi
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RWE 10
Whereas a binary built with GNU:
readelf --program-headers mpiBench_gnu
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 10
We found that a work around is to add "-Wl,-z,noexecstack" during the link step. Alternatively, one can force this bit off in an existing executable with execstack:
execstack -c a.out