mm/uffd: sanity check write bit for uffd-wp protected ptes
authorPeter Xu <peterx@redhat.com>
Mon, 14 Nov 2022 00:04:47 +0000 (19:04 -0500)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 30 Nov 2022 23:58:55 +0000 (15:58 -0800)
commitc2da319c2e2789dccb20fdafe520ac61c9df84f7
treeb4aee98aec73e99100490e439dc2f67df4a0142c
parent25e9fa22fbfec1e58c955d2670bf9a18f4ebe9ef
mm/uffd: sanity check write bit for uffd-wp protected ptes

Let's add one sanity check for CONFIG_DEBUG_VM on the write bit in
whatever chance we have when walking through the pgtables.  It can bring
the error earlier even before the app notices the data was corrupted on
the snapshot.  Also it helps us to identify this is a wrong pgtable setup,
so hopefully a great information to have for debugging too.

Link: https://lkml.kernel.org/r/20221114000447.1681003-3-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Nadav Amit <nadav.amit@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/x86/include/asm/pgtable.h