-.\" $OpenBSD: mmap.2,v 1.57 2018/01/12 04:36:44 deraadt Exp $
+.\" $OpenBSD: mmap.2,v 1.58 2018/02/11 04:50:25 deraadt Exp $
.\" $NetBSD: mmap.2,v 1.5 1995/06/24 10:48:59 cgd Exp $
.\"
.\" Copyright (c) 1991, 1993
.\"
.\" @(#)mmap.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd $Mdocdate: January 12 2018 $
+.Dd $Mdocdate: February 11 2018 $
.Dt MMAP 2
.Os
.Sh NAME
must be multiples of the page size.
Existing mappings in the address range will be replaced.
Use of this option is discouraged.
+.It Dv MAP_STACK
+Indicate that the mapping is used as a stack.
+This flag must be used in combination with
+.Dv MAP_ANON and
+.Dv MAP_PRIVATE .
.El
.Pp
Finally, the following flags are also provided for
-.\" $OpenBSD: sigaltstack.2,v 1.19 2015/05/31 23:54:25 schwarze Exp $
+.\" $OpenBSD: sigaltstack.2,v 1.20 2018/02/11 04:50:25 deraadt Exp $
.\" $NetBSD: sigaltstack.2,v 1.3 1995/02/27 10:41:52 cgd Exp $
.\"
.\" Copyright (c) 1983, 1991, 1992, 1993
.\"
.\" @(#)sigaltstack.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd $Mdocdate: May 31 2015 $
+.Dd $Mdocdate: February 11 2018 $
.Dt SIGALTSTACK 2
.Os
.Sh NAME
if the thread is currently on a signal stack and
.Dv SS_DISABLE
if the signal stack is currently disabled.
+.Pp
+The stack must be allocated using
+.Xr mmap 2
+with
+.Ar MAP_STACK
+to inform the kernel that the memory is being used as a stack.
+Otherwise, the first system call performed while operating on
+that stack will deliver
+.Dv SIGABRT .
.Sh NOTES
The value
.Dv SIGSTKSZ
the usual case when allocating an alternate stack area.
The following code fragment is typically used to allocate an alternate stack.
.Bd -literal -offset indent
-if ((sigstk.ss_sp = malloc(SIGSTKSZ)) == NULL)
+if ((sigstk.ss_sp = mmap(NULL, SIGSTKSZ, PROT_WRITE | PROT_READ,
+ MAP_PRIVATE | MAP_ANON | MAP_STACK, -1, 0)) == NULL)
/* error return */
sigstk.ss_size = SIGSTKSZ;
sigstk.ss_flags = 0;