kasan: fix conflict with page poisoning
authorAndrey Konovalov <andreyknvl@google.com>
Fri, 9 Apr 2021 20:27:38 +0000 (13:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 9 Apr 2021 21:54:23 +0000 (14:54 -0700)
When page poisoning is enabled, it accesses memory that is marked as
poisoned by KASAN, which leas to false-positive KASAN reports.

Suppress the reports by adding KASAN annotations to unpoison_page()
(poison_page() already has them).

Link: https://lkml.kernel.org/r/2dc799014d31ac13fd97bd906bad33e16376fc67.1617118501.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/page_poison.c

index 65cdf84..655dc58 100644 (file)
@@ -77,12 +77,14 @@ static void unpoison_page(struct page *page)
        void *addr;
 
        addr = kmap_atomic(page);
+       kasan_disable_current();
        /*
         * Page poisoning when enabled poisons each and every page
         * that is freed to buddy. Thus no extra check is done to
         * see if a page was poisoned.
         */
-       check_poison_mem(addr, PAGE_SIZE);
+       check_poison_mem(kasan_reset_tag(addr), PAGE_SIZE);
+       kasan_enable_current();
        kunmap_atomic(addr);
 }