Re: [PATCH 4/7] mm: Introduce verify_page_range()

From: Peter Zijlstra
Date: Wed Apr 14 2021 - 03:01:18 EST


On Tue, Apr 13, 2021 at 08:01:08PM -0700, Kees Cook wrote:
> So the addr can just be encoded in "int", and no structure is needed at:
>
> typedef bool (*vpr_fn_t)(pte_t pte);
>
> static int vpr_fn(pte_t *pte, unsigned long addr, void *data)
> {
> vpr_fn_t callback = data;
>
> if (!callback(*pte))
> return addr >> PAGE_SIZE;
> return 0;
> }
>
> unsigned long verify_page_range(struct mm_struct *mm,
> unsigned long addr, unsigned long size,
> vpr_fn_t callback)
> {
> return apply_to_page_range(mm, addr, size, vpr_fn, callback) << PAGE_SIZE;
> }
>
> But maybe I'm missing something?

That covers only (32+12) bits of address space and will mostly work, but
we definitely support architectures (very much including x86_64) with
larger address spaces than that.