]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/vmwgfx: Validate the box size for the snooped cursor
authorZack Rusin <zackr@vmware.com>
Wed, 26 Oct 2022 03:19:35 +0000 (23:19 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:50 +0000 (11:41 +0100)
commit 01ca4f2d4f8350dd3ebe555b90e2e8d790a82609 upstream.

Invalid userspace dma surface copies could potentially overflow
the memcpy from the surface to the snooped image leading to crashes.
To fix it the dimensions of the copybox have to be validated
against the expected size of the snooped cursor.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Fixes: 4006e3417b26 ("vmwgfx: Snoop DMA transfers with non-covering sizes")
Cc: <stable@vger.kernel.org> # v3.2+
Reviewed-by: Michael Banack <banackm@vmware.com>
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221026031936.1004280-1-zack@kde.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

index 0b800c354049230685a0a3d8c6af02a12ac1f8c0..2492d3a19f36c521876a82a035c3e07a393539d4 100644 (file)
@@ -182,7 +182,8 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
        if (cmd->dma.guest.ptr.offset % PAGE_SIZE ||
            box->x != 0    || box->y != 0    || box->z != 0    ||
            box->srcx != 0 || box->srcy != 0 || box->srcz != 0 ||
-           box->d != 1    || box_count != 1) {
+           box->d != 1    || box_count != 1 ||
+           box->w > 64 || box->h > 64) {
                /* TODO handle none page aligned offsets */
                /* TODO handle more dst & src != 0 */
                /* TODO handle more then one copy */