From: Bobby Eshleman <bobbyeshleman@meta.com>
To: <phind.uet@gmail.com>
Cc: Stefano Garzarella <sgarzare@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
George Zhang <georgezhang@vmware.com>,
Andy King <acking@vmware.com>, Dmitry Torokhov <dtor@vmware.com>,
<virtualization@lists.linux.dev>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] vsock: reject negative tv_usec in SO_VM_SOCKETS_CONNECT_TIMEOUT
Date: Fri, 30 Oct 2026 15:07:52 -0700 [thread overview]
Message-ID: <auUVOP8G8f1PNYaG@devvm29614.prn0.facebook.com> (raw)
In-Reply-To: <20261030064428.73930-1-phind.uet@gmail.com>
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")
>
> 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. Maybe we could think about adding some easy opt range tests into
vsock_test in the future.
Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
next prev parent reply other threads:[~2026-10-30 22:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 6:43 phind.uet
2026-10-30 6:49 ` netdev-bot+sinfo
2026-10-30 12:09 ` Stefano Garzarella
2026-10-30 22:07 ` Bobby Eshleman [this message]
2026-10-30 22:08 ` Bobby Eshleman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auUVOP8G8f1PNYaG@devvm29614.prn0.facebook.com \
--to=bobbyeshleman@meta.com \
--cc=acking@vmware.com \
--cc=davem@davemloft.net \
--cc=dtor@vmware.com \
--cc=edumazet@kernel.org \
--cc=georgezhang@vmware.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phind.uet@gmail.com \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®