linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mprotect: Fix successful vma_merge() of next in do_mprotect_pkey()
@ 2023-02-24 21:20 Liam R. Howlett
  2023-02-24 22:53 ` Bert Karwatzki
  0 siblings, 1 reply; 2+ messages in thread
From: Liam R. Howlett @ 2023-02-24 21:20 UTC (permalink / raw)
  To: maple-tree, linux-mm, linux-kernel, Andrew Morton, linux-next
  Cc: Liam R. Howlett, Bert Karwatzki

If mprotect_fixup() successfully calls vma_merge() and replaces vma and
the next vma, then the tmp variable in the do_mprotect_pkey() is not
updated to point to the new vma end.  This results in the loop detecting
a gap between VMAs that does not exist.  Fix the faulty value of tmp by
setting it to the end location of the vma iterator at the end of the
loop.

Reported-by: Bert Karwatzki <spasswolf@web.de>
Bug: https://bugzilla.kernel.org/show_bug.cgi?id=217061
Fixes: 2286a6914c77 ("mm: change mprotect_fixup to vma iterator")
Link: https://lore.kernel.org/linux-mm/20230223120407.729110a6ecd1416ac59d9cb0@linux-foundation.org/
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 mm/mprotect.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index 1d4843c97c2a..231929f119d9 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -832,6 +832,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
 		if (error)
 			break;
 
+		tmp = vma_iter_end(&vmi);
 		nstart = tmp;
 		prot = reqprot;
 	}
-- 
2.39.0



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

* Re: [PATCH] mm/mprotect: Fix successful vma_merge() of next in do_mprotect_pkey()
  2023-02-24 21:20 [PATCH] mm/mprotect: Fix successful vma_merge() of next in do_mprotect_pkey() Liam R. Howlett
@ 2023-02-24 22:53 ` Bert Karwatzki
  0 siblings, 0 replies; 2+ messages in thread
From: Bert Karwatzki @ 2023-02-24 22:53 UTC (permalink / raw)
  To: Liam R. Howlett, maple-tree, linux-mm, linux-kernel,
	Andrew Morton, linux-next

Am Freitag, dem 24.02.2023 um 16:20 -0500 schrieb Liam R. Howlett:
> If mprotect_fixup() successfully calls vma_merge() and replaces vma
> and
> the next vma, then the tmp variable in the do_mprotect_pkey() is not
> updated to point to the new vma end.  This results in the loop
> detecting
> a gap between VMAs that does not exist.  Fix the faulty value of tmp
> by
> setting it to the end location of the vma iterator at the end of the
> loop.
> 
> Reported-by: Bert Karwatzki <spasswolf@web.de>
> Bug: https://bugzilla.kernel.org/show_bug.cgi?id=217061
> Fixes: 2286a6914c77 ("mm: change mprotect_fixup to vma iterator")
> Link:
> https://lore.kernel.org/linux-mm/20230223120407.729110a6ecd1416ac59d9cb0@linux-foundation.org/
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
>  mm/mprotect.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index 1d4843c97c2a..231929f119d9 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -832,6 +832,7 @@ static int do_mprotect_pkey(unsigned long start,
> size_t len,
>                 if (error)
>                         break;
>  
> +               tmp = vma_iter_end(&vmi);
>                 nstart = tmp;
>                 prot = reqprot;
>         }
I tested this in linux-next-20230224 by starting stellaris from steam
(which is the only way I managed to trigger the bug) and it fixes the
issue for me.
Bert Karwatzki


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

end of thread, other threads:[~2023-02-24 22:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24 21:20 [PATCH] mm/mprotect: Fix successful vma_merge() of next in do_mprotect_pkey() Liam R. Howlett
2023-02-24 22:53 ` Bert Karwatzki

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