diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2018-02-11 04:50:26 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2018-02-11 04:50:26 +0000 |
commit | f0bafd370452168f1e3dde5ae78daf0af7eea918 (patch) | |
tree | 4fd48cff20c3cb96d15a9aa520bf602bf50c00ed /lib/libc/sys | |
parent | bc743d53c94437d5751d53a7d552bab82a2f52af (diff) |
Document how MAP_STACK will be used. All stacks must be mmap'd with
this attribute. The kernel does so for main-process stacks at execve() time,
pthread stack functions do so for new stacks, and stacks provided to
sigaltstack() and other user-provided stacks will need to be allocated
in that way.
Not required yet, but paving the way.
Work done with stefan
Diffstat (limited to 'lib/libc/sys')
-rw-r--r-- | lib/libc/sys/mmap.2 | 9 | ||||
-rw-r--r-- | lib/libc/sys/sigaltstack.2 | 16 |
2 files changed, 20 insertions, 5 deletions
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index 37c82d786df..4ff05ab6d27 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -1,4 +1,4 @@ -.\" $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 @@ -30,7 +30,7 @@ .\" .\" @(#)mmap.2 8.1 (Berkeley) 6/4/93 .\" -.Dd $Mdocdate: January 12 2018 $ +.Dd $Mdocdate: February 11 2018 $ .Dt MMAP 2 .Os .Sh NAME @@ -153,6 +153,11 @@ mappings) 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 diff --git a/lib/libc/sys/sigaltstack.2 b/lib/libc/sys/sigaltstack.2 index 01f47dd4ef4..d00cdac48fc 100644 --- a/lib/libc/sys/sigaltstack.2 +++ b/lib/libc/sys/sigaltstack.2 @@ -1,4 +1,4 @@ -.\" $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 @@ -30,7 +30,7 @@ .\" .\" @(#)sigaltstack.2 8.1 (Berkeley) 6/4/93 .\" -.Dd $Mdocdate: May 31 2015 $ +.Dd $Mdocdate: February 11 2018 $ .Dt SIGALTSTACK 2 .Os .Sh NAME @@ -92,6 +92,15 @@ field will contain the value 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 @@ -99,7 +108,8 @@ is defined to be the number of bytes/chars that would be used to cover 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; |