path: root/mm/vmalloc.c
diff options
authorPeter Zijlstra <>2021-11-05 13:39:22 -0700
committerLinus Torvalds <>2021-11-06 13:30:36 -0700
commitbd1a8fb2d43f7c293383f76691d7a55f7f89d9da (patch)
treefeb4ca9f9bfcb52dcba1a30a009ec0fb8479f2b8 /mm/vmalloc.c
parent228f778e973035185232ae745be0e3bc57dacea6 (diff)
mm/vmalloc: don't allow VM_NO_GUARD on vmap()
The vmalloc guard pages are added on top of each allocation, thereby isolating any two allocations from one another. The top guard of the lower allocation is the bottom guard guard of the higher allocation etc. Therefore VM_NO_GUARD is dangerous; it breaks the basic premise of isolating separate allocations. There are only two in-tree users of this flag, neither of which use it through the exported interface. Ensure it stays this way. Link: Signed-off-by: Peter Zijlstra (Intel) <> Reviewed-by: Christoph Hellwig <> Reviewed-by: David Hildenbrand <> Acked-by: Will Deacon <> Acked-by: Kees Cook <> Cc: Andrey Konovalov <> Cc: Mel Gorman <> Cc: Uladzislau Rezki <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm/vmalloc.c')
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index f43c88fa08cf..4a11abd9e70f 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2743,6 +2743,13 @@ void *vmap(struct page **pages, unsigned int count,
+ /*
+ * Your top guard is someone else's bottom guard. Not having a top
+ * guard compromises someone else's mappings too.
+ */
+ if (WARN_ON_ONCE(flags & VM_NO_GUARD))
+ flags &= ~VM_NO_GUARD;
if (count > totalram_pages())
return NULL;