From: Michal Hocko <mhocko@suse.com>
To: Qian Cai <cai@lca.pw>
Cc: akpm@linux-foundation.org, osalvador@suse.de,
catalin.marinas@arm.com, vbabka@suse.cz, linux-mm@kvack.org
Subject: Re: [PATCH] mm/hotplug: invalid PFNs from pfn_to_online_page()
Date: Mon, 21 Jan 2019 19:19:57 +0100 [thread overview]
Message-ID: <20190121181957.GX4087@dhcp22.suse.cz> (raw)
In-Reply-To: <1295f347-5a14-5b3b-23ef-2f001c25d980@lca.pw>
On Mon 21-01-19 11:38:49, Qian Cai wrote:
>
>
> On 1/21/19 4:53 AM, Michal Hocko wrote:
> > On Thu 17-01-19 21:16:50, Qian Cai wrote:
[...]
> >> Fixes: 2d070eab2e82 ("mm: consider zone which is not fully populated to
> >> have holes")
> >
> > Did you mean
> > Fixes: 9f1eb38e0e11 ("mm, kmemleak: little optimization while scanning")
>
> No, pfn_to_online_page() missed a few checks compared to pfn_valid() at least on
> arm64 where the returned pfn is no longer valid (where pfn_valid() will skip those).
>
> 2d070eab2e82 introduced pfn_to_online_page(), so it was targeted to fix it.
But it is 9f1eb38e0e11 which has replaced pfn_valid by
pfn_to_online_page.
>
> >
> >> Signed-off-by: Qian Cai <cai@lca.pw>
> >> ---
> >> include/linux/memory_hotplug.h | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> >> index 07da5c6c5ba0..b8b36e6ac43b 100644
> >> --- a/include/linux/memory_hotplug.h
> >> +++ b/include/linux/memory_hotplug.h
> >> @@ -26,7 +26,7 @@ struct vmem_altmap;
> >> struct page *___page = NULL; \
> >> unsigned long ___nr = pfn_to_section_nr(pfn); \
> >> \
> >> - if (___nr < NR_MEM_SECTIONS && online_section_nr(___nr))\
> >> + if (online_section_nr(___nr) && pfn_valid(pfn)) \
> >> ___page = pfn_to_page(pfn); \
> >
> > Why have you removed the bound check? Is this safe?
> > Regarding the fix, I am not really sure TBH. If the secion is online
> > then we assume all struct pages to be initialized. If anything this
> > should be limited to werid arches which might have holes so
> > pfn_valid_within().
>
> It looks to me at least on arm64 and x86_64, it has done this check in
> pfn_valid() already.
>
> if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
> return 0
But an everflow could happen before pfn_valid is evaluated, no?
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2019-01-21 18:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 17:36 kmemleak scan crash due to invalid PFNs Qian Cai
2019-01-17 18:50 ` Oscar Salvador
2019-01-17 18:50 ` Oscar Salvador
2019-01-17 18:58 ` Oscar Salvador
2019-01-18 2:16 ` [PATCH] mm/hotplug: invalid PFNs from pfn_to_online_page() Qian Cai
2019-01-21 9:53 ` Michal Hocko
2019-01-21 16:38 ` Qian Cai
2019-01-21 17:58 ` Qian Cai
2019-01-21 18:36 ` Michal Hocko
2019-01-21 18:19 ` Michal Hocko [this message]
2019-01-21 18:37 ` Qian Cai
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=20190121181957.GX4087@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=cai@lca.pw \
--cc=catalin.marinas@arm.com \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=vbabka@suse.cz \
/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