Add a test for working mmap() of RWX pages on openbsd 6.0 and newer.

Unless a binary is linked with -zwxneeded and run from a filesystem
mounted with -o wxallowed then no page may have both the PROT_EXEC and
PROT_WRITE protections.
This commit is contained in:
Joshua Elsasser 2018-11-08 11:05:27 -08:00
parent 77fb7b7f97
commit e0f4906962
2 changed files with 25 additions and 0 deletions

View file

@ -443,6 +443,21 @@ else
esac
fi
case "$sbcl_os" in
openbsd)
# openbsd 6.0 and newer restrict mmap of RWX pages
if [ $(uname -r | tr -d .) -gt 60 ]; then
rm -f tools-for-build/mmap-rwx
LDFLAGS="$LDFLAGS -Wl,-zwxneeded" $GNUMAKE -C tools-for-build mmap-rwx -I ../src/runtime
if ! ./tools-for-build/mmap-rwx; then
echo "Can't mmap() RWX pages!"
echo "Is the current filesystem mounted with wxallowed?"
exit 1
fi
fi
;;
esac
bf=`pwd`/build-features.lisp-expr
echo //initializing $bf
echo ';;;; This is a machine-generated file.' > $bf

View file

@ -0,0 +1,10 @@
#include <sys/mman.h>
int
main()
{
if (mmap(0, 1, PROT_EXEC|PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON, -1, 0) == MAP_FAILED)
return 1;
return 0;
}