* [patch 2/3] vfio-mdev: buffer overflow in ioctl()
@ 2017-01-07 6:28 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-01-07 6:28 UTC (permalink / raw)
To: Kirti Wankhede; +Cc: kvm, kernel-janitors
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: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index d2656ff569c1..353666d68207 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -1073,7 +1073,7 @@ int mtty_get_region_info(struct mdev_device *mdev,
{
unsigned int size = 0;
struct mdev_state *mdev_state;
- int bar_index;
+ u32 bar_index;
if (!mdev)
return -EINVAL;
@@ -1082,8 +1082,11 @@ int mtty_get_region_info(struct mdev_device *mdev,
if (!mdev_state)
return -EINVAL;
- mutex_lock(&mdev_state->ops_lock);
bar_index = region_info->index;
+ if (bar_index >= VFIO_PCI_NUM_REGIONS)
+ return -EINVAL;
+
+ mutex_lock(&mdev_state->ops_lock);
switch (bar_index) {
case VFIO_PCI_CONFIG_REGION_INDEX:
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [patch 2/3] vfio-mdev: buffer overflow in ioctl()
@ 2017-01-07 6:28 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-01-07 6:28 UTC (permalink / raw)
To: Kirti Wankhede; +Cc: kvm, kernel-janitors
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: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index d2656ff569c1..353666d68207 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -1073,7 +1073,7 @@ int mtty_get_region_info(struct mdev_device *mdev,
{
unsigned int size = 0;
struct mdev_state *mdev_state;
- int bar_index;
+ u32 bar_index;
if (!mdev)
return -EINVAL;
@@ -1082,8 +1082,11 @@ int mtty_get_region_info(struct mdev_device *mdev,
if (!mdev_state)
return -EINVAL;
- mutex_lock(&mdev_state->ops_lock);
bar_index = region_info->index;
+ if (bar_index >= VFIO_PCI_NUM_REGIONS)
+ return -EINVAL;
+
+ mutex_lock(&mdev_state->ops_lock);
switch (bar_index) {
case VFIO_PCI_CONFIG_REGION_INDEX:
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch 2/3] vfio-mdev: buffer overflow in ioctl()
2017-01-07 6:28 ` Dan Carpenter
@ 2017-01-09 18:51 ` Kirti Wankhede
-1 siblings, 0 replies; 4+ messages in thread
From: Kirti Wankhede @ 2017-01-09 18:39 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kvm, kernel-janitors, Alex Williamson
CC+= Alex
Thanks Dan for fixing.
Reviewed by: Kirti Wankhede <kwankhede@nvidia.com>
Thanks,
Kirti
On 1/7/2017 11:58 AM, Dan Carpenter wrote:
> 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: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
> index d2656ff569c1..353666d68207 100644
> --- a/samples/vfio-mdev/mtty.c
> +++ b/samples/vfio-mdev/mtty.c
> @@ -1073,7 +1073,7 @@ int mtty_get_region_info(struct mdev_device *mdev,
> {
> unsigned int size = 0;
> struct mdev_state *mdev_state;
> - int bar_index;
> + u32 bar_index;
>
> if (!mdev)
> return -EINVAL;
> @@ -1082,8 +1082,11 @@ int mtty_get_region_info(struct mdev_device *mdev,
> if (!mdev_state)
> return -EINVAL;
>
> - mutex_lock(&mdev_state->ops_lock);
> bar_index = region_info->index;
> + if (bar_index >= VFIO_PCI_NUM_REGIONS)
> + return -EINVAL;
> +
> + mutex_lock(&mdev_state->ops_lock);
>
> switch (bar_index) {
> case VFIO_PCI_CONFIG_REGION_INDEX:
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch 2/3] vfio-mdev: buffer overflow in ioctl()
@ 2017-01-09 18:51 ` Kirti Wankhede
0 siblings, 0 replies; 4+ messages in thread
From: Kirti Wankhede @ 2017-01-09 18:51 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kvm, kernel-janitors, Alex Williamson
CC+= Alex
Thanks Dan for fixing.
Reviewed by: Kirti Wankhede <kwankhede@nvidia.com>
Thanks,
Kirti
On 1/7/2017 11:58 AM, Dan Carpenter wrote:
> 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: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
> index d2656ff569c1..353666d68207 100644
> --- a/samples/vfio-mdev/mtty.c
> +++ b/samples/vfio-mdev/mtty.c
> @@ -1073,7 +1073,7 @@ int mtty_get_region_info(struct mdev_device *mdev,
> {
> unsigned int size = 0;
> struct mdev_state *mdev_state;
> - int bar_index;
> + u32 bar_index;
>
> if (!mdev)
> return -EINVAL;
> @@ -1082,8 +1082,11 @@ int mtty_get_region_info(struct mdev_device *mdev,
> if (!mdev_state)
> return -EINVAL;
>
> - mutex_lock(&mdev_state->ops_lock);
> bar_index = region_info->index;
> + if (bar_index >= VFIO_PCI_NUM_REGIONS)
> + return -EINVAL;
> +
> + mutex_lock(&mdev_state->ops_lock);
>
> switch (bar_index) {
> case VFIO_PCI_CONFIG_REGION_INDEX:
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-09 18:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-07 6:28 [patch 2/3] vfio-mdev: buffer overflow in ioctl() Dan Carpenter
2017-01-07 6:28 ` Dan Carpenter
2017-01-09 18:39 ` Kirti Wankhede
2017-01-09 18:51 ` Kirti Wankhede
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.