]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
drm/virtio: fix bounds check in virtio_gpu_cmd_get_capset()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 4 Jul 2018 09:42:50 +0000 (12:42 +0300)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
commit0859f58aff85b4c7cf820cc1d3f43ea5ecd95e7c
treef3d4d11a9b4ebe9840d27024b50520b24f24653f
parent276d8cef43441f5a8791e0702b5af4963bfb3078
drm/virtio: fix bounds check in virtio_gpu_cmd_get_capset()

BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit 09c4b49457434fa74749ad6194ef28464d9f5df9 ]

This doesn't affect runtime because in the current code "idx" is always
valid.

First, we read from "vgdev->capsets[idx].max_size" before checking
whether "idx" is within bounds.  And secondly the bounds check is off by
one so we could end up reading one element beyond the end of the
vgdev->capsets[] array.

Fixes: 62fb7a5e1096 ("virtio-gpu: add 3d/virgl support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180704094250.m7sgvvzg3dhcvv3h@kili.mountain
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/gpu/drm/virtio/virtgpu_vq.c