diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-07-18 16:55:52 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-07-18 16:55:52 +0200 |
| commit | 93467b31bec6da512b51544e5e4584f2745e995e (patch) | |
| tree | 2ea2be38c5e4dc9aafffbbc0db5aae0f6513a1d9 /fs/userfaultfd.c | |
| parent | 8ca1f4c6fb1462ee120730ea75c19da10d2f2d6f (diff) | |
| parent | 7a5cef0db4795d9d453a12e0f61b5b7634fc4d40 (diff) | |
Merge v7.1.4linux-rolling-stable
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/userfaultfd.c')
| -rw-r--r-- | fs/userfaultfd.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 390e4b7d9cb9..dba1172436b7 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -254,6 +254,15 @@ static inline bool userfaultfd_huge_must_wait(struct userfaultfd_ctx *ctx, if (pte_is_uffd_marker(pte)) return true; /* + * Concurrent migration may have replaced the present PTE with a + * non-marker swap entry between fault delivery and this lockless + * re-check. huge_pte_write() on a swap entry decodes random offset + * bits, so gate it on pte_present(). The migration completion path + * will re-deliver the fault if it still needs userspace. + */ + if (!pte_present(pte)) + return false; + /* * If VMA has UFFD WP faults enabled and WP fault, wait for userspace to * resolve the fault. */ @@ -340,6 +349,17 @@ again: if (pte_is_uffd_marker(ptent)) goto out; /* + * Concurrent swap-out / migration may have replaced the present PTE + * with a non-marker swap entry between fault delivery and this + * lockless re-check. pte_write() on a swap entry decodes random + * offset bits, so gate it on pte_present(). The page-in path will + * re-deliver the fault if it still needs userspace. + */ + if (!pte_present(ptent)) { + ret = false; + goto out; + } + /* * If VMA has UFFD WP faults enabled and WP fault, wait for userspace to * resolve the fault. */ |
