From: Vlastimil Babka <vbabka@suse.cz>
To: Andrey Konovalov <andreyknvl@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Sergei Trofimovich <slyfox@gentoo.org>,
Alexander Potapenko <glider@google.com>,
Marco Elver <elver@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH mm v2] mm, kasan: fix for "integrate page_alloc init with HW_TAGS"
Date: Tue, 30 Mar 2021 18:44:09 +0200 [thread overview]
Message-ID: <404ad944-ab46-cffb-5fbb-3dd7ae25caaa@suse.cz> (raw)
In-Reply-To: <65b6028dea2e9a6e8e2cb779b5115c09457363fc.1617122211.git.andreyknvl@google.com>
On 3/30/21 6:37 PM, Andrey Konovalov wrote:
> My commit "integrate page_alloc init with HW_TAGS" changed the order of
> kernel_unpoison_pages() and kernel_init_free_pages() calls. This leads
> to complaints from the page unpoisoning code, as the poison pattern gets
> overwritten for __GFP_ZERO allocations.
>
> Fix by restoring the initial order. Also add a warning comment.
>
> Reported-by: Vlastimil Babka <vbabka@suse.cz>
> Reported-by: Sergei Trofimovich <slyfox@gentoo.org>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Tested that the bug indeed occurs in -next and is fixed by this. Thanks.
> ---
> mm/page_alloc.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 033bd92e8398..d2c020563c0b 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2328,6 +2328,13 @@ inline void post_alloc_hook(struct page *page, unsigned int order,
> arch_alloc_page(page, order);
> debug_pagealloc_map_pages(page, 1 << order);
>
> + /*
> + * Page unpoisoning must happen before memory initialization.
> + * Otherwise, the poison pattern will be overwritten for __GFP_ZERO
> + * allocations and the page unpoisoning code will complain.
> + */
> + kernel_unpoison_pages(page, 1 << order);
> +
> /*
> * As memory initialization might be integrated into KASAN,
> * kasan_alloc_pages and kernel_init_free_pages must be
> @@ -2338,7 +2345,6 @@ inline void post_alloc_hook(struct page *page, unsigned int order,
> if (init && !kasan_has_integrated_init())
> kernel_init_free_pages(page, 1 << order);
>
> - kernel_unpoison_pages(page, 1 << order);
> set_page_owner(page, order, gfp_flags);
> }
>
>
next prev parent reply other threads:[~2021-03-30 16:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-30 16:37 [PATCH mm v2] mm, kasan: fix for "integrate page_alloc init with HW_TAGS" Andrey Konovalov
2021-03-30 16:44 ` Vlastimil Babka [this message]
2021-03-30 18:11 ` Sergei Trofimovich
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=404ad944-ab46-cffb-5fbb-3dd7ae25caaa@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=andreyknvl@google.com \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=slyfox@gentoo.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).