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=1794585712; b=BESHdLOmQVJPEwhalGY2UJ8/gNCj03Tp0bSo4huVJqUX2wnVYDPJQ7bEsIWuXzTZdNUJ SdpRdHuIJTQRVgGlclS+6f45jw/GKB0I2nuZbqzdQymP7JW0ztHNPZu2L+Cxt7r2T/el+ Y8YbVafYAGeAWJBpvM68J5iaZkiO7FYWhX5zpSnaqlcnBedgApCxdtWouWl87kTZnw6Xy 9Q557Rz/vIKigfoZiYPGxfXTuVM2/fmzncqXQ4q6MQ/wKyz32/w08ztuFXMbuq1830Bpc 3QjFLJbF6G+sSMjAUtQD0kkzDx9n9nh7mJ3U2eO6JbofqMMG2iczGJT9nJZdBqRX5iQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794585712; 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=5oWcSm4mjRZSwqaJ1rPZFtF+WMYOmZXxcx2va47bB5o=; b=ksg7czIaN397d80JQxfVrAn9r9pIGx/C4z+vXcKFAjA3LOZ0fw2DuFFZs09b4sPiOEo3 ZowQVkC2BXjwUUodsjeyIESCb4Cs87do8WV+qichOs0sRePbRy0ZiqLdfWfxL3NEm1awm SLRvNIJx2zA0hMKeAoUsYcIDqajopVSkxsd8JfIALUr3BfevMVXHy+m9XgFGeLtSkbKXM f18Ve/8tJXsj+JK7orlYhAgH1AE/V2UgoHza+GMu/ANxk8UF5vVRYCF6inYIoRvJsADpW V8h5Ziz2HFOpOWzOwXBxamc/sWr3LcXaadZYjwS2TuH7zqwqkG8mnunzKb2WhiR373Q== 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=V5+pWViS; 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 D18F660A383B; Fri, 13 Nov 2026 16:01:52 +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=V5+pWViS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FDF41F000C5; Fri, 13 Nov 2026 16:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794585712; bh=5oWcSm4mjRZSwqaJ1rPZFtF+WMYOmZXxcx2va47bB5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V5+pWViSiXXx+F4RyKDe/+mdwBJ7V3g9H4wGBJRqwyuUPbkhgq+CCWTQ9rGTz/GX9 lQmnirogaXB4kr7oAm82ieDx81zlmoktwI3VBrsDcyMNE7Lz8elAZYDUqeTAXCxrJS h04GAx/LEqMEF23UPJB5a5AQuKeEIpd6McEQe94k= 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 7.3 315/507] mm/mmu_notifier: set ->mm only after mmgrab() Date: Fri, 13 Nov 2026 10:50:19 -0500 Message-ID: <20261113153806.117899914@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: stable@vger.kernel.org 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: 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 2e20f88e162d7..a7bae5de5fedc 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -947,7 +947,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; @@ -964,8 +963,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