mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 22:58:29 +00:00
vfio-mdev: buffer overflow in ioctl()
This is a sample driver for documentation so the impact is probably
pretty low. But we should check that bar_index is valid so we
don't write beyond the end of the mdev_state->region_info[] array.
Fixes: 9d1a546c53
("docs: Sample driver to demonstrate how to use Mediated device framework.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
6ed0993a0b
commit
5c677869e0
1 changed files with 5 additions and 2 deletions
|
@ -1073,7 +1073,7 @@ int mtty_get_region_info(struct mdev_device *mdev,
|
||||||
{
|
{
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
struct mdev_state *mdev_state;
|
struct mdev_state *mdev_state;
|
||||||
int bar_index;
|
u32 bar_index;
|
||||||
|
|
||||||
if (!mdev)
|
if (!mdev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -1082,8 +1082,11 @@ int mtty_get_region_info(struct mdev_device *mdev,
|
||||||
if (!mdev_state)
|
if (!mdev_state)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&mdev_state->ops_lock);
|
|
||||||
bar_index = region_info->index;
|
bar_index = region_info->index;
|
||||||
|
if (bar_index >= VFIO_PCI_NUM_REGIONS)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
mutex_lock(&mdev_state->ops_lock);
|
||||||
|
|
||||||
switch (bar_index) {
|
switch (bar_index) {
|
||||||
case VFIO_PCI_CONFIG_REGION_INDEX:
|
case VFIO_PCI_CONFIG_REGION_INDEX:
|
||||||
|
|
Loading…
Add table
Reference in a new issue