Linux virtualization list
 help / color / mirror / Atom feed
* [PATCH] vdpasim: Off by one in vdpasim_set_group_asid()
@ 2022-05-23  8:30 Dan Carpenter
  2022-05-24  5:57 ` Jason Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-05-23  8:30 UTC (permalink / raw)
  To: Michael S. Tsirkin, Gautam Dawar
  Cc: kernel-janitors, virtualization, Xie Yongji, Eli Cohen

The > comparison needs to be >= to prevent an out of bounds access
of the vdpasim->iommu[] array.  The vdpasim->iommu[] is allocated in
vdpasim_create() and it has vdpasim->dev_attr.nas elements.

Fixes: 87e5afeac247 ("vdpasim: control virtqueue support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 50d721072beb..0f2865899647 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -567,7 +567,7 @@ static int vdpasim_set_group_asid(struct vdpa_device *vdpa, unsigned int group,
 	if (group > vdpasim->dev_attr.ngroups)
 		return -EINVAL;
 
-	if (asid > vdpasim->dev_attr.nas)
+	if (asid >= vdpasim->dev_attr.nas)
 		return -EINVAL;
 
 	iommu = &vdpasim->iommu[asid];
-- 
2.35.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] vdpasim: Off by one in vdpasim_set_group_asid()
  2022-05-23  8:30 [PATCH] vdpasim: Off by one in vdpasim_set_group_asid() Dan Carpenter
@ 2022-05-24  5:57 ` Jason Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2022-05-24  5:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Michael S. Tsirkin, kernel-janitors, virtualization, Xie Yongji,
	Gautam Dawar, Eli Cohen

On Mon, May 23, 2022 at 4:31 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The > comparison needs to be >= to prevent an out of bounds access
> of the vdpasim->iommu[] array.  The vdpasim->iommu[] is allocated in
> vdpasim_create() and it has vdpasim->dev_attr.nas elements.
>
> Fixes: 87e5afeac247 ("vdpasim: control virtqueue support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Jason Wang <jasowang@redhat.com>

> ---
>  drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> index 50d721072beb..0f2865899647 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> @@ -567,7 +567,7 @@ static int vdpasim_set_group_asid(struct vdpa_device *vdpa, unsigned int group,
>         if (group > vdpasim->dev_attr.ngroups)
>                 return -EINVAL;
>
> -       if (asid > vdpasim->dev_attr.nas)
> +       if (asid >= vdpasim->dev_attr.nas)
>                 return -EINVAL;
>
>         iommu = &vdpasim->iommu[asid];
> --
> 2.35.1
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-24  5:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-23  8:30 [PATCH] vdpasim: Off by one in vdpasim_set_group_asid() Dan Carpenter
2022-05-24  5:57 ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox