From nobody Fri Aug 25 01:08:32 2023 X-Original-To: dev-commits-src-all@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 4RX1zh719vz4qZs5; Fri, 25 Aug 2023 01:08:32 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RX1zh5qtYz4Smc; Fri, 25 Aug 2023 01:08:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692925712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tChOEE5Tl2gkV6nsf9hSCO1oXkhGkad0kgzqAzZZjkE=; b=uIzjGHV1P0J06LI3d/XF7i77lPr1XmhnK1NuDss0XAF1H7Ap7A0TzFJozoYfGMLkh9aLzO e/FgIoPt317zjNJJL6iY8tD7sBC+piQLL8w/1px8ih9ST1E1/kAnvYjyC2nhlkAaYhiEy7 muXlOw1oqbEMmNvAmOS8bO5UZ9r+4LZO/wMVkcrdDW+v9+5ZAHPk+e7Kvev6QAnhy+4lYL tDtNE5xTC6u8DjXfqljWHLzfkX0mauazy6pjtWnlH95qyLyEEkZ+SKGLVElGzMRgewdgd9 +458himO8xj0YbUMoCsfcYBau5X9N+JPU1Xc8Tjpg8rjQTt/YDSC1wceQEo1Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692925712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tChOEE5Tl2gkV6nsf9hSCO1oXkhGkad0kgzqAzZZjkE=; b=rWCthZrYRdXCEmLsyWl93sudrCnhM5iadHxg9tOOTC07PG4cLa1e+O5jt0zmn+vjpuA6uO h3lBYnuFDUgACth0bXJEV0Hgdb7IzPVFk2KV7+mSa3LSatPjA+mDPh8XNRPcEbf0i4iiHq SJwcHQUd4dqCuNWJ2Gv4b0yKtR54xMLbSDOthPw5lIzelJvG3K2jB8Ze2mM/oea+/0/Z2V 4QtU3Zd7MhYIl2Y7kuS5RlfenQqkQuLTXythgEFK4iOii7zDTw+HpN4Wm5xXD5XF+aBy4C BZHJDUxjjOsLoa58u8l9OcsrgqCdx1di0URTMGKFZhrwUvOLcdCnPNXbv9GkqQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692925712; a=rsa-sha256; cv=none; b=oShd5P6BzZtFjJPmbLDDd8/1BKiIh5LsIwZNmP/qItw4MkE6GO67ZV/4jw4F9mkiUYz0fo WTIXQwLe8NJbCSvjJIWtpu5sroBx6Ps3ghLbwPLXJuJsy54KHx2jIcht88kOEoVvKg0Hdz n8foTfgY0ikfl9Tmruzg1LhCpvbCiHyuhxJcnmkzxcYsdDiUaH1E02UBxNAw0Fszb4qHpQ y+ITK4BuMnPUtp55Bpubcic01walEgwaqEE91ofXOajgWPNNrjlbb649edkrXtkl48Q/wO ZwwK31e/HczjvxuMQj72nWcGjKQL9PSogEtmqNG678Cnuiscn5nI42fVjyJgGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RX1zh4wv8zpYy; Fri, 25 Aug 2023 01:08:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37P18WNe058298; Fri, 25 Aug 2023 01:08:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37P18Wtu058295; Fri, 25 Aug 2023 01:08:32 GMT (envelope-from git) Date: Fri, 25 Aug 2023 01:08:32 GMT Message-Id: <202308250108.37P18Wtu058295@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f28d489aaaa4 - stable/13 - vm_map_protect(): move guard handling at the last phase into an empty dedicated helper List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f28d489aaaa417afe984a096dfbfecbfb6b2a695 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f28d489aaaa417afe984a096dfbfecbfb6b2a695 commit f28d489aaaa417afe984a096dfbfecbfb6b2a695 Author: Konstantin Belousov AuthorDate: 2023-07-28 00:14:07 +0000 Commit: Konstantin Belousov CommitDate: 2023-08-25 01:06:44 +0000 vm_map_protect(): move guard handling at the last phase into an empty dedicated helper (cherry picked from commit 79169929f04d00e51a901d1e4cb377d2475bf660) --- sys/vm/vm_map.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index d4e4f2c89679..d443c320b799 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2716,6 +2716,13 @@ vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, VM_OBJECT_RUNLOCK(object); } +static void +vm_map_protect_guard(vm_map_entry_t entry, vm_prot_t new_prot, + vm_prot_t new_maxprot, int flags) +{ + MPASS((entry->eflags & MAP_ENTRY_GUARD) != 0); +} + /* * vm_map_protect: * @@ -2774,12 +2781,13 @@ again: check_prot |= new_maxprot; for (entry = first_entry; entry->start < end; entry = vm_map_entry_succ(entry)) { - if ((entry->eflags & MAP_ENTRY_GUARD) != 0) - continue; if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) != 0) { vm_map_unlock(map); return (KERN_INVALID_ARGUMENT); } + if ((entry->eflags & MAP_ENTRY_GUARD) != 0) { + continue; + } if (!CONTAINS_BITS(entry->max_protection, check_prot)) { vm_map_unlock(map); return (KERN_PROTECTION_FAILURE); @@ -2879,10 +2887,15 @@ again: entry->start < end; vm_map_try_merge_entries(map, prev_entry, entry), prev_entry = entry, entry = vm_map_entry_succ(entry)) { - if (rv != KERN_SUCCESS || - (entry->eflags & MAP_ENTRY_GUARD) != 0) + if (rv != KERN_SUCCESS) continue; + if ((entry->eflags & MAP_ENTRY_GUARD) != 0) { + vm_map_protect_guard(entry, new_prot, new_maxprot, + flags); + continue; + } + old_prot = entry->protection; if ((flags & VM_MAP_PROTECT_SET_MAXPROT) != 0) {