* [PATCH] mm/gup: fix NULL pointer dereference in fixup_user_fault()
@ 2026-10-03 19:48 Nguyen Duy Nhat Anh
0 siblings, 0 replies; only message in thread
From: Nguyen Duy Nhat Anh @ 2026-10-03 19:48 UTC (permalink / raw)
To: akpm
Cc: david, jgg, jhubbard, peterx, linux-mm, linux-kernel,
Nguyen Duy Nhat Anh
In fixup_user_fault(), the 'unlocked' parameter is checked for NULL
early on, allowing callers to pass NULL if they do not track whether the
mmap lock was dropped.
However, if handle_mm_fault() returns VM_FAULT_COMPLETED, line 1597
dereferences 'unlocked' directly (*unlocked = true) without checking
if it is NULL. Callers like s390's pci_mmio.c pass NULL for 'unlocked',
leading to a kernel NULL pointer dereference when VM_FAULT_COMPLETED
occurs.
Fix this by checking if 'unlocked' is non-NULL before assigning to it.
Signed-off-by: Nguyen Duy Nhat Anh <neganhat@gmail.com>
---
mm/gup.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index eb898ea1ee22..64f709a45adc 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1594,7 +1594,8 @@ int fixup_user_fault(struct mm_struct *mm,
* could tell the callers so they do not need to unlock.
*/
mmap_read_lock(mm);
- *unlocked = true;
+ if (unlocked)
+ *unlocked = true;
return 0;
}
@@ -1608,7 +1609,8 @@ int fixup_user_fault(struct mm_struct *mm,
if (ret & VM_FAULT_RETRY) {
mmap_read_lock(mm);
- *unlocked = true;
+ if (unlocked)
+ *unlocked = true;
fault_flags |= FAULT_FLAG_TRIED;
goto retry;
}
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-03 19:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-03 19:48 [PATCH] mm/gup: fix NULL pointer dereference in fixup_user_fault() Nguyen Duy Nhat Anh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®