* [PATCH] vsock: reject negative tv_usec in SO_VM_SOCKETS_CONNECT_TIMEOUT
@ 2026-10-30 6:43 phind.uet
2026-10-30 6:49 ` netdev-bot+sinfo
2026-10-30 12:09 ` Stefano Garzarella
0 siblings, 2 replies; 3+ messages in thread
From: phind.uet @ 2026-10-30 6:43 UTC (permalink / raw)
To: Stefano Garzarella, Bobby Eshleman, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, George Zhang,
Andy King, Dmitry Torokhov
Cc: Nguyen Dinh Phi, virtualization, netdev, linux-kernel
From: Nguyen Dinh Phi <phind.uet@gmail.com>
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: d021c344051a ("VSOCK: Introduce VM Sockets")
Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
---
net/vmw_vsock/af_vsock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index d0508887a2fb..1d7d53542724 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -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));
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] vsock: reject negative tv_usec in SO_VM_SOCKETS_CONNECT_TIMEOUT
2026-10-30 6:43 [PATCH] vsock: reject negative tv_usec in SO_VM_SOCKETS_CONNECT_TIMEOUT phind.uet
@ 2026-10-30 6:49 ` netdev-bot+sinfo
2026-10-30 12:09 ` Stefano Garzarella
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-10-30 6:49 UTC (permalink / raw)
To: phind.uet
Cc: Stefano Garzarella, Bobby Eshleman, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, George Zhang,
Andy King, Dmitry Torokhov, virtualization, netdev, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vsock: reject negative tv_usec in SO_VM_SOCKETS_CONNECT_TIMEOUT
2026-10-30 6:43 [PATCH] vsock: reject negative tv_usec in SO_VM_SOCKETS_CONNECT_TIMEOUT phind.uet
2026-10-30 6:49 ` netdev-bot+sinfo
@ 2026-10-30 12:09 ` Stefano Garzarella
1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2026-10-30 12:09 UTC (permalink / raw)
To: phind.uet
Cc: Bobby Eshleman, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, George Zhang, Andy King,
Dmitry Torokhov, virtualization, netdev, linux-kernel
On Fri, Oct 30, 2026 at 02:43:50PM +0800, phind.uet@gmail.com wrote:
>From: Nguyen Dinh Phi <phind.uet@gmail.com>
>
>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: d021c344051a ("VSOCK: Introduce VM Sockets")
>
This blank line shouldn't be there, maybe it can be fixed when the net
maintainers apply this patch, so please wait their comments before
sending a v2.
>Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
>---
> net/vmw_vsock/af_vsock.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>index d0508887a2fb..1d7d53542724 100644
>--- a/net/vmw_vsock/af_vsock.c
>+++ b/net/vmw_vsock/af_vsock.c
>@@ -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));
>--
>2.43.0
>
LGTM:
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-30 12:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 6:43 [PATCH] vsock: reject negative tv_usec in SO_VM_SOCKETS_CONNECT_TIMEOUT phind.uet
2026-10-30 6:49 ` netdev-bot+sinfo
2026-10-30 12:09 ` Stefano Garzarella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox