Re: [PATCH] mm: Fix __dump_page() for poisoned pages

From: Michal Hocko
Date: Wed Feb 13 2019 - 09:23:11 EST


On Wed 13-02-19 13:40:49, Robin Murphy wrote:
> Evaluating page_mapping() on a poisoned page ends up dereferencing junk
> and making PF_POISONED_CHECK() considerably crashier than intended. Fix
> that by not inspecting the mapping until we've determined that it's
> likely to be valid.

Has this ever triggered? I am mainly asking because there is no usage of
mapping so I would expect that the compiler wouldn't really call
page_mapping until it is really used.

> Fixes: 1c6fb1d89e73 ("mm: print more information about mapping in __dump_page")
> Signed-off-by: Robin Murphy <robin.murphy@xxxxxxx>
> ---
> mm/debug.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/debug.c b/mm/debug.c
> index 0abb987dad9b..1611cf00a137 100644
> --- a/mm/debug.c
> +++ b/mm/debug.c
> @@ -44,7 +44,7 @@ const struct trace_print_flags vmaflag_names[] = {
>
> void __dump_page(struct page *page, const char *reason)
> {
> - struct address_space *mapping = page_mapping(page);
> + struct address_space *mapping;
> bool page_poisoned = PagePoisoned(page);
> int mapcount;
>
> @@ -58,6 +58,8 @@ void __dump_page(struct page *page, const char *reason)
> goto hex_only;
> }
>
> + mapping = page_mapping(page);
> +
> /*
> * Avoid VM_BUG_ON() in page_mapcount().
> * page->_mapcount space in struct page is used by sl[aou]b pages to
> --
> 2.20.1.dirty
>

--
Michal Hocko
SUSE Labs