summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2019-03-05 18:46:06 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-06 00:07:17 -0500
commit0ee930e6cafa048c1925893d0ca89918b2814f2c (patch)
tree583057c2957c316cbb52378c8758c408b676d216
parent2d432cb7091e99881af803cdd67a31969b863005 (diff)
mm/memory.c: prevent mapping typed pages to userspace
Pages which use page_type must never be mapped to userspace as it would destroy their page type. Add an explicit check for this instead of assuming that kernel drivers always get this right. Link: http://lkml.kernel.org/r/20190129053830.3749-1-willy@infradead.org Signed-off-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: David Hildenbrand <david@redhat.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/memory.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/memory.c b/mm/memory.c
index a9897dcd530f..79e0173a7d70 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1452,7 +1452,7 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
1452 spinlock_t *ptl; 1452 spinlock_t *ptl;
1453 1453
1454 retval = -EINVAL; 1454 retval = -EINVAL;
1455 if (PageAnon(page) || PageSlab(page)) 1455 if (PageAnon(page) || PageSlab(page) || page_has_type(page))
1456 goto out; 1456 goto out;
1457 retval = -ENOMEM; 1457 retval = -ENOMEM;
1458 flush_dcache_page(page); 1458 flush_dcache_page(page);