mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
Fix use after free in get_capset_info callback.
If a response to virtio_gpu_cmd_get_capset_info takes longer than five seconds to return, the callback will access freed kernel memory in vg->capsets. Signed-off-by: Doug Horn <doughorn@google.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200902210847.2689-2-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
707d561f77
commit
e219688fc5
@ -80,8 +80,10 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
|
|||||||
vgdev->capsets[i].id > 0, 5 * HZ);
|
vgdev->capsets[i].id > 0, 5 * HZ);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
DRM_ERROR("timed out waiting for cap set %d\n", i);
|
DRM_ERROR("timed out waiting for cap set %d\n", i);
|
||||||
|
spin_lock(&vgdev->display_info_lock);
|
||||||
kfree(vgdev->capsets);
|
kfree(vgdev->capsets);
|
||||||
vgdev->capsets = NULL;
|
vgdev->capsets = NULL;
|
||||||
|
spin_unlock(&vgdev->display_info_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DRM_INFO("cap set %d: id %d, max-version %d, max-size %d\n",
|
DRM_INFO("cap set %d: id %d, max-version %d, max-size %d\n",
|
||||||
|
@ -684,9 +684,13 @@ static void virtio_gpu_cmd_get_capset_info_cb(struct virtio_gpu_device *vgdev,
|
|||||||
int i = le32_to_cpu(cmd->capset_index);
|
int i = le32_to_cpu(cmd->capset_index);
|
||||||
|
|
||||||
spin_lock(&vgdev->display_info_lock);
|
spin_lock(&vgdev->display_info_lock);
|
||||||
vgdev->capsets[i].id = le32_to_cpu(resp->capset_id);
|
if (vgdev->capsets) {
|
||||||
vgdev->capsets[i].max_version = le32_to_cpu(resp->capset_max_version);
|
vgdev->capsets[i].id = le32_to_cpu(resp->capset_id);
|
||||||
vgdev->capsets[i].max_size = le32_to_cpu(resp->capset_max_size);
|
vgdev->capsets[i].max_version = le32_to_cpu(resp->capset_max_version);
|
||||||
|
vgdev->capsets[i].max_size = le32_to_cpu(resp->capset_max_size);
|
||||||
|
} else {
|
||||||
|
DRM_ERROR("invalid capset memory.");
|
||||||
|
}
|
||||||
spin_unlock(&vgdev->display_info_lock);
|
spin_unlock(&vgdev->display_info_lock);
|
||||||
wake_up(&vgdev->resp_wq);
|
wake_up(&vgdev->resp_wq);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user