netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] vhost: vringh: Fix copy_to_iter return value check
@ 2025-09-25  6:04 Michael S. Tsirkin
  2025-09-26  9:51 ` Simon Horman
  2025-09-27  0:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2025-09-25  6:04 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>
---
 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] 5+ messages in thread

* Re: [PATCH net] vhost: vringh: Fix copy_to_iter return value check
  2025-09-25  6:04 [PATCH net] vhost: vringh: Fix copy_to_iter return value check Michael S. Tsirkin
@ 2025-09-26  9:51 ` Simon Horman
  2025-09-27  0:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: Simon Horman @ 2025-09-26  9:51 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, zhang jiao, Jason Wang, Eugenio Pérez, kvm,
	virtualization, netdev

On Thu, Sep 25, 2025 at 02:04:08AM -0400, Michael S. Tsirkin 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>

Hi Michael,

As a patch for net, I think it would be nice to include a fixes tag.
Perhaps:

Fixes: 309bba39c945 ("vringh: iterate on iotlb_translate to handle large translations")

And nicer still to include some description of the failure scenario.

In any case, the code change looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH net] vhost: vringh: Fix copy_to_iter return value check
  2025-09-25  6:04 [PATCH net] vhost: vringh: Fix copy_to_iter return value check Michael S. Tsirkin
  2025-09-26  9:51 ` Simon Horman
@ 2025-09-27  0:50 ` patchwork-bot+netdevbpf
  2025-10-01 11:22   ` Michael S. Tsirkin
  1 sibling, 1 reply; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-27  0:50 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, zhangjiao2, jasowang, eperezma, kvm, virtualization,
	netdev

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 25 Sep 2025 02:04:08 -0400 you 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>
> 
> [...]

Here is the summary with links:
  - [net] vhost: vringh: Fix copy_to_iter return value check
    https://git.kernel.org/netdev/net/c/439263376c2c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH net] vhost: vringh: Fix copy_to_iter return value check
  2025-09-27  0:50 ` patchwork-bot+netdevbpf
@ 2025-10-01 11:22   ` Michael S. Tsirkin
  2025-10-01 14:00     ` Jakub Kicinski
  0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2025-10-01 11:22 UTC (permalink / raw)
  To: patchwork-bot+netdevbpf
  Cc: Jakub Kicinski, linux-kernel, zhangjiao2, jasowang, eperezma, kvm,
	virtualization, netdev

On Sat, Sep 27, 2025 at 12:50:07AM +0000, patchwork-bot+netdevbpf@kernel.org wrote:
> Hello:
> 
> This patch was applied to netdev/net.git (main)
> by Jakub Kicinski <kuba@kernel.org>:
> 
> On Thu, 25 Sep 2025 02:04:08 -0400 you 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>
> > 
> > [...]
> 
> Here is the summary with links:
>   - [net] vhost: vringh: Fix copy_to_iter return value check
>     https://git.kernel.org/netdev/net/c/439263376c2c
> 
> You are awesome, thank you!
> -- 
> Deet-doot-dot, I am a bot.
> https://korg.docs.kernel.org/patchwork/pwbot.html
> 


It's probably stable material. Does netdev still have a separate
stable process? I'm not sure I remember.

-- 
MST


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

* Re: [PATCH net] vhost: vringh: Fix copy_to_iter return value check
  2025-10-01 11:22   ` Michael S. Tsirkin
@ 2025-10-01 14:00     ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2025-10-01 14:00 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: patchwork-bot+netdevbpf, linux-kernel, zhangjiao2, jasowang,
	eperezma, kvm, virtualization, netdev

On Wed, 1 Oct 2025 07:22:00 -0400 Michael S. Tsirkin wrote:
> It's probably stable material. Does netdev still have a separate
> stable process? I'm not sure I remember.

Not any more. FWIW Paolo posted our -next PR earlier today, so the fix
should reach Linus within the next couple of days.

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

end of thread, other threads:[~2025-10-01 14:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-25  6:04 [PATCH net] vhost: vringh: Fix copy_to_iter return value check Michael S. Tsirkin
2025-09-26  9:51 ` Simon Horman
2025-09-27  0:50 ` patchwork-bot+netdevbpf
2025-10-01 11:22   ` Michael S. Tsirkin
2025-10-01 14:00     ` Jakub Kicinski

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).