linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check
@ 2023-06-06 18:29 Liam R. Howlett
  2023-06-06 18:33 ` Lorenzo Stoakes
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Liam R. Howlett @ 2023-06-06 18:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Lorenzo Stoakes, Vlastimil Babka,
	Liam R. Howlett, Jeff Xu, stable

The return of do_mprotect_pkey() can still be incorrectly returned as
success if there is a gap that spans to or beyond the end address passed
in.  Update the check to ensure that the end address has indeed been
seen.

Link: https://lore.kernel.org/all/CABi2SkXjN+5iFoBhxk71t3cmunTk-s=rB4T7qo0UQRh17s49PQ@mail.gmail.com/
Fixes: 82f951340f25 ("mm/mprotect: fix do_mprotect_pkey() return on error")
Reported-by: Jeff Xu <jeffxu@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 mm/mprotect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index 92d3d3ca390a..c59e7561698c 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
 	}
 	tlb_finish_mmu(&tlb);
 
-	if (!error && vma_iter_end(&vmi) < end)
+	if (!error && tmp < end)
 		error = -ENOMEM;
 
 out:
-- 
2.39.2


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

* Re: [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check
  2023-06-06 18:29 [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check Liam R. Howlett
@ 2023-06-06 18:33 ` Lorenzo Stoakes
  2023-06-07  7:43 ` David Hildenbrand
  2023-06-07  7:46 ` Vlastimil Babka
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Stoakes @ 2023-06-06 18:33 UTC (permalink / raw)
  To: Liam R. Howlett
  Cc: Andrew Morton, linux-mm, linux-kernel, Vlastimil Babka, Jeff Xu, stable

On Tue, Jun 06, 2023 at 02:29:12PM -0400, Liam R. Howlett wrote:
> The return of do_mprotect_pkey() can still be incorrectly returned as
> success if there is a gap that spans to or beyond the end address passed
> in.  Update the check to ensure that the end address has indeed been
> seen.
>
> Link: https://lore.kernel.org/all/CABi2SkXjN+5iFoBhxk71t3cmunTk-s=rB4T7qo0UQRh17s49PQ@mail.gmail.com/
> Fixes: 82f951340f25 ("mm/mprotect: fix do_mprotect_pkey() return on error")
> Reported-by: Jeff Xu <jeffxu@chromium.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
>  mm/mprotect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index 92d3d3ca390a..c59e7561698c 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
>  	}
>  	tlb_finish_mmu(&tlb);
>
> -	if (!error && vma_iter_end(&vmi) < end)
> +	if (!error && tmp < end)
>  		error = -ENOMEM;
>
>  out:
> --
> 2.39.2
>

As discussed via irc, was able to confirm locally this fixes the reported
issue, so have a quick:-

Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>

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

* Re: [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check
  2023-06-06 18:29 [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check Liam R. Howlett
  2023-06-06 18:33 ` Lorenzo Stoakes
@ 2023-06-07  7:43 ` David Hildenbrand
  2023-06-07  7:46 ` Vlastimil Babka
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2023-06-07  7:43 UTC (permalink / raw)
  To: Liam R. Howlett, Andrew Morton
  Cc: linux-mm, linux-kernel, Lorenzo Stoakes, Vlastimil Babka,
	Jeff Xu, stable

On 06.06.23 20:29, Liam R. Howlett wrote:
> The return of do_mprotect_pkey() can still be incorrectly returned as
> success if there is a gap that spans to or beyond the end address passed
> in.  Update the check to ensure that the end address has indeed been
> seen.
> 
> Link: https://lore.kernel.org/all/CABi2SkXjN+5iFoBhxk71t3cmunTk-s=rB4T7qo0UQRh17s49PQ@mail.gmail.com/
> Fixes: 82f951340f25 ("mm/mprotect: fix do_mprotect_pkey() return on error")
> Reported-by: Jeff Xu <jeffxu@chromium.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
>   mm/mprotect.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index 92d3d3ca390a..c59e7561698c 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
>   	}
>   	tlb_finish_mmu(&tlb);
>   
> -	if (!error && vma_iter_end(&vmi) < end)
> +	if (!error && tmp < end)
>   		error = -ENOMEM;
>   
>   out:

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb


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

* Re: [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check
  2023-06-06 18:29 [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check Liam R. Howlett
  2023-06-06 18:33 ` Lorenzo Stoakes
  2023-06-07  7:43 ` David Hildenbrand
@ 2023-06-07  7:46 ` Vlastimil Babka
  2 siblings, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2023-06-07  7:46 UTC (permalink / raw)
  To: Liam R. Howlett, Andrew Morton
  Cc: linux-mm, linux-kernel, Lorenzo Stoakes, Jeff Xu, stable



On 6/6/23 20:29, Liam R. Howlett wrote:
> The return of do_mprotect_pkey() can still be incorrectly returned as
> success if there is a gap that spans to or beyond the end address passed
> in.  Update the check to ensure that the end address has indeed been
> seen.
> 
> Link: https://lore.kernel.org/all/CABi2SkXjN+5iFoBhxk71t3cmunTk-s=rB4T7qo0UQRh17s49PQ@mail.gmail.com/
> Fixes: 82f951340f25 ("mm/mprotect: fix do_mprotect_pkey() return on error")
> Reported-by: Jeff Xu <jeffxu@chromium.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  mm/mprotect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index 92d3d3ca390a..c59e7561698c 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
>  	}
>  	tlb_finish_mmu(&tlb);
>  
> -	if (!error && vma_iter_end(&vmi) < end)
> +	if (!error && tmp < end)
>  		error = -ENOMEM;
>  
>  out:

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

end of thread, other threads:[~2023-06-07  7:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 18:29 [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check Liam R. Howlett
2023-06-06 18:33 ` Lorenzo Stoakes
2023-06-07  7:43 ` David Hildenbrand
2023-06-07  7:46 ` Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).