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=1794050051; b=JA2ctuo6jJL3nurFZSJ9c46W6mDzTwO6CZAZKguk8u/bMzjtGcu5UYWU+alfdiOuyXRd 4ip0Z9dvTy+wer5SGg05cXIJWQ0tnRhCpe64w1CGnV51/0nDQUqCU9uN0QpOOx0K+9b9m 1dQXqW0KZ1yudVC+F8RrxNJPDiVZawiYep33ATNFY98R7uUk3LnURQc88N60N9laFQqoW q4u5cW9ADHD4oFyiXvSqO4hujsXcECWbTsr49foyVPMqt1eh70s8D2vYSwO8RDOeamr1A X0q97N9EhsaGvEwAoucmrBS/7JUTL2aSsOiz8pGekgGWVZUWnkKNNtZ9OvnUJNj5f8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794050051; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=xtQDNn7KFgbm6UFgFmXbsGd8ieypMGtXW54R2fCOuFo=; b=KUFiFT1f87spQVRnLR0aKLIsWlT8joxJjrt3G9X83CQOFTUnh+f01+cVlnOLyvjylnpB BPJONG4IJkjWnm+v5SV2gGr04bwjb0Tvtew4uNRzZV9KpEIUH/ovB+t2ufVog9V3IjmtN EVQMgzOcLupYpELYW6jc3coYYY8VHjVarIUFGynQ+RAjfdPqo+OYODU/eZFJiltxmYxgz MqKRW5+9A9lnS2ZSMxlnWzg2tp+2iE8YKAQVbnW8uYGJ4OPkqD5MTXuXjp4QQUVQPy1tI bSHWIyb9ac1rCpljweodJZHkszTlsGBDDptvHIAIv7wGBV1+hkTwEnoTZyEaNjFtbEg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="cZESuvY/"; 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 08220606A32C for ; Sat, 7 Nov 2026 11:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cZESuvY/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26B851F0089F; Sat, 7 Nov 2026 11:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794050050; bh=xtQDNn7KFgbm6UFgFmXbsGd8ieypMGtXW54R2fCOuFo=; h=From:To:Cc:Subject:Date; b=cZESuvY/GbfHIpCNHxHXR6Rsa3drFLBzjqWp133mcVCi+Y18ubcCioAA540oDJX68 nfiQ/wMCYLLMq5ryZSO+Lzgck0PNF1SupvFrYiEEIktY6xSOXrKm80woKMgT7cHDJe MG/r/IyBkbYbaflokky6KmknjhpyYMSRcP4Prvy8WvQyZKDHXThxGWhVc5LnPQlbnm jlpmrWvRTbH57hIrIZgMHpRkQ6T6Y8O3Ga+KJEqzL7bKNdH9ecjkNT7aL4wbvfAK4B 4xqnEKBHnw7wJTMOGhz0+2OQefdEC3JK7AaLV/GQVXwmvQQLYm8AyxsYTUaUuRRarQ itSA2TutH6fUQ== From: Sasha Levin To: whi4ed0g@gmail.com, danisjiang@gmail.com, lyude@redhat.com Cc: stable@vger.kernel.org Subject: FAILED: patch "[PATCH] drm/nouveau/svm: drain fault handler before freeing svmm" failed to apply to 5.10-stable tree Date: Sat, 7 Nov 2026 06:14:08 -0500 Message-ID: <20261107061408-failed-5.10-b46ddaf08234@kernel.org> X-Mailer: git-send-email 2.53.0 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x b46ddaf0823405f81e681eb26ec98508f3eb9a07 # git commit -s git send-email --to '' --in-reply-to '20261107061408-failed-5.10-b46ddaf08234@kernel.org' --subject-prefix 'PATCH 5.10.y' 'HEAD^..' Thanks, Sasha ------------------ original commit in Linus's tree ------------------ >From b46ddaf0823405f81e681eb26ec98508f3eb9a07 Mon Sep 17 00:00:00 2001 From: Zhenhao Wan Date: Fri, 14 Aug 2026 18:00:05 +0800 Subject: [PATCH] drm/nouveau/svm: drain fault handler before freeing svmm The SVM fault handler nouveau_svm_fault() looks up each fault's nouveau_svmm under svm->mutex, caches it in the fault array, then drops svm->mutex and dereferences the svmm across blocking faults (mmu_interval_notifier_insert(), hmm_range_fault()). nouveau_svmm is not refcounted. On DRM file close nouveau_svmm_fini() -> mmu_notifier_put() frees it asynchronously via call_srcu() without waiting for the handler, and mmget_not_zero() pins the mm, not the svmm. flush_work() on the fault buffer otherwise runs only at device removal and suspend, never on close, so a fault handled concurrently with a close can dereference a freed svmm. The instance is already unlinked by nouveau_svmm_part() earlier in the same close, so no new fault can resolve to it. Drain the handler in nouveau_svmm_fini() before the free, guarding the flush with a NULL check on drm->svm: on device teardown nouveau_svm_fini() runs first and frees drm->svm (NULL) after blocking the notify and flushing the buffer, so the handler is already drained; on per-client close drm->svm is alive and the flush runs. Fixes: eeaf06ac1a55 ("drm/nouveau/svm: initial support for shared virtual memory") Reported-by: Yuhao Jiang Assisted-by: Claude:claude-opus-5 Cc: stable@vger.kernel.org Signed-off-by: Zhenhao Wan Reviewed-by: Lyude Paul Signed-off-by: Lyude Paul Link: https://patch.msgid.link/20260814-nouveau-svm-svmm-uaf-v2-1-8e6590519f07@gmail.com --- drivers/gpu/drm/nouveau/nouveau_svm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index dcc92131488ea..a87406d3da300 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -304,6 +304,19 @@ nouveau_svmm_fini(struct nouveau_svmm **psvmm) { struct nouveau_svmm *svmm = *psvmm; if (svmm) { + struct nouveau_svm *svm = svmm->vmm->cli->drm->svm; + + /* The fault handler caches svmm pointers under svm->mutex and + * dereferences them after dropping it, across blocking faults. + * The instance is already unlinked (nouveau_svmm_part), so drain + * the handler before the free to release any in-flight reference. + * + * On device teardown nouveau_svm_fini() ran first and freed + * drm->svm (NULL) after draining the buffer; nothing to flush. + */ + if (svm) + flush_work(&svm->buffer[0].work); + mutex_lock(&svmm->mutex); svmm->vmm = NULL; mutex_unlock(&svmm->mutex); -- 2.53.0