diff options
author | Anton Lindqvist <anton@cvs.openbsd.org> | 2022-12-05 06:30:26 +0000 |
---|---|---|
committer | Anton Lindqvist <anton@cvs.openbsd.org> | 2022-12-05 06:30:26 +0000 |
commit | 1c8462390a1e5c6b86c5107db6c81cb0905bcba9 (patch) | |
tree | 7809e8a26b38fa8d6de1a72bfbfce8eee1d6e4f2 /regress | |
parent | 18b2bff809dc543d07ef96ea2aa037474e99ceda (diff) |
Treat all possible mprotect() failures as fatal.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sys/uvm/wx_syscall/wx_syscall.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/regress/sys/uvm/wx_syscall/wx_syscall.c b/regress/sys/uvm/wx_syscall/wx_syscall.c index c067ac849ab..b272f2c3e0c 100644 --- a/regress/sys/uvm/wx_syscall/wx_syscall.c +++ b/regress/sys/uvm/wx_syscall/wx_syscall.c @@ -1,10 +1,12 @@ #include <sys/types.h> #include <sys/mman.h> + +#include <err.h> +#include <errno.h> #include <fcntl.h> #include <stdio.h> -#include <unistd.h> #include <stdlib.h> -#include <errno.h> +#include <unistd.h> int main() @@ -13,11 +15,15 @@ main() int psz = getpagesize(); printf("%llx\n", (long long)flock); - if (mprotect((void *)(o & ~(psz-1)), psz, - PROT_EXEC|PROT_WRITE|PROT_READ) == -1 && - errno == ENOTSUP) { - printf("mprotect -> ENOTSUP? Please run from wxallowed filesystem\n"); - exit(0); + if (mprotect((void *)(o & ~(psz - 1)), psz, + PROT_EXEC|PROT_WRITE|PROT_READ) == -1) { + if (errno == ENOTSUP) { + printf("mprotect -> ENOTSUP? Please run from " + "wxallowed filesystem\n"); + exit(0); + } else { + err(1, "mprotect"); + } } flock(0, 0); |