[PATCH 3/4] /proc/pid/smaps: add mseal info for vma

jeffxu at chromium.org jeffxu at chromium.org
Wed Nov 27 20:29:01 UTC 2024


From: Jeff Xu <jeffxu at chromium.org>

Add sl in /proc/pid/smaps to indicate vma is sealed

Link: https://lkml.kernel.org/r/20240614232014.806352-2-jeffxu@google.com
Fixes: 8be7258aad44 ("mseal: add mseal syscall")
Signed-off-by: Jeff Xu <jeffxu at chromium.org>
Acked-by: David Hildenbrand <david at redhat.com>
Cc: Adhemerval Zanella <adhemerval.zanella at linaro.org>
Cc: Jann Horn <jannh at google.com>
Cc: Jorge Lucangeli Obes <jorgelo at chromium.org>
Cc: Kees Cook <keescook at chromium.org>
Cc: Randy Dunlap <rdunlap at infradead.org>
Cc: Stephen Röttger <sroettger at google.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
(cherry picked from commit 399ab86ea55039f9d0a5f621a68cb4631f796f37)

Signed-off-by: Jeff Xu <jeffxu at chromium.org>

---
 Documentation/filesystems/proc.rst | 1 +
 fs/proc/task_mmu.c                 | 3 +++
 include/linux/mm.h                 | 5 +++++
 mm/internal.h                      | 5 -----
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
index 104c6d047d9b..ac1c3461889a 100644
--- a/Documentation/filesystems/proc.rst
+++ b/Documentation/filesystems/proc.rst
@@ -571,6 +571,7 @@ encoded manner. The codes are the following:
     um    userfaultfd missing tracking
     uw    userfaultfd wr-protect tracking
     ss    shadow stack page
+    sl    sealed
     ==    =======================================
 
 Note that there is no guarantee that every flag and associated mnemonic will
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 8433f076e987..5bccfda4751e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -702,6 +702,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
 #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */
 #ifdef CONFIG_X86_USER_SHADOW_STACK
 		[ilog2(VM_SHADOW_STACK)] = "ss",
+#endif
+#ifdef CONFIG_64BIT
+		[ilog2(VM_SEALED)] = "sl",
 #endif
 	};
 	size_t i;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index adbab01e2e90..b269af7f2495 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -391,6 +391,11 @@ extern unsigned int kobjsize(const void *objp);
 # define VM_UFFD_MINOR		VM_NONE
 #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */
 
+#ifdef CONFIG_64BIT
+/* VM is sealed, in vm_flags */
+#define VM_SEALED	_BITUL(63)
+#endif
+
 /* Bits set in the VMA until the stack is in its final location */
 #define VM_STACK_INCOMPLETE_SETUP (VM_RAND_READ | VM_SEQ_READ | VM_STACK_EARLY)
 
diff --git a/mm/internal.h b/mm/internal.h
index e78089a226a5..4584c15a3e54 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1223,11 +1223,6 @@ void __meminit __init_single_page(struct page *page, unsigned long pfn,
 unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg,
 			  int priority);
 
-#ifdef CONFIG_64BIT
-/* VM is sealed, in vm_flags */
-#define VM_SEALED	_BITUL(63)
-#endif
-
 #ifdef CONFIG_64BIT
 static inline int can_do_mseal(unsigned long flags)
 {
-- 
2.47.0.338.g60cca15819-goog




More information about the kernel-team mailing list