git: a1ae801880ef - stable/14 - kinfo_vmentry: report max protection

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 15 Oct 2024 15:05:29 UTC
The branch stable/14 has been updated by kib:

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

commit a1ae801880ef64e2c2fd7ca51744ff86611df313
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-07 07:49:43 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-15 14:50:16 +0000

    kinfo_vmentry: report max protection
    
    (cherry picked from commit 409c2fa385aa34baf7dd86bed2e86fbff16ad86d)
---
 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 d20fc0ac4e9a..17d002a29c77 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -2679,6 +2679,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 47f2984b1eff..4ca80741ad5a 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -508,6 +508,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