fs/binfmt_elf.c | 7 +-- include/linux/mm.h | 8 +-- mm/mseal.c | 160 ++++++++++++++++++----------------------------------- 3 files changed, 58 insertions(+), 117 deletions(-)
The mseal implementation is still rather confusing, so tighten things up a
little.
The only user of do_mseal() outside of the system call is the MMAP_PAGE_ZERO
process personality - retain better control over how mseal is utilised by
providing mseal_mmap_page_zero() for this instead.
The comments are overly long and confusion, so cut them down so they're a lot
clearer.
Remove confusing mm_struct params (mseal can not be used on remote mm's) and
wrap the actual system call logic into the system call declaration.
---
v2:
* Added tags (thanks everyone!)
* Abstracted mm as per David.
* Renamed [__]mseal() to [__]mseal_range() as per Pedro.
* Moved to reverse xmas tree declarations.
* Tweaked commit message for 2/3.
v1:
https://patch.msgid.link/20260716-mseal-fixups-v1-0-3a9609bf041b@kernel.org
To: Andrew Morton <akpm@linux-foundation.org>
To: "Liam R. Howlett" <liam@infradead.org>
To: Vlastimil Babka <vbabka@kernel.org>
To: Jann Horn <jannh@google.com>
To: Pedro Falcato <pfalcato@suse.de>
To: Alexander Viro <viro@zeniv.linux.org.uk>
To: Christian Brauner <brauner@kernel.org>
To: Jan Kara <jack@suse.cz>
To: Kees Cook <kees@kernel.org>
To: David Hildenbrand <david@kernel.org>
To: Mike Rapoport <rppt@kernel.org>
To: Suren Baghdasaryan <surenb@google.com>
To: Michal Hocko <mhocko@suse.com>
Cc: ljs@kernel.org
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
---
Lorenzo Stoakes (ARM) (3):
mm/mseal: remove superfluous comments, fix confusion around mm
mm/mseal: limit scope of mseal address zero to address zero
mm/mseal: remove further superfluous comments, do_mseal()
fs/binfmt_elf.c | 7 +--
include/linux/mm.h | 8 +--
mm/mseal.c | 160 ++++++++++++++++++-----------------------------------
3 files changed, 58 insertions(+), 117 deletions(-)
---
base-commit: 59c684a9908d2e6f7a791f7f033eae57ec2b3a61
change-id: 20260716-mseal-fixups-131ad0939de2
Cheers,
--
Lorenzo Stoakes (ARM) <ljs@kernel.org>
On Fri, 17 Jul 2026 18:27:08 +0100 "Lorenzo Stoakes (ARM)" <ljs@kernel.org> wrote:
>
> The mseal implementation is still rather confusing, so tighten things up a
> little.
>
> The only user of do_mseal() outside of the system call is the MMAP_PAGE_ZERO
> process personality - retain better control over how mseal is utilised by
> providing mseal_mmap_page_zero() for this instead.
>
> The comments are overly long and confusion, so cut them down so they're a lot
> clearer.
>
> Remove confusing mm_struct params (mseal can not be used on remote mm's) and
> wrap the actual system call logic into the system call declaration.
Thanks, I've updated mm-new to this version.
> v2:
> * Added tags (thanks everyone!)
> * Abstracted mm as per David.
> * Renamed [__]mseal() to [__]mseal_range() as per Pedro.
> * Moved to reverse xmas tree declarations.
> * Tweaked commit message for 2/3.
Here's how v2 altered mm.git:
mm/mseal.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
--- a/mm/mseal.c~b
+++ a/mm/mseal.c
@@ -18,9 +18,9 @@
static bool range_contains_unmapped(unsigned long start, unsigned long end)
{
- struct vm_area_struct *vma;
- unsigned long prev_end = start;
VMA_ITERATOR(vmi, current->mm, start);
+ unsigned long prev_end = start;
+ struct vm_area_struct *vma;
for_each_vma_range(vmi, vma, end) {
if (vma->vm_start > prev_end)
@@ -32,10 +32,10 @@ static bool range_contains_unmapped(unsi
return prev_end < end;
}
-static int __mseal(unsigned long start, unsigned long end)
+static int __mseal_range(unsigned long start, unsigned long end)
{
- struct vm_area_struct *vma, *prev;
VMA_ITERATOR(vmi, current->mm, start);
+ struct vm_area_struct *vma, *prev;
/* We know there are no gaps so this will be non-NULL. */
vma = vma_iter_load(&vmi);
@@ -66,7 +66,7 @@ static int __mseal(unsigned long start,
return 0;
}
-static int mseal(unsigned long start, unsigned long end)
+static int mseal_range(unsigned long start, unsigned long end)
{
int err;
@@ -76,7 +76,7 @@ static int mseal(unsigned long start, un
if (range_contains_unmapped(start, end))
err = -ENOMEM;
else
- err = __mseal(start, end);
+ err = __mseal_range(start, end);
mmap_write_unlock(current->mm);
return err;
}
@@ -92,7 +92,7 @@ void mseal_mmap_page_zero(void)
if (WARN_ON_ONCE(!(current->personality & MMAP_PAGE_ZERO)))
return;
- err = mseal(0, PAGE_SIZE);
+ err = mseal_range(0, PAGE_SIZE);
if (err)
pr_warn_ratelimited("pid=%d, couldn't seal address 0, ret=%d.\n",
task_pid_nr(current), err);
@@ -139,5 +139,5 @@ SYSCALL_DEFINE3(mseal, unsigned long, st
if (end == start)
return 0;
- return mseal(start, end);
+ return mseal_range(start, end);
}
_
© 2016 - 2026 Red Hat, Inc.