From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Jann Horn <jannh@google.com>, Pedro Falcato <pfalcato@suse.de>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Kees Cook <kees@kernel.org>,
David Hildenbrand <david@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
"Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Subject: [PATCH 1/3] mm/mseal: remove superfluous comments, fix confusion around mm
Date: Thu, 16 Jul 2026 14:43:09 +0100 [thread overview]
Message-ID: <20260716-mseal-fixups-v1-1-3a9609bf041b@kernel.org> (raw)
In-Reply-To: <20260716-mseal-fixups-v1-0-3a9609bf041b@kernel.org>
Remove comment blocks that don't add value and eliminate any confusion
about whether or not we permit mseal()'ing of remote mm's by explicitly
referencing current->mm consistently.
Also avoid ugly goto by using an else branch.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
mm/mseal.c | 48 ++++++++----------------------------------------
1 file changed, 8 insertions(+), 40 deletions(-)
diff --git a/mm/mseal.c b/mm/mseal.c
index 9781647483d1..207fea89c61e 100644
--- a/mm/mseal.c
+++ b/mm/mseal.c
@@ -16,28 +16,7 @@
#include <linux/sched.h>
#include "internal.h"
-/*
- * mseal() disallows an input range which contain unmapped ranges (VMA holes).
- *
- * It disallows unmapped regions from start to end whether they exist at the
- * start, in the middle, or at the end of the range, or any combination thereof.
- *
- * This is because after sealing a range, there's nothing to stop memory mapping
- * of ranges in the remaining gaps later, meaning that the user might then
- * wrongly consider the entirety of the mseal()'d range to be sealed when it
- * in fact isn't.
- */
-
-/*
- * Does the [start, end) range contain any unmapped memory?
- *
- * We ensure that:
- * - start is part of a valid VMA.
- * - end is part of a valid VMA.
- * - no gap (unallocated memory) exists between start and end.
- */
-static bool range_contains_unmapped(struct mm_struct *mm,
- unsigned long start, unsigned long end)
+static bool range_contains_unmapped(unsigned long start, unsigned long end)
{
struct vm_area_struct *vma;
unsigned long prev_end = start;
@@ -53,11 +32,10 @@ static bool range_contains_unmapped(struct mm_struct *mm,
return prev_end < end;
}
-static int mseal_apply(struct mm_struct *mm,
- unsigned long start, unsigned long end)
+static int mseal_apply(unsigned long start, unsigned long end)
{
struct vm_area_struct *vma, *prev;
- VMA_ITERATOR(vmi, mm, start);
+ VMA_ITERATOR(vmi, current->mm, start);
/* We know there are no gaps so this will be non-NULL. */
vma = vma_iter_load(&vmi);
@@ -145,7 +123,6 @@ int do_mseal(unsigned long start, size_t len_in, unsigned long flags)
size_t len;
int ret = 0;
unsigned long end;
- struct mm_struct *mm = current->mm;
/* Verify flags not set. */
if (flags)
@@ -167,24 +144,15 @@ int do_mseal(unsigned long start, size_t len_in, unsigned long flags)
if (end == start)
return 0;
- if (mmap_write_lock_killable(mm))
+ if (mmap_write_lock_killable(current->mm))
return -EINTR;
- if (range_contains_unmapped(mm, start, end)) {
+ if (range_contains_unmapped(start, end))
ret = -ENOMEM;
- goto out;
- }
-
- /*
- * Second pass, this should success, unless there are errors
- * from vma_modify_flags, e.g. merge/split error, or process
- * reaching the max supported VMAs, however, those cases shall
- * be rare.
- */
- ret = mseal_apply(mm, start, end);
+ else
+ ret = mseal_apply(start, end);
-out:
- mmap_write_unlock(mm);
+ mmap_write_unlock(current->mm);
return ret;
}
--
2.55.0
next prev parent reply other threads:[~2026-07-16 13:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 13:43 [PATCH 0/3] mm/mseal: further cleanups Lorenzo Stoakes (ARM)
2026-07-16 13:43 ` Lorenzo Stoakes (ARM) [this message]
2026-07-16 15:00 ` [PATCH 1/3] mm/mseal: remove superfluous comments, fix confusion around mm Pedro Falcato
2026-07-17 10:33 ` David Hildenbrand (Arm)
2026-07-17 10:44 ` Lorenzo Stoakes (ARM)
2026-07-16 13:43 ` [PATCH 2/3] mm/mseal: limit scope of mseal address zero to address zero Lorenzo Stoakes (ARM)
2026-07-16 15:06 ` Pedro Falcato
2026-07-16 15:38 ` Lorenzo Stoakes (ARM)
2026-07-17 10:41 ` David Hildenbrand (Arm)
2026-07-17 10:51 ` Lorenzo Stoakes (ARM)
2026-07-17 10:46 ` David Hildenbrand (Arm)
2026-07-17 10:49 ` David Hildenbrand (Arm)
2026-07-17 10:52 ` Lorenzo Stoakes (ARM)
2026-07-16 13:43 ` [PATCH 3/3] mm/mseal: remove further superfluous comments, do_mseal() Lorenzo Stoakes (ARM)
2026-07-16 15:09 ` Pedro Falcato
2026-07-16 15:13 ` Lorenzo Stoakes (ARM)
2026-07-17 0:33 ` Andrew Morton
2026-07-17 11:06 ` Lorenzo Stoakes (ARM)
2026-07-17 10:50 ` David Hildenbrand (Arm)
2026-07-17 10:55 ` Lorenzo Stoakes (ARM)
2026-07-16 13:48 ` [PATCH 0/3] mm/mseal: further cleanups Lorenzo Stoakes (ARM)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260716-mseal-fixups-v1-1-3a9609bf041b@kernel.org \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david@kernel.org \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=kees@kernel.org \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=pfalcato@suse.de \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox