diff mbox series

[01/10] vmalloc: reject vmap with VM_FLUSH_RESET_PERMS

Message ID 20230119100226.789506-2-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/10] vmalloc: reject vmap with VM_FLUSH_RESET_PERMS | expand

Commit Message

Christoph Hellwig Jan. 19, 2023, 10:02 a.m. UTC
VM_FLUSH_RESET_PERMS is just for use with vmalloc as it is tied to freeing
the underlying pages.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 mm/vmalloc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Uladzislau Rezki Jan. 19, 2023, 6:46 p.m. UTC | #1
On Thu, Jan 19, 2023 at 11:02:17AM +0100, Christoph Hellwig wrote:
> VM_FLUSH_RESET_PERMS is just for use with vmalloc as it is tied to freeing
> the underlying pages.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  mm/vmalloc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 0781c5a8e0e73d..6957d15d526e46 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2883,6 +2883,9 @@ void *vmap(struct page **pages, unsigned int count,
>  
>  	might_sleep();
>  
> +	if (WARN_ON_ONCE(flags & VM_FLUSH_RESET_PERMS))
> +		return NULL;
> +
>  	/*
>  	 * Your top guard is someone else's bottom guard. Not having a top
>  	 * guard compromises someone else's mappings too.
> -- 
> 2.39.0
> 
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki
diff mbox series

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 0781c5a8e0e73d..6957d15d526e46 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2883,6 +2883,9 @@  void *vmap(struct page **pages, unsigned int count,
 
 	might_sleep();
 
+	if (WARN_ON_ONCE(flags & VM_FLUSH_RESET_PERMS))
+		return NULL;
+
 	/*
 	 * Your top guard is someone else's bottom guard. Not having a top
 	 * guard compromises someone else's mappings too.