From owner-svn-src-all@freebsd.org Tue Oct 27 18:08:34 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C7F645682B; Tue, 27 Oct 2020 18:08:34 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CLKSy2F54z3yD9; Tue, 27 Oct 2020 18:08:34 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3017FFA16; Tue, 27 Oct 2020 18:08:34 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09RI8YAr035902; Tue, 27 Oct 2020 18:08:34 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09RI8Ypb035901; Tue, 27 Oct 2020 18:08:34 GMT (envelope-from alc@FreeBSD.org) Message-Id: <202010271808.09RI8Ypb035901@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Tue, 27 Oct 2020 18:08:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367087 - head/lib/libc/sys X-SVN-Group: head X-SVN-Commit-Author: alc X-SVN-Commit-Paths: head/lib/libc/sys X-SVN-Commit-Revision: 367087 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2020 18:08:34 -0000 Author: alc Date: Tue Oct 27 18:08:33 2020 New Revision: 367087 URL: https://svnweb.freebsd.org/changeset/base/367087 Log: Revise the description of MAP_STACK. In particular, describe the guard in more detail. Reviewed by: bcr, kib, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D26908 Modified: head/lib/libc/sys/mmap.2 Modified: head/lib/libc/sys/mmap.2 ============================================================================== --- head/lib/libc/sys/mmap.2 Tue Oct 27 17:25:40 2020 (r367086) +++ head/lib/libc/sys/mmap.2 Tue Oct 27 18:08:33 2020 (r367087) @@ -28,7 +28,7 @@ .\" @(#)mmap.2 8.4 (Berkeley) 5/11/95 .\" $FreeBSD$ .\" -.Dd October 21, 2020 +.Dd October 27, 2020 .Dt MMAP 2 .Os .Sh NAME @@ -319,9 +319,30 @@ Modifications are private. .It Dv MAP_SHARED Modifications are shared. .It Dv MAP_STACK +Creates both a mapped region that grows downward on demand and an +adjoining guard that both reserves address space for the mapped region +to grow into and limits the mapped region's growth. +Together, the mapped region and the guard occupy +.Fa len +bytes of the address space. +The guard starts at the returned address, and the mapped region ends at +the returned address plus +.Fa len +bytes. +Upon access to the guard, the mapped region automatically grows in size, +and the guard shrinks by an equal amount. +Essentially, the boundary between the guard and the mapped region moves +downward so that the access falls within the enlarged mapped region. +However, the guard will never shrink to less than the number of pages +specified by the sysctl +.Dv security.bsd.stack_guard_page , +thereby ensuring that a gap for detecting stack overflow always exists +between the downward growing mapped region and the closest mapped region +beneath it. +.Pp .Dv MAP_STACK implies -.Dv MAP_ANON , +.Dv MAP_ANON and .Fa offset of 0. @@ -334,23 +355,6 @@ must include at least .Dv PROT_READ and .Dv PROT_WRITE . -.Pp -This option creates -a memory region that grows to at most -.Fa len -bytes in size, starting from the stack top and growing down. -The -stack top is the starting address returned by the call, plus -.Fa len -bytes. -The bottom of the stack at maximum growth is the starting -address returned by the call. -.Pp -Stacks created with -.Dv MAP_STACK -automatically grow. -Guards prevent inadvertent use of the regions into which those -stacks can grow without requiring mapping the whole stack in advance. The size of the guard, in pages, is specified by sysctl .Dv security.bsd.stack_guard_page . .El