Re: [PATCH] arm64: mm: validate /dev/mem mmap ranges without overflow
From: Zhao Gongyi
Date: Tue Nov 03 2026 - 21:21:57 EST
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