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=1796382260; b=OWUbyQ9eS6+aX0w58pq61HeG82WWicLBZ0AWlNI9j9DRCwL+MVlsim+QZARPQ2WawsxX IprzszrfLHF2zpZAUgNyOLwjWtm5Pil9NzCa2TbFhtAiSYadaDOweFCS6F4HYQjntYRi9 7OXK5EFZ3yHu4icSKblcK/Y3Lq3NKk+EUERY5IUuSr/fkjO1b1GC6emZ3O++sc8nvrCwj hR7WPNP8lfXhZDDQ6kRW9XJe8AQX6lAgkITu7dE4Oq2OJjC4z7QgygEZsoXgvyPXa8oKK VFzuekWFTkq0r3/uUcB8NZ2deQEqqk39ZTLMgG+jJpzkVPwD0NExoDWw8iXZEMZKRig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382260; 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=yxxu8ctC2QYiMTc/XD4YjHLbW6VlOa4BlIUh93l9HQI=; b=p406V+Jkxq34iT1MeCJ7mzSzd9INjwhU53EA4FDZHzw1G7Zo5gBKj2OomgihkCivcy5O AmM/Po1Be3MIKMonxSWmnIgeyhv5fqU25j2RZ3ZzZ35z+7gQnZWF6mhSGJ01UKu9Inmt3 Y8/2XYqK+oin2S1wQ8lC2CvDctgEIiFn3b67rAtuS68pLIPtgYn8Jjqc9RzQAvLV44oou cr5kB4VzN0kE1HzJL2nW/maOted8LJrOsZ/5vxyIOXJoaYrqLhh0LBiTdjdzXjt9raI8r KpoQipueGEwU5IFWDk05VFNWgQ5/bADufRUg6LAzy/wxnE/VtuO/zId1c/P7M8L6oqw== 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=zvQ8cjv1; 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 62C5D606A322; Fri, 4 Dec 2026 11:04:20 +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=zvQ8cjv1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF2101F000CE; Fri, 4 Dec 2026 11:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382260; bh=yxxu8ctC2QYiMTc/XD4YjHLbW6VlOa4BlIUh93l9HQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zvQ8cjv1+bV0s648xUdO/1Jx4TSdOMbc6xOBwxumWph1QcPAOcFvDZhqv1Nnzm0SG jZ3kR+8RJ2jt8x9Efb7P+S6a8NbWCJ3DtPNSNSTmrmEFCp+nfJln9yZQRnxg86oHUz GfltV9ARel5Bk2bWu8qyCPpD166iEd7+NVHm67c4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vladimir Popov , Zack Rusin Subject: [PATCH 6.18 378/703] drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence() Date: Fri, 4 Dec 2026 19:04:37 +0900 Message-ID: <20261204100637.897474729@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: Vladimir Popov commit 06f8a6708a98dff199ef7ea553b092efc38b4eab upstream. If vmw_execbuf_fence_commands() call fails in vmw_kms_helper_validation_finish(), it sets *p_fence = NULL. If ctx->bo_list is not empty, the caller, vmw_kms_helper_validation_finish(), passes the fence through a chain of functions to dma_fence_is_array(), which causes a NULL pointer dereference in dma_fence_is_array(): vmw_kms_helper_validation_finish() // pass NULL fence vmw_validation_done() vmw_validation_bo_fence() ttm_eu_fence_buffer_objects() // pass NULL fence dma_resv_add_fence() dma_fence_is_container() dma_fence_is_array() // NULL deref Fix this by adding a NULL check in vmw_validation_bo_fence(): if the fence is NULL, fall back to ttm_eu_backoff_reservation()to safely release the buffer object reservations without attempting to add a NULL fence to dma_resv. This is safe because when fence is NULL, vmw_fallback_wait() has already been called inside vmw_execbuf_fence_commands() to synchronize the GPU. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 038ecc503236 ("drm/vmwgfx: Add a validation module v2") Cc: stable@vger.kernel.org Signed-off-by: Vladimir Popov Reviewed-by: Zack Rusin Signed-off-by: Zack Rusin Link: https://patch.msgid.link/20260414105529.9883-1-popov.nkv@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_validation.h @@ -127,16 +127,23 @@ vmw_validation_bo_reserve(struct vmw_val * vmw_validation_bo_fence - Unreserve and fence buffer objects registered * with a validation context * @ctx: The validation context + * @fence: Fence with which to fence all buffer objects taking part in the + * command submission. * * This function unreserves the buffer objects previously reserved using - * vmw_validation_bo_reserve, and fences them with a fence object. + * vmw_validation_bo_reserve, and fences them with a fence object if the + * given fence object is not NULL. */ static inline void vmw_validation_bo_fence(struct vmw_validation_context *ctx, struct vmw_fence_obj *fence) { - ttm_eu_fence_buffer_objects(&ctx->ticket, &ctx->bo_list, - (void *) fence); + /* fence is able to be NULL if vmw_execbuf_fence_commands() fails */ + if (fence) + ttm_eu_fence_buffer_objects(&ctx->ticket, &ctx->bo_list, + (void *)fence); + else + ttm_eu_backoff_reservation(&ctx->ticket, &ctx->bo_list); } /**