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=1795046458; b=jGPbdLSKy6uKpMBhnIcAdG4I7i8w2yGozh4SR3lxJ8+1Kmmu9PXtDY2Y+JcF6I3ZO2ft 6gPToGjxnEZ9/ZsTFaHSQj7VCMSpxKoNEWhaA++G25ekPlrynMtia9+Z/aOsXUs6F+3nO Q0NaSZkSFz01D7ngxlPlTDXa5EG0aqK1Tl2itk6+XNc0O2nszKWeCJrVRxQme/sFs8mk6 Y3aD+xJJremPAxdsrvwNMGJqpwHlT1a062PQj0fmikqG4XQHZf3Lzx4sK7Mk4SWyomNxK TR+TJDpYlVqYSfTViABKRuIrBTUFR0RtLW+BJJI37Gw/SYd8NdvitZB3RMa50BF+TNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795046458; 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=w5sPtE0EG2g8KF++pHqERwRUISQP7TI7Sjbi9EqoJQ0=; b=aGI4Ib/TQmL6Hi0HUn9jOR9f2MhbnEXgKzg/A2S8YsvXTB6k/1yNf4vtqpjKL3SHzDg2 sEOAE9buQYxhduO4nwWH6F5fLUGO3SgqShXWpNik0u+1yihzJZOR5nleRBbOIlRM2kkBU 0iXMWR4lD7UFhfYTEiQlSF+YKa/LJPOtscgth9jR9CIc+UudKW7fevwWvLXXi4QIODdVG DeMCwaDkKGKUy/LBBJcUXUlR+GcZMIHClJ0IIBukqaAjNNBQQo8TtMjLd0kNk9LOLimDi +s3plml2fCQYp/YmiDGgkJ2eBOf/Amwso7ggYY7sP61ANyhykwkVigYd2uemnTCp/5w== 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=K3zgrheb; 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 CF3BC606A325; Thu, 19 Nov 2026 00:00:58 +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=K3zgrheb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 313131F000C5; Thu, 19 Nov 2026 00:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795046458; bh=w5sPtE0EG2g8KF++pHqERwRUISQP7TI7Sjbi9EqoJQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=K3zgrhebc+hBuOyA13ruh8GQKYthfThDETWnEQPIr6zGOg0bwNxG1PJYAkec0ibly AhCOIM7y+/3/teyv9KeYWkG6/wI21OKCTFQi0eQzTjwkXkHQ5Af32SuuDGmr+1VuQx 2XSURVctGPV3CTsCKZAnRDqYJ4//hsOJpUUCyR6o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , "Gregory Price (Meta)" , "Lorenzo Stoakes (ARM)" , Muhammad Usama Anjum , "David Hildenbrand (Arm)" , Sasha Levin Subject: [PATCH 6.1 1286/2857] mm/mmu_notifier: set ->mm only after mmgrab() Date: Wed, 18 Nov 2026 15:38:40 +0100 Message-ID: <20261118150247.800803011@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason [ Upstream commit 5ad9e4b0f1104f5dbfb41125c34bb30ea6dc7a94 ] Radeon uses a non-NULL notifier->mm to decide whether to call mmu_interval_notifier_remove() when freeing a buffer object. __mmu_interval_notifier_insert() sets ->mm before validating the range, so a wrapping userptr range can leave ->mm set after insertion fails. Cleanup then tries to remove an unregistered notifier for which no mm reference was acquired. Set ->mm only after mmgrab(), once insertion can no longer fail. While we could fix radeon's code instead, setting ->mm on success only makes the code more robust. Fix generated by an LLM and sent by Chris Mason in private. Fixes: 3506ff69c3ec ("drm/radeon: use mmu_interval_notifier_insert") Cc: stable@vger.kernel.org Signed-off-by: Chris Mason [ david: simplify description ] Reviewed-by: Gregory Price (Meta) Tested-by: Gregory Price (Meta) Reviewed-by: Lorenzo Stoakes (ARM) Tested-by: Muhammad Usama Anjum Link: https://patch.msgid.link/20261031-fixes_core-v3-29-d6437171ecc3@kernel.org Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Sasha Levin --- mm/mmu_notifier.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index f45ff1b7626a6..fa5b60f51e463 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -915,7 +915,6 @@ static int __mmu_interval_notifier_insert( struct mmu_notifier_subscriptions *subscriptions, unsigned long start, unsigned long length, const struct mmu_interval_notifier_ops *ops) { - interval_sub->mm = mm; interval_sub->ops = ops; RB_CLEAR_NODE(&interval_sub->interval_tree.rb); interval_sub->interval_tree.start = start; @@ -932,8 +931,12 @@ static int __mmu_interval_notifier_insert( if (WARN_ON(atomic_read(&mm->mm_users) <= 0)) return -EINVAL; - /* pairs with mmdrop in mmu_interval_notifier_remove() */ + /* + * Pairs with mmdrop in mmu_interval_notifier_remove(). Drivers take a + * non-NULL ->mm for "registered", so set it only with the reference. + */ mmgrab(mm); + interval_sub->mm = mm; /* * If some invalidate_range_start/end region is going on in parallel -- 2.53.0