Skip to content

Commit

Permalink
kmsan: unpoison only the created pages in get_user_pages_fast()
Browse files Browse the repository at this point in the history
gup_pgd_range() may return less pages than requested. In that case
we must unpoison only the created pages.
  • Loading branch information
ramosian-glider committed May 15, 2018
1 parent 09a149f commit 06b2df0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/gup.c
Expand Up @@ -1820,12 +1820,12 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
gup_pgd_range(addr, end, write, pages, &nr);
// TODO(glider): there might be other places where user memory is pinned
// to kernel memory.
// gup_pgd_range() has just created a bunch of new pages that KMSAN
// treats as uninitialized.
// gup_pgd_range() has just created a number (less or equal to nr_pages)
// of new pages that KMSAN treats as uninitialized.
// In the case the [addr, end) range belongs to the userspace memory,
// unpoison the corresponding kernel pages.
if ((addr < TASK_SIZE) && (end < TASK_SIZE)) {
kmsan_unpoison_shadow(page_address(pages[0]), len);
kmsan_unpoison_shadow(page_address(pages[0]), (unsigned long)nr << PAGE_SHIFT);
}
local_irq_enable();
ret = nr;
Expand Down

0 comments on commit 06b2df0

Please sign in to comment.