linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/1] add mseal to /proc/pid/smaps
@ 2024-06-14 18:23 jeffxu
  2024-06-14 18:23 ` [PATCH v1 1/1] /proc/pid/smaps: add mseal info for vma jeffxu
  0 siblings, 1 reply; 5+ messages in thread
From: jeffxu @ 2024-06-14 18:23 UTC (permalink / raw)
  To: akpm, jannh, sroettger, rdunlap, david, adhemerval.zanella
  Cc: linux-kernel, linux-mm, jorgelo, keescook, Jeff Xu

From: Jeff Xu <jeffxu@chromium.org>

Add mseal information in /proc/pid/smaps to indicate the VMA is sealed.

I appreicate Adhemerval Zanella Netto to bring this to my attention. [1]

[1] https://public-inbox.org/libc-alpha/743ac2ce-817b-42ef-a0a1-7edf9a85d8e5@linaro.org/#t


Jeff Xu (1):
  /proc/pid/smaps: add mseal info for vma

 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(-)

-- 
2.45.2.627.g7a2c4fd464-goog



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1 1/1] /proc/pid/smaps: add mseal info for vma
  2024-06-14 18:23 [PATCH v1 0/1] add mseal to /proc/pid/smaps jeffxu
@ 2024-06-14 18:23 ` jeffxu
  2024-06-14 18:42   ` Jann Horn
  0 siblings, 1 reply; 5+ messages in thread
From: jeffxu @ 2024-06-14 18:23 UTC (permalink / raw)
  To: akpm, jannh, sroettger, rdunlap, david, adhemerval.zanella
  Cc: linux-kernel, linux-mm, jorgelo, keescook, Jeff Xu

From: Jeff Xu <jeffxu@chromium.org>

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

Signed-off-by: Jeff Xu <jeffxu@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 7c3a565ffbef..400217a1589c 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
+    sp    sealed page
     ==    =======================================
 
 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 6ed1f56b32b4..ba2db75ca22a 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -711,6 +711,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)] = "sp",
 #endif
 	};
 	size_t i;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 587d34879865..8600564898fa 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -314,6 +314,11 @@ extern unsigned int kobjsize(const void *objp);
 #define VM_NOHUGEPAGE	0x40000000	/* MADV_NOHUGEPAGE marked this vma */
 #define VM_MERGEABLE	0x80000000	/* KSM may merge identical pages */
 
+#ifdef CONFIG_64BIT
+/* VM is sealed, in vm_flags */
+#define VM_SEALED	_BITUL(63)
+#endif
+
 #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
 #define VM_HIGH_ARCH_BIT_0	32	/* bit only usable on 64-bit architectures */
 #define VM_HIGH_ARCH_BIT_1	33	/* bit only usable on 64-bit architectures */
diff --git a/mm/internal.h b/mm/internal.h
index fd68c43664d5..72f7c110d563 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1509,11 +1509,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.45.2.627.g7a2c4fd464-goog



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] /proc/pid/smaps: add mseal info for vma
  2024-06-14 18:23 ` [PATCH v1 1/1] /proc/pid/smaps: add mseal info for vma jeffxu
@ 2024-06-14 18:42   ` Jann Horn
  2024-06-14 19:00     ` Jeff Xu
  2024-06-14 19:06     ` Jeff Xu
  0 siblings, 2 replies; 5+ messages in thread
From: Jann Horn @ 2024-06-14 18:42 UTC (permalink / raw)
  To: jeffxu
  Cc: akpm, sroettger, rdunlap, david, adhemerval.zanella,
	linux-kernel, linux-mm, jorgelo, keescook

Hi!

On Fri, Jun 14, 2024 at 8:24 PM <jeffxu@chromium.org> wrote:
> Add sp in /proc/pid/smaps to indicate vma is sealed
>
> Signed-off-by: Jeff Xu <jeffxu@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 7c3a565ffbef..400217a1589c 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
> +    sp    sealed page

Nit: Why "page"? The sealing is a property of the VMA, not of the
pages mapped into it. Maybe "sealed area" and an abbreviation like
"sl" would make sense?

> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 587d34879865..8600564898fa 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -314,6 +314,11 @@ extern unsigned int kobjsize(const void *objp);
>  #define VM_NOHUGEPAGE  0x40000000      /* MADV_NOHUGEPAGE marked this vma */
>  #define VM_MERGEABLE   0x80000000      /* KSM may merge identical pages */
>
> +#ifdef CONFIG_64BIT
> +/* VM is sealed, in vm_flags */
> +#define VM_SEALED      _BITUL(63)
> +#endif
> +
>  #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
>  #define VM_HIGH_ARCH_BIT_0     32      /* bit only usable on 64-bit architectures */
>  #define VM_HIGH_ARCH_BIT_1     33      /* bit only usable on 64-bit architectures */

Other 64-bit flags are defined further down; maybe it would make sense
to move this definition below the definition of VM_ALLOW_ANY_UNCACHED,
so that the definitions are sorted by the number of the bit?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] /proc/pid/smaps: add mseal info for vma
  2024-06-14 18:42   ` Jann Horn
@ 2024-06-14 19:00     ` Jeff Xu
  2024-06-14 19:06     ` Jeff Xu
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Xu @ 2024-06-14 19:00 UTC (permalink / raw)
  To: Jann Horn
  Cc: akpm, sroettger, rdunlap, david, adhemerval.zanella,
	linux-kernel, linux-mm, jorgelo, keescook

On Fri, Jun 14, 2024 at 11:43 AM Jann Horn <jannh@google.com> wrote:
>
> Hi!
>
> On Fri, Jun 14, 2024 at 8:24 PM <jeffxu@chromium.org> wrote:
> > Add sp in /proc/pid/smaps to indicate vma is sealed
> >
> > Signed-off-by: Jeff Xu <jeffxu@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 7c3a565ffbef..400217a1589c 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
> > +    sp    sealed page
>
> Nit: Why "page"? The sealing is a property of the VMA, not of the
> pages mapped into it. Maybe "sealed area" and an abbreviation like
> "sl" would make sense?
>
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index 587d34879865..8600564898fa 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -314,6 +314,11 @@ extern unsigned int kobjsize(const void *objp);
> >  #define VM_NOHUGEPAGE  0x40000000      /* MADV_NOHUGEPAGE marked this vma */
> >  #define VM_MERGEABLE   0x80000000      /* KSM may merge identical pages */
> >
> > +#ifdef CONFIG_64BIT
> > +/* VM is sealed, in vm_flags */
> > +#define VM_SEALED      _BITUL(63)
> > +#endif
> > +
> >  #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
> >  #define VM_HIGH_ARCH_BIT_0     32      /* bit only usable on 64-bit architectures */
> >  #define VM_HIGH_ARCH_BIT_1     33      /* bit only usable on 64-bit architectures */
>
> Other 64-bit flags are defined further down; maybe it would make sense
> to move this definition below the definition of VM_ALLOW_ANY_UNCACHED,
> so that the definitions are sorted by the number of the bit?

Sure.  I will update.

Thanks!
-Jeff


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] /proc/pid/smaps: add mseal info for vma
  2024-06-14 18:42   ` Jann Horn
  2024-06-14 19:00     ` Jeff Xu
@ 2024-06-14 19:06     ` Jeff Xu
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Xu @ 2024-06-14 19:06 UTC (permalink / raw)
  To: Jann Horn
  Cc: akpm, sroettger, rdunlap, david, adhemerval.zanella,
	linux-kernel, linux-mm, jorgelo, keescook

On Fri, Jun 14, 2024 at 11:43 AM Jann Horn <jannh@google.com> wrote:
>
> Hi!
>
> On Fri, Jun 14, 2024 at 8:24 PM <jeffxu@chromium.org> wrote:
> > Add sp in /proc/pid/smaps to indicate vma is sealed
> >
> > Signed-off-by: Jeff Xu <jeffxu@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 7c3a565ffbef..400217a1589c 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
> > +    sp    sealed page
>
> Nit: Why "page"? The sealing is a property of the VMA, not of the
> pages mapped into it. Maybe "sealed area" and an abbreviation like
> "sl" would make sense?
>
ok. Maybe just sealed for short:

sl  "sealed"

Thanks
-Jeff


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-14 19:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14 18:23 [PATCH v1 0/1] add mseal to /proc/pid/smaps jeffxu
2024-06-14 18:23 ` [PATCH v1 1/1] /proc/pid/smaps: add mseal info for vma jeffxu
2024-06-14 18:42   ` Jann Horn
2024-06-14 19:00     ` Jeff Xu
2024-06-14 19:06     ` Jeff Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox