mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
vsock: reject negative tv_usec in SO_VM_SOCKETS_CONNECT_TIMEOUT
The timeval validation checks tv_usec < USEC_PER_SEC but not
tv_usec >= 0, so a negative tv_usec makes the timeout computation
wrap into a bogus value, later tripping "schedule_timeout: wrong
timeout value" instead of being rejected.
Fixes: d021c34405 ("VSOCK: Introduce VM Sockets")
Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20261030064428.73930-1-phind.uet@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
b3427f41f8
commit
c0ef6144b4
|
|
@ -2156,7 +2156,8 @@ static int vsock_connectible_setsockopt(struct socket *sock,
|
|||
optname == SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD);
|
||||
if (err)
|
||||
break;
|
||||
if (tv.tv_sec >= 0 && tv.tv_usec < USEC_PER_SEC &&
|
||||
if (tv.tv_sec >= 0 && tv.tv_usec >= 0 &&
|
||||
tv.tv_usec < USEC_PER_SEC &&
|
||||
tv.tv_sec < (MAX_SCHEDULE_TIMEOUT / HZ - 1)) {
|
||||
vsk->connect_timeout = tv.tv_sec * HZ +
|
||||
DIV_ROUND_UP((unsigned long)tv.tv_usec, (USEC_PER_SEC / HZ));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user