diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-26 12:27:33 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-26 12:27:33 -0700 |
commit | 0576f0602a4926b0027fdd7561a1c0053fa99d26 (patch) | |
tree | 1c6d64a00ab882e271bb167dcad88a220ebadd5f /mm | |
parent | 797a3242755da1b7c1ada6fb153cb2700ef30a80 (diff) | |
parent | 314eed30ede02fa925990f535652254b5bad6b65 (diff) | |
download | linux-0576f0602a4926b0027fdd7561a1c0053fa99d26.tar.bz2 |
Merge tag 'usercopy-v5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull usercopy fix from Kees Cook:
"Fix hardened usercopy under CONFIG_DEBUG_VIRTUAL"
* tag 'usercopy-v5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
usercopy: Avoid HIGHMEM pfn warning
Diffstat (limited to 'mm')
-rw-r--r-- | mm/usercopy.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mm/usercopy.c b/mm/usercopy.c index 98e924864554..660717a1ea5c 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -11,6 +11,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/mm.h> +#include <linux/highmem.h> #include <linux/slab.h> #include <linux/sched.h> #include <linux/sched/task.h> @@ -227,7 +228,12 @@ static inline void check_heap_object(const void *ptr, unsigned long n, if (!virt_addr_valid(ptr)) return; - page = virt_to_head_page(ptr); + /* + * When CONFIG_HIGHMEM=y, kmap_to_page() will give either the + * highmem page or fallback to virt_to_page(). The following + * is effectively a highmem-aware virt_to_head_page(). + */ + page = compound_head(kmap_to_page((void *)ptr)); if (PageSlab(page)) { /* Check slab allocator for flags and size. */ |