Re: [PATCH v3 1/2] x86/ioremap: fix the pfn calculation mistake in __ioremap_check_ram()

From: Dave Hansen
Date: Thu Jul 01 2021 - 10:41:45 EST


On 6/21/21 5:34 AM, Yaohui Wang wrote:
> For example, suppose memory range [phys_addr ~ phys_addr + PAGE_SIZE - 1]
> is a normal RAM page. ioremap(phys_addr, PAGE_SIZE - 1) will succeed
> (but it should not) because the pfn wrapping prevents this page to be
> checked whether it touches non-ioremappable resources.

I would have expected such a scenario to get caught by this check:

if ((res->flags & IORESOURCE_SYSTEM_RAM) != IORESOURCE_SYSTEM_RAM)
return false;

Was this issue found by inspection, or is it causing an actual problem
in practice?

Also, it would be really nice to include the original authors when you
send Fixes: for patches. BTW, scripts/get_maintainer.pl would have done
this for you. I've added Tom and Brijesh. Please cc them in the future.