git: 409c2fa385aa - main - kinfo_vmentry: report max protection

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 08 Oct 2024 06:50:42 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=409c2fa385aa34baf7dd86bed2e86fbff16ad86d

commit 409c2fa385aa34baf7dd86bed2e86fbff16ad86d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-07 07:49:43 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-08 06:50:17 +0000

    kinfo_vmentry: report max protection
    
    Reviewed by:    brooks, markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D46971
---
 sys/kern/kern_proc.c | 6 ++++++
 sys/sys/user.h       | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 02d3b9fd69cd..422873ee14c2 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -2678,6 +2678,12 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags)
 			kve->kve_protection |= KVME_PROT_WRITE;
 		if (entry->protection & VM_PROT_EXECUTE)
 			kve->kve_protection |= KVME_PROT_EXEC;
+		if (entry->max_protection & VM_PROT_READ)
+			kve->kve_protection |= KVME_MAX_PROT_READ;
+		if (entry->max_protection & VM_PROT_WRITE)
+			kve->kve_protection |= KVME_MAX_PROT_WRITE;
+		if (entry->max_protection & VM_PROT_EXECUTE)
+			kve->kve_protection |= KVME_MAX_PROT_EXEC;
 
 		if (entry->eflags & MAP_ENTRY_COW)
 			kve->kve_flags |= KVME_FLAG_COW;
diff --git a/sys/sys/user.h b/sys/sys/user.h
index 1fd802b03a42..2025dc5cb47b 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -506,6 +506,9 @@ struct kinfo_lockf {
 #define	KVME_PROT_READ		0x00000001
 #define	KVME_PROT_WRITE		0x00000002
 #define	KVME_PROT_EXEC		0x00000004
+#define	KVME_MAX_PROT_READ	0x00010000
+#define	KVME_MAX_PROT_WRITE	0x00020000
+#define	KVME_MAX_PROT_EXEC	0x00040000
 
 #define	KVME_FLAG_COW		0x00000001
 #define	KVME_FLAG_NEEDS_COPY	0x00000002