diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-07-18 23:00:32 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-07-18 23:00:32 +0000 |
commit | aba228e7a0f5a37ccb32c892a3c12fd57bf1aa41 (patch) | |
tree | 74273296d263364c6f2465df6285a442090f1951 /regress/sys/kern/noexec | |
parent | 98005da9bda57d9209b2fb2782ff23876cdcfd41 (diff) |
The function getaddr() compares the stack address of the caller
with its own local variable. This way it detects the direction of
stack growth. This does not work if the functions gets inlined.
Pass -fno-inline to the compiler to avoid sporadic tests fails.
Diffstat (limited to 'regress/sys/kern/noexec')
-rw-r--r-- | regress/sys/kern/noexec/Makefile | 26 | ||||
-rw-r--r-- | regress/sys/kern/noexec/noexec.c | 6 |
2 files changed, 20 insertions, 12 deletions
diff --git a/regress/sys/kern/noexec/Makefile b/regress/sys/kern/noexec/Makefile index 754e928cf85..b0110210278 100644 --- a/regress/sys/kern/noexec/Makefile +++ b/regress/sys/kern/noexec/Makefile @@ -1,14 +1,10 @@ -# $OpenBSD: Makefile,v 1.15 2016/09/01 10:12:35 tedu Exp $ +# $OpenBSD: Makefile,v 1.16 2017/07/18 23:00:31 bluhm Exp $ -.if ${MACHINE} == "sparc64" || \ - ${MACHINE} == "alpha" || ${MACHINE} == "armv7" || \ - ${MACHINE_ARCH} == "amd64" || ${MACHINE} == "i386" || \ - ${MACHINE} == "hppa" +PROG= noexec +SRCS= noexec.c testfly.S +CFLAGS= -Wall -fno-inline +LDSTATIC= ${STATIC} -PROG= noexec -SRCS= noexec.c testfly.S -CFLAGS+=-Wall -LDSTATIC= ${STATIC} REGRESS_TARGETS= nxtext-mmap nxtext-mprotect \ nxdata nxdata-mmap nxdata-mprotect \ nxbss nxbss-mmap nxbss-mprotect \ @@ -66,8 +62,16 @@ nxmmap: ${PROG} nxmmap-mprotect: ${PROG} @./${PROG} -m -p -.else -REGRESS_TARGETS= # this architecture has no test for this +.if ${MACHINE} != "alpha" && \ + ${MACHINE} != "amd64" && \ + ${MACHINE} != "armv7" && \ + ${MACHINE} != "hppa" && \ + ${MACHINE} != "i386" && \ + ${MACHINE} != "sparc64" +REGRESS_TARGETS=run-regress-skiparch +run-regress-skiparch: + # this architecture has no test for this + @echo SKIPPED .endif .include <bsd.regress.mk> diff --git a/regress/sys/kern/noexec/noexec.c b/regress/sys/kern/noexec/noexec.c index 6d8b047457a..6e3d70b5ba4 100644 --- a/regress/sys/kern/noexec/noexec.c +++ b/regress/sys/kern/noexec/noexec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: noexec.c,v 1.16 2016/09/24 07:26:14 otto Exp $ */ +/* $OpenBSD: noexec.c,v 1.17 2017/07/18 23:00:31 bluhm Exp $ */ /* * Copyright (c) 2002,2003 Michael Shalayeff @@ -120,6 +120,10 @@ getaddr(void *a) { void *ret; + /* + * Compile with -fno-inline to get reasonable result when comparing + * local variable address with caller's stack. + */ if ((void *)&ret < a) ret = (void *)((u_long)&ret - 4 * page_size); else |