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=1796382847; b=VNnJunhDs861XQ1+I7quPSLFHOtqUGA/Dta0TosMCjSMHR/EkySQSIT/sZ0sHPKO9BW0 uJFNQKdZ3cXw7un+ZZKP+8IWvCdQjK5UqbE0KsCDMyGZYNc61QnTVdP5K6IRO2p0w/FCH hkdklR3cYDwNeQsnyh1nZsfey70nn26GQk6ak5/aHkStTC2m0rhkwTpJD9JZFNS+819Cb TFqQDLQUK3bU18Rod8V0OLxVIPsT4X1rlcFT3qgcNW+iIoz6BthMMqQcmkve8tfHh/1KJ KW1PXs+xFzXwnUwX/Bho8xdlFM0iLTU3e5jgKNunIwiXlZX6MRviUSpQVCNHJ4Ps60A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382847; 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=9/f2T2X6hFJJkTkd1xb3wOZXfGCabzHJwgJPJZZaQGU=; b=HJ8eF2Mw2Z7BRduRStDItpUhR0NwAWA+pJX4YeZfiEksdYkwLfb31vWw/dcX7ipTF19g tbTNas1N2IDaGwVBx+km6pyYWvUm4zaEuWrsOatm/ksJkS4fzJ51GMuQRjAcfrxwSKJ/9 TGe3iZFvAWeAqoh5mu/hkRIwasQy5zjrZK7GppS8VND0XCI3eChRxTkIFHadk8BQK3yZB /n+S0MTSv0fYua+Lsmf2cvG/XSDgAfwjlyNpgDDTVlPAYbJLW/mJ6Wb8baPl79VPCuYk8 YvMgoP0jPVYMmBTPlvc5Y+27JNWpJoJf9B0VqRjgLMD8iN0WkyphAEiLiD3/WJG+0Lg== 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=Ax7SqXUf; 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 22E6A606A322; Fri, 4 Dec 2026 11:14:06 +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=Ax7SqXUf Received: by smtp.kernel.org (Postfix) with ESMTPSA id C17EC1F00A05; Fri, 4 Dec 2026 11:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382846; bh=9/f2T2X6hFJJkTkd1xb3wOZXfGCabzHJwgJPJZZaQGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ax7SqXUfYjAPezt2V7dd3/7bcQ+TbEhkkWhdgIynrBhU5xGwijlLiUY04T3da9LRi iSS2tpzb/QlhBfeSDoINRra1G1+7iIAUWSJeMGqNFcXOK4xckv13nrPkl8EsCPFoIC cdk+i9n90BVLvzSEyV8HqYgbFkKPvJj7xpwaoE+M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dave Airlie Subject: [PATCH 6.18 620/703] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period Date: Fri, 4 Dec 2026 19:08:39 +0900 Message-ID: <20261204100644.278103294@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 @@ -248,6 +248,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; };