diff options
author | Nikolay Kuratov <kniv@yandex-team.ru> | 2023-12-11 19:23:17 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-12-20 17:00:19 +0100 |
commit | 9a23be1e580617a11fa8f98c7324c755b41782e6 (patch) | |
tree | 99025337cee5c645176aaf1a914d9746326f56bb | |
parent | 2027dd67c3cf682fc3c9bb6fc5f43750857f24b8 (diff) | |
download | linux-stable-9a23be1e580617a11fa8f98c7324c755b41782e6.tar.gz linux-stable-9a23be1e580617a11fa8f98c7324c755b41782e6.tar.bz2 linux-stable-9a23be1e580617a11fa8f98c7324c755b41782e6.zip |
vsock/virtio: Fix unsigned integer wrap around in virtio_transport_has_space()
[ Upstream commit 60316d7f10b17a7ebb1ead0642fee8710e1560e0 ]
We need to do signed arithmetic if we expect condition
`if (bytes < 0)` to be possible
Found by Linux Verification Center (linuxtesting.org) with SVACE
Fixes: 06a8fc78367d ("VSOCK: Introduce virtio_vsock_common.ko")
Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20231211162317.4116625-1-kniv@yandex-team.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | net/vmw_vsock/virtio_transport_common.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 79e79fd6efd1..2e25890ca52d 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -583,7 +583,7 @@ static s64 virtio_transport_has_space(struct vsock_sock *vsk) struct virtio_vsock_sock *vvs = vsk->trans; s64 bytes; - bytes = vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt); + bytes = (s64)vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt); if (bytes < 0) bytes = 0; |