mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 22:26:55 +00:00
vsock/virtio: Fix unsigned integer wrap around in virtio_transport_has_space()
[ Upstream commit60316d7f10
] 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:06a8fc7836
("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>
This commit is contained in:
parent
2027dd67c3
commit
9a23be1e58
1 changed files with 1 additions and 1 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue