From nobody Wed Jul 13 16:47:35 2022 X-Original-To: dev-commits-src-branches@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 5838717FBF55; Wed, 13 Jul 2022 16:47:35 +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 4Ljk7W258Nz3WJk; Wed, 13 Jul 2022 16:47:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657730855; 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=83vOc/WSr/yk2nXUla1eSrRTu2zVa6kzS2Bl1/QK1Ko=; b=QRQ2fEbjPZWx0FA3tY9v0nUG9Xdv7LKokEVU82lfP2/oHFh8YHS6rIjCD62bKscr0i0wKf r1RFoloWLqgE4mUiSbP0+aGs3qTBGVCM9IK4X3rJcvbKkhyf2MQ2eP3aJXkq9+u+ozzrAc cHWvWRcbufchg0BhoA7VwNtYyOWMLqAWmcwgOCWAL0HB2QVdDCE+zSYQZJYwH2JIO5c0ZN LKKx1N+GGzQlxP712SB4Wv5ZYccYvr4pXQGWlNIYzZ/TQQgecH5Nkgo/UOoMVuWdy08PeW UymOUkmP6MTp/1PZJol1ad/FFepu/hN71P7tzz8mwVjuVcbr0vQkjdpuwif5Xw== 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 4Ljk7W16t0zVLK; Wed, 13 Jul 2022 16:47:35 +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 26DGlZ34052130; Wed, 13 Jul 2022 16:47:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26DGlZGu052129; Wed, 13 Jul 2022 16:47:35 GMT (envelope-from git) Date: Wed, 13 Jul 2022 16:47:35 GMT Message-Id: <202207131647.26DGlZGu052129@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 4f8a3bb601ad - stable/13 - gcore: Don't hardcode VM write permissions. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 4f8a3bb601adbca70d590593a53699dca590226d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657730855; 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=83vOc/WSr/yk2nXUla1eSrRTu2zVa6kzS2Bl1/QK1Ko=; b=GOM9WxAwoFTXK5oY8ql6zXvNvWTQsHeavrV4hkFQL48udJHRDnPtqsjt4OJ6sqf4DsR1/l B/5M7Taae1gIx0iOyXdmWn7n3EY6sROR3SjVrYKlw4UsemBf95aqpi6nqO8BrbUlctjXZU PMB6KD9L2terWR2+h6ZusEg5AW5BHJWd4TpdJ9IxIcI0Z617eKRv3LY+uZIznqCvgfhUo3 TNxj2HzKVjSLrdBHaTA2rOHGmuWC2axEyptHz3w9tb/oEHohMXfc6BJcopDJHScaVz2lcI waHLZItaepioaSkbyfobjyp9FXR5Fll5z+ePbj/+oSmZTqys5oB5UvvyKfesjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657730855; a=rsa-sha256; cv=none; b=MzT3lpaS4CrvvrgVMtNzgK57K4/62iElY8RKW0iYO2Ly8cKNqUW/M096pYbOdIikvRQb0j 0VBqS4xikDT3II9sTOBpLXL+2O7LI04YWUnsxNQmJtx1P1uTfq/YSH6WodNVPoXxoGqyBM l5HDr8PzLxHKcJdl2XnfwNBSX8NK6TWykRNINscErUeRIzQIVHi/B0KWCmfX+Wn37axFqq i3bK7fPdvIHMfvJoWP/mzpkUvOExnIrTyJQ10AIdv10pF0opq7ZYhkpp3D2dbApHu051Es 8P4B0Iw9XoxJE5yiZfyBuMll9xYejt7nNWFpPF0j6sx8UMlwcYikyfJY8en4Gw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4f8a3bb601adbca70d590593a53699dca590226d commit 4f8a3bb601adbca70d590593a53699dca590226d Author: John Baldwin AuthorDate: 2022-06-06 23:43:02 +0000 Commit: John Baldwin CommitDate: 2022-07-13 16:18:43 +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 (cherry picked from commit 81c857dd7e6a83924a8e45684fb94024fc3c929b) --- 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;