Re: [PATCH v2 0/3] mm/mseal: further cleanups

From: Andrew Morton

Date: Fri Jul 17 2026 - 15:40:05 EST


On Fri, 17 Jul 2026 18:27:08 +0100 "Lorenzo Stoakes (ARM)" <ljs@xxxxxxxxxx> 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);
}
_