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=1796380713; b=4jbfol4HPYaQCIXrI4qkSrnAksjPqm1vr2Ki0hgvx4B1ae7kEZaqk7HWidUp9jEJBCWo NjlpW4kQoVNbQ5C5NgdLQZNY6Kv6H2zTzQEKgrARVmMvYsZ4NU+iUxGo8c1bTL59YYIZi /BODTjK4mw34v8s6UaWOj3kg1NPImy3jJygKqzFJWvm1O6LIdmcfehX9vhDgaQIu6jTeg CboOupCGjSZdXjQSqQiXf5RPqwR+IU3IdaZKjHx8oa0G6PHvO0odAeb+ccuU0mjWiGcUL cfOKnNqegKueJbml4Goern1xSOZcSeCnHPhO883VcQ0EZu8bUNmUXZ0KNIpr0aZfgeA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380713; 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-Type:Content-Transfer-Encoding; bh=CDS8WPwATykU1bU7/zW6zuFhp0n7bWei/ngZHj7qNoA=; b=2fZYWH+rIKkCQXImweJ9EUdOUGs4lXwiHMZfvp4KrnlZBV1AjrorFv7w/152O3fLDnu4 1XVtI1zLPMON8GaQr4uLbxZ6ybDX1nt4a31ZYKneqsLlRFy8BkR2Zq9N3ET6Ti9XaUFtv +2zHDlfUo3Equ5pVTM89TWHZBP1UiagmAVgd2fAcF/zD83NfluM4RS/g7zYknfDpCR14t p120v2LAecQ94aKeUbLT+S3IFbXgUDam4f3WtxqjDXasWfJGKFv8RDdaGCgvU3O+dbt1L DiOm1kQMiEzg9eD5HR98QMiZTLhVLCY0e6l0CHHqO/jN1uCeqyYrUCvZjXhGWDHmW8Q== 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=2gDzYqhk; 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 AF37E606A322; Fri, 4 Dec 2026 10:38:33 +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=2gDzYqhk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A31B1F000C2; Fri, 4 Dec 2026 10:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380713; bh=CDS8WPwATykU1bU7/zW6zuFhp0n7bWei/ngZHj7qNoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2gDzYqhk5oFyHXFBdY74OBOVs+vJ2Mb1/yttFQ7Yum0ta2PH5s8/rpuxnzuVfCcya UXqh1wpTwFIxWFU4U2G8AheB01bJlOtf6CNLs7FKhjzDpZUWW0CaloR5GtjV6pMZxq 5hxZoG2vg06/2arfTOo07bK0EYBwjG0Zr2sbEElM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Benjamin Cheng , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher Subject: [PATCH 7.3 391/742] drm/amdgpu: wait for tlb flush before freeing BO Date: Fri, 4 Dec 2026 19:04:15 +0900 Message-ID: <20261204100645.475183329@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benjamin Cheng commit 11f1080ba1bd3df2b2539dab878b3e2a0a89681f upstream. On gem object close, we previously only attached the fence of its own clear_freed() call to the BO's resv. If an unmap of this BO happened prior to the close call, clear_freed() would be invoked, leaving vm->freed empty, and no meaningful fence to be attached to the resv. Because of that the memory may be freed before the TLB flush is complete, and give a running userq potential access to a stale address translation. Fix this by attaching the last_tlb_inv fence to the BO's resv. Fixes: a1d201e16940 ("drm/amdgpu: enable GFX-V11 userqueue support") Signed-off-by: Benjamin Cheng Reviewed-by: Christian König Signed-off-by: Alex Deucher (cherry picked from commit ab88e18030a1f2c340f64172287af19d1a48d3cc) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -326,7 +326,7 @@ static void amdgpu_gem_object_close(stru drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 0); drm_exec_until_all_locked(&exec) { - r = drm_exec_prepare_obj(&exec, &bo->tbo.base, 1); + r = drm_exec_prepare_obj(&exec, &bo->tbo.base, 2); /* clear_freed + last_tlb_inv */ drm_exec_retry_on_contention(&exec); if (unlikely(r)) goto out_unlock; @@ -357,11 +357,14 @@ static void amdgpu_gem_object_close(stru dev_err(adev->dev, "failed to clear page " "tables on GEM object close (%ld)\n", r); if (r || !fence) - goto out_unlock; + goto out_tlb; amdgpu_bo_fence(bo, fence, true); dma_fence_put(fence); +out_tlb: + amdgpu_bo_fence(bo, vm->last_tlb_inv, true); + out_unlock: if (r && !drm_dev_is_unplugged(adev_to_drm(adev))) dev_err(adev->dev, "leaking bo va (%ld)\n", r);