summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2020-11-07 23:36:24 +0000
committerbluhm <bluhm@openbsd.org>2020-11-07 23:36:24 +0000
commit3c69bf015e43afae947e296915399d335454d28d (patch)
tree0edea52853bc1c88cc365bff747cc11b508f8413
parentAdd clock support for i.MX8MP. This variant uses essentially the (diff)
downloadwireguard-openbsd-3c69bf015e43afae947e296915399d335454d28d.tar.xz
wireguard-openbsd-3c69bf015e43afae947e296915399d335454d28d.zip
Check return value of mmap(2) correctly and set correct flags. Now
mmap(2) actually returns non-stack memory and triggers a SIGSEGV due to MAP_STACK on i386.
-rw-r--r--regress/usr.bin/lastcomm/trapstack.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/regress/usr.bin/lastcomm/trapstack.c b/regress/usr.bin/lastcomm/trapstack.c
index 8737e112b55..e5f01016bd8 100644
--- a/regress/usr.bin/lastcomm/trapstack.c
+++ b/regress/usr.bin/lastcomm/trapstack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trapstack.c,v 1.1 2019/09/23 08:34:07 bluhm Exp $ */
+/* $OpenBSD: trapstack.c,v 1.2 2020/11/07 23:36:24 bluhm Exp $ */
/*
* Copyright (c) 2018 Todd Mortimer <mortimer@openbsd.org>
* Copyright (c) 2019 Alexander Bluhm <bluhm@openbsd.org>
@@ -28,7 +28,7 @@
void handler(int);
void dotrap(void);
-static char *trapmap;
+static volatile char *trapmap;
int
main(int argc, char *argv[])
@@ -60,8 +60,9 @@ main(int argc, char *argv[])
/* allow stack to change half a page up and down. */
newstack[pagesize/sizeof(*newstack)/2] = dotrap;
- trapmap = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, 0, -1, 0);
- if (trapmap == NULL)
+ trapmap = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_ANONYMOUS,
+ -1, 0);
+ if (trapmap == MAP_FAILED)
err(1, "mmap");
if (sigaction(SIGSEGV, &act, NULL) == -1)