* [PATCH] vhost-vdpa: Set s.num in GET_VRING_GROUP
@ 2025-09-27 12:25 Dan Carpenter
2025-09-27 12:32 ` Michael S. Tsirkin
2025-09-29 6:05 ` Eugenio Perez Martin
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-09-27 12:25 UTC (permalink / raw)
To: Eugenio Pérez
Cc: Michael S. Tsirkin, Jason Wang, kvm, virtualization, netdev,
linux-kernel, kernel-janitors
The group is supposed to be copied to the user, but it wasn't assigned
until after the copy_to_user(). Move the "s.num = group;" earlier.
Fixes: ffc3634b6696 ("vduse: add vq group support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
This goes through the kvm tree I think.
drivers/vhost/vdpa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 6305382eacbb..25ab4d06e559 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -667,9 +667,9 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
group = ops->get_vq_group(vdpa, idx);
if (group >= vdpa->ngroups || group > U32_MAX || group < 0)
return -EIO;
- else if (copy_to_user(argp, &s, sizeof(s)))
- return -EFAULT;
s.num = group;
+ if (copy_to_user(argp, &s, sizeof(s)))
+ return -EFAULT;
return 0;
}
case VHOST_VDPA_GET_VRING_DESC_GROUP:
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost-vdpa: Set s.num in GET_VRING_GROUP
2025-09-27 12:25 [PATCH] vhost-vdpa: Set s.num in GET_VRING_GROUP Dan Carpenter
@ 2025-09-27 12:32 ` Michael S. Tsirkin
2025-09-29 6:04 ` Eugenio Perez Martin
2025-09-29 6:05 ` Eugenio Perez Martin
1 sibling, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2025-09-27 12:32 UTC (permalink / raw)
To: Dan Carpenter
Cc: Eugenio Pérez, Jason Wang, kvm, virtualization, netdev,
linux-kernel, kernel-janitors
On Sat, Sep 27, 2025 at 03:25:34PM +0300, Dan Carpenter wrote:
> The group is supposed to be copied to the user, but it wasn't assigned
> until after the copy_to_user(). Move the "s.num = group;" earlier.
>
> Fixes: ffc3634b6696 ("vduse: add vq group support")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> This goes through the kvm tree I think.
Thanks for the patch!
IIUC this was in my tree for next, but more testing
and review found issues (like this one) so I dropped it for now.
> drivers/vhost/vdpa.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 6305382eacbb..25ab4d06e559 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -667,9 +667,9 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
> group = ops->get_vq_group(vdpa, idx);
> if (group >= vdpa->ngroups || group > U32_MAX || group < 0)
> return -EIO;
> - else if (copy_to_user(argp, &s, sizeof(s)))
> - return -EFAULT;
> s.num = group;
> + if (copy_to_user(argp, &s, sizeof(s)))
> + return -EFAULT;
> return 0;
> }
> case VHOST_VDPA_GET_VRING_DESC_GROUP:
> --
> 2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost-vdpa: Set s.num in GET_VRING_GROUP
2025-09-27 12:32 ` Michael S. Tsirkin
@ 2025-09-29 6:04 ` Eugenio Perez Martin
0 siblings, 0 replies; 4+ messages in thread
From: Eugenio Perez Martin @ 2025-09-29 6:04 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Dan Carpenter, Jason Wang, kvm, virtualization, netdev,
linux-kernel, kernel-janitors
On Sat, Sep 27, 2025 at 2:32 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Sat, Sep 27, 2025 at 03:25:34PM +0300, Dan Carpenter wrote:
> > The group is supposed to be copied to the user, but it wasn't assigned
> > until after the copy_to_user(). Move the "s.num = group;" earlier.
> >
> > Fixes: ffc3634b6696 ("vduse: add vq group support")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > This goes through the kvm tree I think.
>
>
> Thanks for the patch!
>
> IIUC this was in my tree for next, but more testing
> and review found issues (like this one) so I dropped it for now.
>
Yes, that's fixed in v5.
> > drivers/vhost/vdpa.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > index 6305382eacbb..25ab4d06e559 100644
> > --- a/drivers/vhost/vdpa.c
> > +++ b/drivers/vhost/vdpa.c
> > @@ -667,9 +667,9 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
> > group = ops->get_vq_group(vdpa, idx);
> > if (group >= vdpa->ngroups || group > U32_MAX || group < 0)
> > return -EIO;
> > - else if (copy_to_user(argp, &s, sizeof(s)))
> > - return -EFAULT;
> > s.num = group;
> > + if (copy_to_user(argp, &s, sizeof(s)))
> > + return -EFAULT;
> > return 0;
> > }
> > case VHOST_VDPA_GET_VRING_DESC_GROUP:
> > --
> > 2.51.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost-vdpa: Set s.num in GET_VRING_GROUP
2025-09-27 12:25 [PATCH] vhost-vdpa: Set s.num in GET_VRING_GROUP Dan Carpenter
2025-09-27 12:32 ` Michael S. Tsirkin
@ 2025-09-29 6:05 ` Eugenio Perez Martin
1 sibling, 0 replies; 4+ messages in thread
From: Eugenio Perez Martin @ 2025-09-29 6:05 UTC (permalink / raw)
To: Dan Carpenter
Cc: Michael S. Tsirkin, Jason Wang, kvm, virtualization, netdev,
linux-kernel, kernel-janitors
On Sat, Sep 27, 2025 at 2:25 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The group is supposed to be copied to the user, but it wasn't assigned
> until after the copy_to_user(). Move the "s.num = group;" earlier.
>
> Fixes: ffc3634b6696 ("vduse: add vq group support")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> This goes through the kvm tree I think.
>
> drivers/vhost/vdpa.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 6305382eacbb..25ab4d06e559 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -667,9 +667,9 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
> group = ops->get_vq_group(vdpa, idx);
> if (group >= vdpa->ngroups || group > U32_MAX || group < 0)
> return -EIO;
> - else if (copy_to_user(argp, &s, sizeof(s)))
> - return -EFAULT;
> s.num = group;
> + if (copy_to_user(argp, &s, sizeof(s)))
> + return -EFAULT;
> return 0;
> }
> case VHOST_VDPA_GET_VRING_DESC_GROUP:
Thank you very much for the report Dan! that should be fixed in v5.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-29 6:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-27 12:25 [PATCH] vhost-vdpa: Set s.num in GET_VRING_GROUP Dan Carpenter
2025-09-27 12:32 ` Michael S. Tsirkin
2025-09-29 6:04 ` Eugenio Perez Martin
2025-09-29 6:05 ` Eugenio Perez Martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).