* [PATCH] vhost: vringh: Fix copy_to_iter return value check
@ 2025-09-23 21:47 Michael S. Tsirkin
2025-09-24 0:54 ` Jason Wang
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2025-09-23 21:47 UTC (permalink / raw)
To: linux-kernel
Cc: zhang jiao, Jason Wang, Eugenio Pérez, kvm, virtualization,
netdev
The return value of copy_to_iter can't be negative, check whether the
copied length is equal to the requested length instead of checking for
negative values.
Cc: zhang jiao <zhangjiao2@cmss.chinamobile.com>
Link: https://lore.kernel.org/all/20250910091739.2999-1-zhangjiao2@cmss.chinamobile.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
Lightly tested. zhang jiao could you pls also test, either ack or
fold into your patch?
drivers/vhost/vringh.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 0c8a17cbb22e..925858cc6096 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -1162,6 +1162,7 @@ static inline int copy_to_iotlb(const struct vringh *vrh, void *dst,
struct iov_iter iter;
u64 translated;
int ret;
+ size_t size;
ret = iotlb_translate(vrh, (u64)(uintptr_t)dst,
len - total_translated, &translated,
@@ -1179,9 +1180,9 @@ static inline int copy_to_iotlb(const struct vringh *vrh, void *dst,
translated);
}
- ret = copy_to_iter(src, translated, &iter);
- if (ret < 0)
- return ret;
+ size = copy_to_iter(src, translated, &iter);
+ if (size != translated)
+ return -EFAULT;
src += translated;
dst += translated;
--
MST
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost: vringh: Fix copy_to_iter return value check
2025-09-23 21:47 [PATCH] vhost: vringh: Fix copy_to_iter return value check Michael S. Tsirkin
@ 2025-09-24 0:54 ` Jason Wang
2025-09-29 16:00 ` Lei Yang
0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2025-09-24 0:54 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: linux-kernel, zhang jiao, Eugenio Pérez, kvm, virtualization,
netdev
On Wed, Sep 24, 2025 at 5:48 AM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> The return value of copy_to_iter can't be negative, check whether the
> copied length is equal to the requested length instead of checking for
> negative values.
>
> Cc: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> Link: https://lore.kernel.org/all/20250910091739.2999-1-zhangjiao2@cmss.chinamobile.com
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost: vringh: Fix copy_to_iter return value check
2025-09-24 0:54 ` Jason Wang
@ 2025-09-29 16:00 ` Lei Yang
0 siblings, 0 replies; 3+ messages in thread
From: Lei Yang @ 2025-09-29 16:00 UTC (permalink / raw)
To: Jason Wang
Cc: Michael S. Tsirkin, linux-kernel, zhang jiao, Eugenio Pérez,
kvm, virtualization, netdev
Tested this patch with virtio-net regression tests, everything works fine.
Tested-by: Lei Yang <leiyang@redhat.com>
On Wed, Sep 24, 2025 at 8:54 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Wed, Sep 24, 2025 at 5:48 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > The return value of copy_to_iter can't be negative, check whether the
> > copied length is equal to the requested length instead of checking for
> > negative values.
> >
> > Cc: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> > Link: https://lore.kernel.org/all/20250910091739.2999-1-zhangjiao2@cmss.chinamobile.com
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >
> >
>
> Acked-by: Jason Wang <jasowang@redhat.com>
>
> Thanks
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-29 16:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 21:47 [PATCH] vhost: vringh: Fix copy_to_iter return value check Michael S. Tsirkin
2025-09-24 0:54 ` Jason Wang
2025-09-29 16:00 ` Lei Yang
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).