From: Andrey Konovalov <andreyknvl@google.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com>, Vincenzo Frascino <vincenzo.frascino@arm.com>, Dmitry Vyukov <dvyukov@google.com>, Andrey Ryabinin <aryabinin@virtuozzo.com>, Alexander Potapenko <glider@google.com>, Marco Elver <elver@google.com>, Peter Collingbourne <pcc@google.com>, Evgenii Stepanov <eugenis@google.com>, Branislav Rankov <Branislav.Rankov@arm.com>, Kevin Brodsky <kevin.brodsky@arm.com>, Christoph Hellwig <hch@infradead.org>, kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov <andreyknvl@google.com> Subject: [PATCH] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC Date: Fri, 26 Feb 2021 02:25:37 +0100 [thread overview] Message-ID: <1aa83e48627978de8068d5e3314185f3a0d7a849.1614302398.git.andreyknvl@google.com> (raw) Currently, kasan_free_nondeferred_pages()->kasan_free_pages() is called after debug_pagealloc_unmap_pages(). This causes a crash when debug_pagealloc is enabled, as HW_TAGS KASAN can't set tags on an unmapped page. This patch puts kasan_free_nondeferred_pages() before debug_pagealloc_unmap_pages(). Besides fixing the crash, this also makes the annotation order consistent with debug_pagealloc_map_pages() preceding kasan_alloc_pages(). Signed-off-by: Andrey Konovalov <andreyknvl@google.com> --- mm/page_alloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c89e7b107514..54bc237fd319 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1311,10 +1311,14 @@ static __always_inline bool free_pages_prepare(struct page *page, */ arch_free_page(page, order); - debug_pagealloc_unmap_pages(page, 1 << order); - + /* + * With hardware tag-based KASAN, memory tags must be set + * before unmapping the page with debug_pagealloc. + */ kasan_free_nondeferred_pages(page, order, fpi_flags); + debug_pagealloc_unmap_pages(page, 1 << order); + return true; } -- 2.30.1.766.gb4fecdf3b7-goog
WARNING: multiple messages have this Message-ID (diff)
From: Andrey Konovalov <andreyknvl@google.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-arm-kernel@lists.infradead.org, Marco Elver <elver@google.com>, Catalin Marinas <catalin.marinas@arm.com>, Kevin Brodsky <kevin.brodsky@arm.com>, Will Deacon <will.deacon@arm.com>, Branislav Rankov <Branislav.Rankov@arm.com>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Christoph Hellwig <hch@infradead.org>, linux-mm@kvack.org, Alexander Potapenko <glider@google.com>, Evgenii Stepanov <eugenis@google.com>, Andrey Konovalov <andreyknvl@google.com>, Andrey Ryabinin <aryabinin@virtuozzo.com>, Vincenzo Frascino <vincenzo.frascino@arm.com>, Peter Collingbourne <pcc@google.com>, Dmitry Vyukov <dvyukov@google.com> Subject: [PATCH] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC Date: Fri, 26 Feb 2021 02:25:37 +0100 [thread overview] Message-ID: <1aa83e48627978de8068d5e3314185f3a0d7a849.1614302398.git.andreyknvl@google.com> (raw) Currently, kasan_free_nondeferred_pages()->kasan_free_pages() is called after debug_pagealloc_unmap_pages(). This causes a crash when debug_pagealloc is enabled, as HW_TAGS KASAN can't set tags on an unmapped page. This patch puts kasan_free_nondeferred_pages() before debug_pagealloc_unmap_pages(). Besides fixing the crash, this also makes the annotation order consistent with debug_pagealloc_map_pages() preceding kasan_alloc_pages(). Signed-off-by: Andrey Konovalov <andreyknvl@google.com> --- mm/page_alloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c89e7b107514..54bc237fd319 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1311,10 +1311,14 @@ static __always_inline bool free_pages_prepare(struct page *page, */ arch_free_page(page, order); - debug_pagealloc_unmap_pages(page, 1 << order); - + /* + * With hardware tag-based KASAN, memory tags must be set + * before unmapping the page with debug_pagealloc. + */ kasan_free_nondeferred_pages(page, order, fpi_flags); + debug_pagealloc_unmap_pages(page, 1 << order); + return true; } -- 2.30.1.766.gb4fecdf3b7-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2021-02-26 1:26 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-26 1:25 Andrey Konovalov [this message] 2021-02-26 1:25 ` [PATCH] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC Andrey Konovalov 2021-02-26 1:25 ` Andrey Konovalov 2021-03-03 23:23 ` Andrew Morton 2021-03-03 23:23 ` Andrew Morton 2021-03-05 15:43 ` Andrey Konovalov 2021-03-05 15:43 ` Andrey Konovalov 2021-03-05 15:43 ` Andrey Konovalov 2021-03-05 17:04 ` Andrey Konovalov 2021-03-05 17:04 ` Andrey Konovalov 2021-03-05 17:04 ` Andrey Konovalov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1aa83e48627978de8068d5e3314185f3a0d7a849.1614302398.git.andreyknvl@google.com \ --to=andreyknvl@google.com \ --cc=Branislav.Rankov@arm.com \ --cc=akpm@linux-foundation.org \ --cc=aryabinin@virtuozzo.com \ --cc=catalin.marinas@arm.com \ --cc=dvyukov@google.com \ --cc=elver@google.com \ --cc=eugenis@google.com \ --cc=glider@google.com \ --cc=hch@infradead.org \ --cc=kasan-dev@googlegroups.com \ --cc=kevin.brodsky@arm.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=pcc@google.com \ --cc=vincenzo.frascino@arm.com \ --cc=will.deacon@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.