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] mm, kasan: fix for "integrate page_alloc init with HW_TAGS"
Date: Tue, 30 Mar 2021 17:54:33 +0200 [thread overview]
Message-ID: <115c3cd4-a5ec-ea4c-fdc8-a17a0990bd30@suse.cz> (raw)
In-Reply-To: <2e5e80481533e73876d5d187d1f278f9656df73a.1617118134.git.andreyknvl@google.com>
On 3/30/21 5:31 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 __GFP_ZERO allocations being incorrectly poisoned when page poisoning
> is enabled.
Correction: This leads to check_poison_mem() complain about memory corruption
because the poison pattern has already been overwritten by zeroes.
> 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>
I expect this will be folded to your patch in mmotm anyway, so the changelog is
not as important...
> ---
> mm/page_alloc.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 033bd92e8398..1fc5061f8ca1 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2328,6 +2328,12 @@ 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, a __GFP_ZERO allocation will not be initialized.
... but the comment should be corrected too:
"Otherwise, a __GFP_ZERO allocation will trigger a memory corruption report
during unpoisoning."
Thanks.
> + */
> + 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 +2344,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 15:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-30 15:31 Andrey Konovalov
2021-03-30 15:54 ` Vlastimil Babka [this message]
2021-03-30 16:37 ` 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=115c3cd4-a5ec-ea4c-fdc8-a17a0990bd30@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