Re: [PATCH 2/2] mm/uffd: Sanity check write bit for uffd-wp protected ptes

From: Peter Xu
Date: Thu Nov 10 2022 - 15:29:30 EST


On Thu, Nov 10, 2022 at 10:43:25AM -0800, Nadav Amit wrote:
> On Nov 10, 2022, at 7:17 AM, Peter Xu <peterx@xxxxxxxxxx> wrote:
>
> > +#ifdef CONFIG_DEBUG_VM
> > + /*
> > + * Having write bit for wr-protect-marked present ptes is fatal,
> > + * because it means the uffd-wp bit will be ignored and write will
> > + * just go through.
> > + *
> > + * Use any chance of pgtable walking to verify this (e.g., when
> > + * page swapped out or being migrated for all purposes). It means
> > + * something is already wrong. Tell the admin even before the
> > + * process crashes. We also nail it with wrong pgtable setup.
> > + */
> > + WARN_ON_ONCE(wp && pte_write(pte));
>
> How about VM_WARN_ON_ONCE() and no ifdef?

Oops.. Will quickly respin, thanks.

--
Peter Xu