From: anton Date: Mon, 5 Dec 2022 06:30:25 +0000 (+0000) Subject: Treat all possible mprotect() failures as fatal. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bf37f676d3bad0bb5562230741bd133f4a46d39d;p=openbsd Treat all possible mprotect() failures as fatal. --- 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 #include + +#include +#include #include #include -#include #include -#include +#include 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);