From nobody Mon Jun 06 23:50:45 2022 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 1A3D41BD757C; Mon, 6 Jun 2022 23:50:45 +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 4LH9Gs2cbxz4Vn3; Mon, 6 Jun 2022 23:50:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654559445; 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=dTftdofoa0yrNDLbKEVbDkE6NVkxASsS9WD12Hgq7yY=; b=o603Wc1TTGdJKhrDE3aAwNCBdXl4OWfLkExOOPvEmf2r36waLDGrdkFSFE8ffjdrdvi28I V3xSYhESOXLC15HVSc77r6b7qL/XyigBy1CQGuDMzuusODPK2I0WUl4ImHyPcDSIH6QbJy rojPbfbtrEofMJl4sUs/A5W74s8wLL1kU9V1PHIjtNMobTsbM2QFaieZDb8j14sD5DvAwz VaKz9ZpEzcDqkdJu6TeuGvEQqZLjbgWwNpHG1n29O4Cdwi+5nTiE6NyDohZVaUA9iKKl97 JZd437p41C/YE9QhGZh7R5OyYkHqzLdvFh8Uj8y/MXLnVN23Vs1rUZmk/qvILg== 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 379E57BF9; Mon, 6 Jun 2022 23:50:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 256Noj0L038567; Mon, 6 Jun 2022 23:50:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 256NojG4038566; Mon, 6 Jun 2022 23:50:45 GMT (envelope-from git) Date: Mon, 6 Jun 2022 23:50:45 GMT Message-Id: <202206062350.256NojG4038566@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 81c857dd7e6a - main - gcore: Don't hardcode VM write permissions. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 81c857dd7e6a83924a8e45684fb94024fc3c929b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654559445; 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=dTftdofoa0yrNDLbKEVbDkE6NVkxASsS9WD12Hgq7yY=; b=S7QX07YMi9mtXxFxk3kPXHEzzUNZUiv8vUG6thDQHeS1tJzEkZynYmt/NT/mhO1+DmH9bP rhP27soPXJwR0d+Lr6yWBnx1+Q2NKoJ4c8CkOiVHwTwvwzl2BMNfKkQ80wJX6ixXArzJr6 S64EsSRyn/1X5mtnKAvhbetGV+X5kD56Miz7Cke8jE8IYfrO2iepGMGDR6Orj+REd8krzB Nmh37E5JHExY+qtNtT/Nds/hDD8lQXzqrIB9yVoGd/2JqoIMZhfVE/TicIU7vN7Hd2H+Yt L5gHflU0oTnC0ECchl1K43g7BeS0c5LSOSg1Lvlh4jPCDCsMWTSRxsQYV5MaMg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654559445; a=rsa-sha256; cv=none; b=ECpgT6VIHo0Xwl2UTbkBfgUWUSyP+CuG1SeN+a0wekbQnTc7ulzzJdViyvMMNoD7o5sty+ KqPPKb/KHrjUcNOoNXZGejxqShceuzrxgOE+e/TIKPbwkjthbhCE18+7aZpSDOSCTrRwyP gL5XMPNw7iC2cGgXMhgalzfwQWq3JhGofh1k2u+0Qmsjg0c9bry41JnwsEnauv4AMSMud6 gWGshGtclHBVN6Jio40J5n8xSmpGv8nl9QFr3qdsu1tQxY2WgAHFa9KMVi+FiVBzn0lEj4 V0ivRWmBAkZeCNFUfgYii9UFc1AbUk2DPsJpPr0YxM1dSTQRqML9dJDlJEXnJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=81c857dd7e6a83924a8e45684fb94024fc3c929b commit 81c857dd7e6a83924a8e45684fb94024fc3c929b Author: John Baldwin AuthorDate: 2022-06-06 23:43:02 +0000 Commit: John Baldwin CommitDate: 2022-06-06 23:43:02 +0000 gcore: Don't hardcode VM write permissions. This ensures read-only PT_LOAD segments are not marked as writable in the phdr flags. Reviewed by: markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D35398 --- usr.bin/gcore/elfcore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c index b0022d014e00..e5d7afd3f440 100644 --- a/usr.bin/gcore/elfcore.c +++ b/usr.bin/gcore/elfcore.c @@ -624,7 +624,9 @@ readmap(pid_t pid) errx(1, "out of memory"); ent->start = (vm_offset_t)kve->kve_start; ent->end = (vm_offset_t)kve->kve_end; - ent->protection = VM_PROT_READ | VM_PROT_WRITE; + ent->protection = VM_PROT_READ; + if ((kve->kve_protection & KVME_PROT_WRITE) != 0) + ent->protection |= VM_PROT_WRITE; if ((kve->kve_protection & KVME_PROT_EXEC) != 0) ent->protection |= VM_PROT_EXECUTE;