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=1796384175; b=q3E7cH6xjQgFVk0Wduz055RyaxVRlOEpr3AfuFl2hScHFRfy7pcjx3VL078w1uYOvjYo JdJu/mU7dLTcJJ3d8wubTq7uJWeW3kaC8RQiiG4qr2GUzwShlI/xIIwkDVXjvje8iMpxg cCsNCrGVtiG8NI6VMwMbk1jPuEZn6NdSPZ/4poUcrxXXchrpzIj56br7DS5GYd6UyTg63 4IvCEVMsG8YjA6KHWQNrZfRX1quz/j38P3Ln7nycDyln4tQwqDVKevfTmqfaIcG/k0Rzj D/dg9/+X2Ze2bVphxGjG60QBbrpfi/rstZnJTnh89F4s/67hft1WmM6G4423o0iFZQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384175; 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=0tG+zXzT8Zj7ZC0wzfAUNyBXWD+7WPCDzrqcw2eiS2o=; b=ZlbkJCRLz89/5T75ukB4iO15CVVsvh2MIoK/UodtQXZ21yBlyeTfs9JDx3Y2GsWssEza xt4pZWASgaxrfSfranLLBecFC+TjhRVx5VVXF8OIpmE1Lko76IGQXozG3nFOGWpqini/B RWlRt9XSJ2d4HeFNajCmxoXDOc/JD7rthBon8QO53UKXtC5EOpSGDJ6jvrBVBPIsJa45o PBax3z20w4044IY7X/jgRIIMRI0llEkOvb65XPZgi2FiGBABTWl1NJ1/xnvw7n9knnjYK 69j2CFIN8WrWGPb1ITyQIg7pix9qseqM/M6X820QwvNWQi/fRO5Gojy9JsxHq+CuVPw== 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=hjIKG+gR; 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 E327E606A682; Fri, 4 Dec 2026 11:36:14 +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=hjIKG+gR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0738F1F000CE; Fri, 4 Dec 2026 11:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384174; bh=0tG+zXzT8Zj7ZC0wzfAUNyBXWD+7WPCDzrqcw2eiS2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hjIKG+gREQDn7fauWT2HxYfRY2Pn42n4m9KfkbaWTE4oC2BpWFMEWd8OZ3XKSUN23 PcvyYnwW5wl8y1688SyscNulZf4oSanHgr927Outqw4sGmCc35tBkiQi/v6BQO4yqs wzlJ7/gfbdmj8Sz3aGPE14nLuPdSRwuXqRnjsiDQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dave Airlie Subject: [PATCH 6.12 528/555] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period Date: Fri, 4 Dec 2026 19:09:31 +0900 Message-ID: <20261204100628.843397324@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Airlie commit 4cd3c5bdf16789fc8c8736ed1a1a645b8cecb3b6 upstream. There is a race in the vma lookup and the vma freeing that can race object close against object execbuffer vma lookups. execbuffer2 and close on two threads can be raced, so the radix tree lookup and tryget in eb_lookup_vma can be raced against a freed vma. The rcu protection in the eb lookup doesn't help because we don't use rcu around the free path. This patch adds rcu protection around the vma destruction path. We could also probably use SLAB_TYPESAFE_BY_RCU but there may be other submarined vma races in other code that this might not fix, so let's just force the rcu on free. Cc: stable@vger.kernel.org Signed-off-by: Dave Airlie Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/i915_vma.c | 2 +- drivers/gpu/drm/i915/i915_vma_types.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -65,7 +65,7 @@ static struct i915_vma *i915_vma_alloc(v static void i915_vma_free(struct i915_vma *vma) { - return kmem_cache_free(slab_vmas, vma); + kfree_rcu(vma, rcu); } #if IS_ENABLED(CONFIG_DRM_I915_ERRLOG_GEM) && IS_ENABLED(CONFIG_DRM_DEBUG_MM) --- a/drivers/gpu/drm/i915/i915_vma_types.h +++ b/drivers/gpu/drm/i915/i915_vma_types.h @@ -296,6 +296,9 @@ struct i915_vma { struct list_head closed_link; + /** rcu head for kfree_rcu */ + struct rcu_head rcu; + /** The async vma resource. Protected by the vm_mutex */ struct i915_vma_resource *resource; };