[PATCH 19/32] mm/gup: check for fatal signals in memfd_pin_folios()

From: David Hildenbrand (Arm)

Date: Sun Nov 29 2026 - 05:13:05 EST


memfd_pin_folios() retries on -EAGAIN until it can isolate all folios
that are not longterm pinnable, which can take an unbounded time.

Consequently, as it never checks for fatal signals, UDMABUF_CREATE, for
example, cannot be killed while it holds the inode lock of the memfd,
blocking a fallocate() of the file.

Let's fix it by checking for fatal signals before each attempt, like
__get_user_pages() does for __gup_longterm_locked().

This has medium urgency, as permanently failing isolation, as recently
seen with hugetlb, makes the task hang forever.

Fixes: 89c1905d9c14 ("mm/gup: introduce memfd_pin_folios() for pinning memfd folios")
Cc: stable@xxxxxxxxxxxxxxx
Reported-by: Chris Mason <mason@xxxxxxxxxx>
Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
---
mm/gup.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/mm/gup.c b/mm/gup.c
index ec0bc99202169..a50463672f803 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -3623,6 +3623,11 @@ long memfd_pin_folios(struct file *memfd, loff_t start, loff_t end,
flags = memalloc_pin_save();
do {
nr_folios = 0;
+ if (fatal_signal_pending(current)) {
+ ret = -EINTR;
+ goto err;
+ }
+
start_idx = start >> pgshift;
end_idx = end >> pgshift;
if (is_file_hugepages(memfd)) {

--
2.56.1