From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794585710; b=qOLJh7MZMBzTzuOfKZv0+JwllgrVihSjcU9nNrgwlmIkXamv6PnjkK+BTeK649pO1dw2 eIHDNUtU9GsGX/vHaaHcd7UVILGu1iNU9jl6hivnnCEnInKRvXrNEJOWrfiW/rrZyq81S EFUhVZ1/VPJpoAfucTLYfwxE5EAmEyc19eT8QaIOD0M5c9HQ8cyHcGwlLRIHCeRdYASuw OgN+GNDbrCTQgQXzHyOOTPdths1sLjAVlBYZ8R+iuiBgIxI6sLsGLSYSk8t8a5HAOBvC0 x+3Kqglvcizpk+oAsqCwGwgRYorMw9+E/tNn7ba/16jOQLYm7pGPcj5ZIXr3cydbOYA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794585710; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=h6PvoSFwwBR0v3izwlArVinI0vyuKEzf4zEZGgn9s6s=; b=RKw+BKWJr4cPEEKPE6cPVFQli2p1KYct8s1EuIMizWPFDhf9lHXI4qSgvvtXIFa2ui2E GbyFlaOpD2xrEREob3N9Vn9cPgjFAHvrrKyiEKeuO+XXy+VNuji5AH/v76ezLFeh8V4+D hlp0xVyYzompGJUa339HkyCfD7q7eyPu+HIvlOWW6jBWqNU7mjraDOwAxLvdNT65W3S76 ODoPOeZ99W9ZBqR2U+2lc6Ovnh9DGb4PrqnLn0Okrj25+R5jvZ2p7aLWsLLyMU1lPByn1 Mbd6WzQpalcZ+ukqBTQcvLhgDQJ5scfYvK1vD1E3ISXmz5tgaywYnp2Zkx4ZBdALM9A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Nr2Ydpvl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6168060A3834; Fri, 13 Nov 2026 16:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Nr2Ydpvl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B9271F000C4; Fri, 13 Nov 2026 16:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794585710; bh=h6PvoSFwwBR0v3izwlArVinI0vyuKEzf4zEZGgn9s6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Nr2YdpvlVJ61RJwSLwYGKfwJA5q+XXPRPFJvEe6/6ZnaAZfFcCGq1GNbJxDsxqoqa uKzeu1jiEn26XzpWzBpZ3BsvjJ69kpEiSyl9ulIeK/iMKTzwKnSkjYXf7jrgElnzOs F5P9qToepT60Qb1PCZq7H8az6Xq5/90xXD/Gby1w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Bacik , "Lorenzo Stoakes (ARM)" , Muhammad Usama Anjum , "David Hildenbrand (Arm)" , Sasha Levin Subject: [PATCH 7.3 314/507] mm/mmu_notifier: finish non-blocking interval invalidation on error Date: Fri, 13 Nov 2026 10:50:18 -0500 Message-ID: <20261113153806.072621326@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153753.358973689@linuxfoundation.org> References: <20261113153753.358973689@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik [ Upstream commit 6d65925777ecae9d7a571a327e41c63f3940a0c7 ] When an ordinary MMU notifier rejects a non-blocking invalidation, the interval invalidation started beforehand is left unfinished: the caller skips mmu_notifier_invalidate_range_end(). Subsequent interval notifier operations can then wait forever. The only in-tree trigger is nouveau SVM, which uses both notifier types and rejects non-blocking invalidations. Reaping via the OOM reaper or process_mrelease() can therefore leave the GPU fault worker stuck, holding a reference that prevents the dying process's address space and memory from being freed. End the interval invalidation when an ordinary notifier fails a non-blocking invalidation, like mn_itree_invalidate() already does when an interval notifier fails. Make that handling clearer in the documentation of mmu_notifier_invalidate_range_start_nonblock(). Fix generated by an LLM and sent by Josef Bacik in private. Fixes: 99cb252f5e68 ("mm/mmu_notifier: add an interval tree notifier") Cc: stable@vger.kernel.org Signed-off-by: Josef Bacik [ david: simplify description, update function doc ] Acked-by: Lorenzo Stoakes (ARM) Tested-by: Muhammad Usama Anjum Link: https://patch.msgid.link/20261031-fixes_core-v3-28-d6437171ecc3@kernel.org Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Sasha Levin --- include/linux/mmu_notifier.h | 3 ++- mm/mmu_notifier.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index a11a44eef521e..5db78e5761c5c 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -483,7 +483,8 @@ mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) /* * This version of mmu_notifier_invalidate_range_start() avoids blocking, but it * can return an error if a notifier can't proceed without blocking, in which - * case you're not allowed to modify PTEs in the specified range. + * case you're not allowed to modify PTEs in the specified range or call + * mmu_notifier_invalidate_range_end(). * * This is mainly intended for OOM handling. */ diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index df69ba6e797f7..2e20f88e162d7 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -569,16 +569,25 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) { struct mmu_notifier_subscriptions *subscriptions = range->mm->notifier_subscriptions; - int ret; + const bool has_itree = subscriptions->has_itree; + int ret = 0; - if (subscriptions->has_itree) { + if (has_itree) { ret = mn_itree_invalidate(subscriptions, range); if (ret) return ret; } if (!hlist_empty(&subscriptions->list)) - return mn_hlist_invalidate_range_start(subscriptions, range); - return 0; + ret = mn_hlist_invalidate_range_start(subscriptions, range); + + /* + * On error, the non-blocking caller is not allowed to call + * invalidate_range_end(), as in mn_itree_invalidate(). + */ + if (ret && has_itree && !mmu_notifier_range_blockable(range)) + mn_itree_inv_end(subscriptions); + + return ret; } static void -- 2.53.0