mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefano Garzarella <sgarzare@redhat.com>
To: phind.uet@gmail.com
Cc: Bobby Eshleman <bobbyeshleman@meta.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 13:09:42 +0100	[thread overview]
Message-ID: <auSIGIZctLp1oOhf@sgarzare-redhat> (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")
>

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>



      parent reply	other threads:[~2026-10-30 12:10 UTC|newest]

Thread overview: 3+ 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 [this message]

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=auSIGIZctLp1oOhf@sgarzare-redhat \
    --to=sgarzare@redhat.com \
    --cc=acking@vmware.com \
    --cc=bobbyeshleman@meta.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=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®