Re: [PATCH v2 3/4] mm: Factor __pfn_valid() out of pfn_valid()
From: David Hildenbrand (Arm)
Date: Sun Nov 01 2026 - 13:03:27 EST
On 11/1/26 18:04, Viorel Cernateanu via B4 Relay wrote:
> From: Viorel Cernateanu <vrilutza@xxxxxxxxx>
>
> KMSAN needs to validate a PFN during metadata lookup without entering
> instrumented code. Calling pfn_valid() also calls
> rcu_read_lock_sched(), which can enter instrumented code and recurse
> into the metadata lookup.
>
> Extract the PFN checks into __pfn_valid(), whose caller must already
> be in an RCU-sched read-side critical section. Keep pfn_valid() as
> the wrapper that acquires and releases that protection.
>
> This lets KMSAN reuse the existing PFN validation while providing
> the required protection without instrumented helpers.
>
> The wrapper now also holds the RCU-sched read lock during the
> initial range checks, which previously ran before acquiring it.
>
> Suggested-by: Alexander Potapenko <glider@xxxxxxxxxx>
> Signed-off-by: Viorel Cernateanu <vrilutza@xxxxxxxxx>
> ---
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
--
Cheers,
David