[PATCH] arm64: mm: validate /dev/mem mmap ranges without overflow

Zhao Gongyi zhaogongyi at bytedance.com
Tue Nov 3 18:21:24 PST 2026


Hi Catalin,

On 11/3/26 11:08 PM, Catalin Marinas wrote:
> 
> Can we write this as:
> 
> int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
> {
>          phys_addr_t limit = PHYS_MASK + 1;
> 
>          return size <= limit && pfn <= (limit - size) >> PAGE_SHIFT;
> }
> 
> It would resemble the generic __access_ok() better where we need to
> check for similar overflow. I find it easier to read.
> 
> (happy to make the change when applying)
> 

Thanks, your version is clearer. Please feel free to make the change 
when applying.

Thanks,
Gongyi



More information about the linux-arm-kernel mailing list