Re: [PATCH] mm: skip checking poison pattern for page_to_nid()

Qian Cai
2018-12-19T12:46:52Z

On 12/19/18 5:20 AM, Michal Hocko wrote:
> On Tue 18-12-18 20:57:32, Qian Cai wrote:
> [...]
>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>> index 5411de93a363..f083f366ea90 100644
>> --- a/include/linux/mm.h
>> +++ b/include/linux/mm.h
>> @@ -985,9 +985,7 @@ extern int page_to_nid(const struct page *page);
>> #else
>> static inline int page_to_nid(const struct page *page)
>> {
>> - struct page *p = (struct page *)page;
>> -
>> - return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK;
>> + return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
>> }
>> #endif
>
> I didn't get to think about a proper fix but this is clearly worng. If
> the page is still poisoned then flags are clearly bogus and the node you
> get is a garbage as well. Have you actually tested this patch?
>

Yes, I did notice that after running for a while triggering some UBSAN
out-of-bounds access warnings. I am still trying to figure out how those
uninitialized page flags survived though after

mm_init
mem_init
memblock_free_all
init_single_page()