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=1796220924; b=MBvPEFLvUgeLEhYIntPPq/3UXQCQ7CaSVYizCD7v15mzpZSTTQfdiOMcOoOiMNak8Y9v JnjwJpQvT3kceLajGhZyfq2kLJxCgmHuDZw/Z3XiSN1I2Ha/PU2hkH4I7QD2JxJ4W/UXL 4VXyhbdP7rgjDjEW+9VwCP+dGWxvvvo8lDAcx9MV0XhctMQ3GxJFiJznBY0gkqL3uYe0n aZ1wnJdlw04Ir3h4cZ6w9dCOt32+Z5leOkpApJdX3Dpsv15rz0/iJ255HgMQAr/BH+PEU TptF2fVvS9OS6oP90I0/xETyPSagpurbCASeaRzsFSqL0bcI7Ai/b6nKnrHVQioRs9A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796220924; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=mg6W8ut0GHo+wz7U+iHyb+AdC/rgbCpL/Mo3NDPM3uw=; b=PwwaWHv6SIptU1NA7WpBrInp+gDzZCna4p6B9HvGyvtCFINYETLiycO0NW5lb4C3SG0n tE4vuscUPWVq0bVgAER3EO4ZpApa+cl9fb44eawr/5TyNcnPagqgvAErrPyRvPjhxtlPv UW5ZUEmp06bPxgQ0UPrJ3Zuy+ynvuCCZ3WS7045lHruDKDCJJy6MYphtMuLFJCgF8zaQ8 7BGGYBGH9PJIDO20RnJ2TSrFZfbcE9WWyWDl67sHyGjIuLkzaLqx6GReauheSqXh155Uk Fz7TpsmRY8hab24BGdUgGS3P7OwxJ1AAp/qly793vswMy2tpyloW1X/hhqNPr9M4WKw== 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="T/XPX75W"; 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 56C06606A31A for ; Wed, 2 Dec 2026 14:15:24 +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=T/XPX75W Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CAC51F00896; Wed, 2 Dec 2026 14:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796220924; bh=mg6W8ut0GHo+wz7U+iHyb+AdC/rgbCpL/Mo3NDPM3uw=; h=Subject:To:Cc:From:Date; b=T/XPX75WsgwmZLoF7ibnMILF9yk4mMexcQcH8BBzDZLIIbZw5uj3XsAamlH7z95Tb 6+jzQZGFNvc55S2o3FD/wMKSYWJVy/JCZQxrFZVwndvubtYVT1qPBJWJRjL2w8h6On Z90Pji2/2WxrfSOYiQY3330xBLpmx6p8kZfl4rIk= Subject: FAILED: patch "[PATCH] drm/vmwgfx: validate backup buffer size in command buffer" failed to apply to 6.18-stable tree To: zack.rusin@broadcom.com,ian.forbes@broadcom.com,zdi-disclosures@trendmicro.com Cc: From: Date: Wed, 02 Dec 2026 13:54:55 +0100 Message-ID: <2026120255-copy-dayroom-addd@gregkh> 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=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-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-6.18.y git checkout FETCH_HEAD git cherry-pick -x c1e6267b9dd3e04f9dc29e500414cc4fc237dec1 # git commit -s git send-email --to '' --in-reply-to '2026120255-copy-dayroom-addd@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From c1e6267b9dd3e04f9dc29e500414cc4fc237dec1 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 26 Oct 2026 23:15:33 -0400 Subject: [PATCH] drm/vmwgfx: validate backup buffer size in command buffer processing vmw_cmd_res_switch_backup lets userspace bind an arbitrary MOB to a resource without checking that the MOB is large enough for the resource's guest_memory_size. The dirty-tracking bitmap is allocated based on the MOB size, but later accessed using the (larger) surface size, causing an out-of-bounds write in the bitmap that corrupts adjacent slab memory. Add a check that backup_offset + res->guest_memory_size does not exceed the buffer size before allowing the backup switch. DX shaders and stream outputs never set guest_memory_size, and both were allocated with kmalloc(), so the check would read uninitialized memory for SVGA_3D_CMD_DX_BIND_SHADER and SVGA_3D_CMD_DX_BIND_STREAMOUTPUT and could reject valid binds. Allocate both with kzalloc() so their guest_memory_size is 0 and the check only bounds the offset. Fixes: a97e21923b42 ("drm/vmwgfx: Hook up guest-backed surfaces") Cc: stable@vger.kernel.org Reported-by: Zero Day Initiative # ZDI-CAN-34068 Closes: https://lore.kernel.org/all/BYAPR01MB38301CFC012E873340F77E3D80662@BYAPR01MB3830.prod.exchangelabs.com/ Signed-off-by: Zack Rusin Reviewed-by: Ian Forbes Link: https://patch.msgid.link/20261027031533.2241918-1-zack.rusin@broadcom.com diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 7b943e99061e..435425f1adfa 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -1794,6 +1794,7 @@ static int vmw_cmd_res_switch_backup(struct vmw_private *dev_priv, { struct vmw_bo *vbo; void *info; + u64 end; int ret; info = vmw_execbuf_info_from_res(sw_context, res); @@ -1804,6 +1805,13 @@ static int vmw_cmd_res_switch_backup(struct vmw_private *dev_priv, if (ret) return ret; + if (check_add_overflow((u64)backup_offset, + (u64)res->guest_memory_size, &end) || + end > vbo->tbo.base.size) { + VMW_DEBUG_USER("Backup buffer too small for resource.\n"); + return -EINVAL; + } + vmw_validation_res_switch_backup(sw_context->ctx, info, vbo, backup_offset); return 0; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c index 39811cf19db1..033157efb1fc 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c @@ -597,7 +597,7 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man, if (!vmw_shader_id_ok(user_key, shader_type)) return -EINVAL; - shader = kmalloc_obj(*shader); + shader = kzalloc_obj(*shader); if (!shader) { return -ENOMEM; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c b/drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c index 52c6cfa163da..34d5b71fa42f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c @@ -284,7 +284,7 @@ int vmw_dx_streamoutput_add(struct vmw_cmdbuf_res_manager *man, struct vmw_private *dev_priv = ctx->dev_priv; int ret; - so = kmalloc_obj(*so); + so = kzalloc_obj(*so); if (!so) { return -ENOMEM; }