Skip to content

Commit 0576f06

Browse files
committed
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
2 parents 797a324 + 314eed3 commit 0576f06

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mm/usercopy.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1212

1313
#include <linux/mm.h>
14+
#include <linux/highmem.h>
1415
#include <linux/slab.h>
1516
#include <linux/sched.h>
1617
#include <linux/sched/task.h>
@@ -227,7 +228,12 @@ static inline void check_heap_object(const void *ptr, unsigned long n,
227228
if (!virt_addr_valid(ptr))
228229
return;
229230

230-
page = virt_to_head_page(ptr);
231+
/*
232+
* When CONFIG_HIGHMEM=y, kmap_to_page() will give either the
233+
* highmem page or fallback to virt_to_page(). The following
234+
* is effectively a highmem-aware virt_to_head_page().
235+
*/
236+
page = compound_head(kmap_to_page((void *)ptr));
231237

232238
if (PageSlab(page)) {
233239
/* Check slab allocator for flags and size. */

0 commit comments

Comments
 (0)