From bf37f676d3bad0bb5562230741bd133f4a46d39d Mon Sep 17 00:00:00 2001 From: anton Date: Mon, 5 Dec 2022 06:30:25 +0000 Subject: [PATCH] Treat all possible mprotect() failures as fatal. --- regress/sys/uvm/wx_syscall/wx_syscall.c | 20 +++++++++++++------- 1 file 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 #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); -- 2.20.1