Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jul 2022 16:47:35 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4f8a3bb601ad - stable/13 - gcore: Don't hardcode VM write permissions.
Message-ID:  <202207131647.26DGlZGu052129@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4f8a3bb601adbca70d590593a53699dca590226d

commit 4f8a3bb601adbca70d590593a53699dca590226d
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-06-06 23:43:02 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
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;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207131647.26DGlZGu052129>