From nobody Thu Jul 20 20:49:21 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4R6Ptx23nvz4dWBp; Thu, 20 Jul 2023 20:49:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4R6Ptw5DcWz3h5H; Thu, 20 Jul 2023 20:49:28 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.17.1/8.17.1) with ESMTPS id 36KKnLiY097890 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 20 Jul 2023 23:49:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 36KKnLiY097890 Received: (from kostik@localhost) by tom.home (8.17.1/8.17.1/Submit) id 36KKnL6x097889; Thu, 20 Jul 2023 23:49:21 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 20 Jul 2023 23:49:21 +0300 From: Konstantin Belousov To: Brooks Davis Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 21e45c30c35c - main - mmap(MAP_STACK): on stack grow, use original protection Message-ID: References: <202307201412.36KECDSU084918@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on tom.home X-Rspamd-Queue-Id: 4R6Ptw5DcWz3h5H X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated On Thu, Jul 20, 2023 at 08:15:15PM +0000, Brooks Davis wrote: > On Thu, Jul 20, 2023 at 02:12:13PM +0000, Konstantin Belousov wrote: > > The branch main has been updated by kib: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=21e45c30c35c9aa732073f725924caf581c93460 > > > > commit 21e45c30c35c9aa732073f725924caf581c93460 > > Author: Konstantin Belousov > > AuthorDate: 2023-07-19 11:05:32 +0000 > > Commit: Konstantin Belousov > > CommitDate: 2023-07-20 14:11:42 +0000 > > > > mmap(MAP_STACK): on stack grow, use original protection > > > > If mprotect(2) changed protection in the bottom of the currently grown > > stack region, currently the changed protection would be used for the > > stack grow on next fault. This is arguably unexpected. > > > > Store the original protection for the entry at mmap(2) time in the > > offset member of the gap vm_map_entry, and use it for protection of the > > grown stack region. > > It occured to me to wonder how this interacts with > __enable_execute_stack(). I think it's ok so long as the compiler > always emits __enable_execute_stack() for each trampoline and doesn't > depend on extentions to the stack being executable from the first > trampoline creation, but I don't know where to look to verify that's the > case. Even on first trampoline creation, compiler cannot know how much was the stack grown already. So the generated code cannot be sure that it changing the protection for the bottom stack page. Then, it cannot work even for more usual stack grow organization.