From e1fef5f107295699125891e2fb86272504a8c3b8 Mon Sep 17 00:00:00 2001 From: deraadt Date: Sat, 22 Jun 2024 17:19:05 +0000 Subject: [PATCH] lower parts of the manual page clearly say why using malloc() to allocate sigaltstack regions is bad... so the example code should not use malloc()... ok semarie --- lib/libc/sys/sigaltstack.2 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libc/sys/sigaltstack.2 b/lib/libc/sys/sigaltstack.2 index cb042c49faa..e1fe4ab868d 100644 --- a/lib/libc/sys/sigaltstack.2 +++ b/lib/libc/sys/sigaltstack.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sigaltstack.2,v 1.27 2024/03/29 06:48:04 deraadt Exp $ +.\" $OpenBSD: sigaltstack.2,v 1.28 2024/06/22 17:19:05 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: March 29 2024 $ +.Dd $Mdocdate: June 22 2024 $ .Dt SIGALTSTACK 2 .Os .Sh NAME @@ -99,7 +99,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_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) /* error return */ sigstk.ss_size = SIGSTKSZ; sigstk.ss_flags = 0; -- 2.20.1