The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] mm/mseal: Fix range_contains_unmapped() ignoring its mm argument
@ 2026-07-16  9:33 Hongfu Li
  2026-07-16 10:19 ` Lorenzo Stoakes (ARM)
  0 siblings, 1 reply; 3+ messages in thread
From: Hongfu Li @ 2026-07-16  9:33 UTC (permalink / raw)
  To: akpm, liam, ljs, vbabka, jannh, pfalcato, david, jeffxu
  Cc: linux-mm, linux-kernel, hongfu.li, Hongfu Li

From: Hongfu Li <lihongfu@kylinos.cn>

range_contains_unmapped() accepts an explicit struct mm_struct *mm
argument, yet hardcodes current->mm inside VMA_ITERATOR(), ignoring
the passed address space.

Its only caller do_mseal() currently passes current->mm, so the bug
does not manifest right now. However this mismatch between prototype
and implementation is a latent bug.

Replace current->mm with the passed mm parameter to match the
function prototype.

Fixes: 530e09096413 ("mm/mseal: simplify and rename VMA gap check")
Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
---
 mm/mseal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mseal.c b/mm/mseal.c
index 9781647483d1..8d82e50900ba 100644
--- a/mm/mseal.c
+++ b/mm/mseal.c
@@ -41,7 +41,7 @@ static bool range_contains_unmapped(struct mm_struct *mm,
 {
 	struct vm_area_struct *vma;
 	unsigned long prev_end = start;
-	VMA_ITERATOR(vmi, current->mm, start);
+	VMA_ITERATOR(vmi, mm, start);
 
 	for_each_vma_range(vmi, vma, end) {
 		if (vma->vm_start > prev_end)
-- 
2.54.0


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

* Re: [PATCH] mm/mseal: Fix range_contains_unmapped() ignoring its mm argument
  2026-07-16  9:33 [PATCH] mm/mseal: Fix range_contains_unmapped() ignoring its mm argument Hongfu Li
@ 2026-07-16 10:19 ` Lorenzo Stoakes (ARM)
  2026-07-17  1:34   ` Hongfu Li
  0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-07-16 10:19 UTC (permalink / raw)
  To: Hongfu Li
  Cc: akpm, liam, vbabka, jannh, pfalcato, david, jeffxu, linux-mm,
	linux-kernel, Hongfu Li

On Thu, Jul 16, 2026 at 05:33:47PM +0800, Hongfu Li wrote:
> From: Hongfu Li <lihongfu@kylinos.cn>
>
> range_contains_unmapped() accepts an explicit struct mm_struct *mm
> argument, yet hardcodes current->mm inside VMA_ITERATOR(), ignoring
> the passed address space.
>
> Its only caller do_mseal() currently passes current->mm, so the bug
> does not manifest right now. However this mismatch between prototype
> and implementation is a latent bug.
>
> Replace current->mm with the passed mm parameter to match the
> function prototype.
>
> Fixes: 530e09096413 ("mm/mseal: simplify and rename VMA gap check")

There's no point in a Fixes tag for something that's not a bug.

> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
> ---
>  mm/mseal.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/mseal.c b/mm/mseal.c
> index 9781647483d1..8d82e50900ba 100644
> --- a/mm/mseal.c
> +++ b/mm/mseal.c
> @@ -41,7 +41,7 @@ static bool range_contains_unmapped(struct mm_struct *mm,
>  {
>  	struct vm_area_struct *vma;
>  	unsigned long prev_end = start;
> -	VMA_ITERATOR(vmi, current->mm, start);
> +	VMA_ITERATOR(vmi, mm, start);

We're never going to sensibly allow a remote mm here, and even suggesting so is
problematic.

Sorry but I think it's just easier if I send a broader cleanup patch to fix
things up here more clearly.

>
>  	for_each_vma_range(vmi, vma, end) {
>  		if (vma->vm_start > prev_end)
> --
> 2.54.0
>

Thanks, Lorenzo

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

* Re: [PATCH] mm/mseal: Fix range_contains_unmapped() ignoring its mm argument
  2026-07-16 10:19 ` Lorenzo Stoakes (ARM)
@ 2026-07-17  1:34   ` Hongfu Li
  0 siblings, 0 replies; 3+ messages in thread
From: Hongfu Li @ 2026-07-17  1:34 UTC (permalink / raw)
  To: Lorenzo Stoakes (ARM)
  Cc: hongfu.li, akpm, liam, vbabka, jannh, pfalcato, david, jeffxu,
	linux-mm, linux-kernel, Hongfu Li

Hi,

On 7/16/26 6:19 PM, Lorenzo Stoakes (ARM) wrote:
> On Thu, Jul 16, 2026 at 05:33:47PM +0800, Hongfu Li wrote:
>> From: Hongfu Li <lihongfu@kylinos.cn>
>>
>> range_contains_unmapped() accepts an explicit struct mm_struct *mm
>> argument, yet hardcodes current->mm inside VMA_ITERATOR(), ignoring
>> the passed address space.
>>
>> Its only caller do_mseal() currently passes current->mm, so the bug
>> does not manifest right now. However this mismatch between prototype
>> and implementation is a latent bug.
>>
>> Replace current->mm with the passed mm parameter to match the
>> function prototype.
>>
>> Fixes: 530e09096413 ("mm/mseal: simplify and rename VMA gap check")
> There's no point in a Fixes tag for something that's not a bug.
>
>> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
>> ---
>>   mm/mseal.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/mseal.c b/mm/mseal.c
>> index 9781647483d1..8d82e50900ba 100644
>> --- a/mm/mseal.c
>> +++ b/mm/mseal.c
>> @@ -41,7 +41,7 @@ static bool range_contains_unmapped(struct mm_struct *mm,
>>   {
>>   	struct vm_area_struct *vma;
>>   	unsigned long prev_end = start;
>> -	VMA_ITERATOR(vmi, current->mm, start);
>> +	VMA_ITERATOR(vmi, mm, start);
> We're never going to sensibly allow a remote mm here, and even suggesting so is
> problematic.
>
> Sorry but I think it's just easier if I send a broader cleanup patch to fix
> things up here more clearly.
Got it, thanks a lot for explaining the issue with remote mm. A unified 
broad cleanup patch works better for this code path. I will withdraw my 
patch and follow your series. Feel free to reach out if you need any 
testing help later.
Best regards,
Hongfu

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

end of thread, other threads:[~2026-07-17  1:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  9:33 [PATCH] mm/mseal: Fix range_contains_unmapped() ignoring its mm argument Hongfu Li
2026-07-16 10:19 ` Lorenzo Stoakes (ARM)
2026-07-17  1:34   ` Hongfu Li

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