diff options
| author | Michael S. Tsirkin <mst@redhat.com> | 2025-09-25 02:04:08 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-10-15 11:56:37 +0200 |
| commit | bd71e7e0a612740e4de5524880c7cd40293af5f7 (patch) | |
| tree | 75ce886e1e9d55c0294fcd3b3c445f7bf986cc56 /drivers/vhost | |
| parent | 114e05344763a102a8844efd96ec06ba99293ccd (diff) | |
| download | linux-bd71e7e0a612740e4de5524880c7cd40293af5f7.tar.gz linux-bd71e7e0a612740e4de5524880c7cd40293af5f7.tar.bz2 linux-bd71e7e0a612740e4de5524880c7cd40293af5f7.zip | |
vhost: vringh: Fix copy_to_iter return value check
[ Upstream commit 439263376c2c4e126cac0d07e4987568de4eaba5 ]
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>
Reviewed-by: Simon Horman <horms@kernel.org>
Fixes: 309bba39c945 ("vringh: iterate on iotlb_translate to handle large translations")
Link: https://patch.msgid.link/cd637504a6e3967954a9e80fc1b75e8c0978087b.1758723310.git.mst@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/vhost')
| -rw-r--r-- | drivers/vhost/vringh.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c index 10bfc5f1c50d..c570d214d5b6 100644 --- a/drivers/vhost/vringh.c +++ b/drivers/vhost/vringh.c @@ -1195,6 +1195,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, @@ -1206,9 +1207,9 @@ static inline int copy_to_iotlb(const struct vringh *vrh, void *dst, iov_iter_bvec(&iter, ITER_DEST, iov, ret, 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; |
