From: "Nguyen Dinh Phi [SG]" <phind.uet@gmail.com>
To: Stefano Garzarella <sgarzare@redhat.com>, Michal Luczaj <mhal@rbox.co>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
syzbot+1b2c9c4a0f8708082678@syzkaller.appspotmail.com,
virtualization@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vsock: use sock_error() to consume sk_err after connect timeout
Date: Thu, 23 Jul 2026 18:26:44 +0800 [thread overview]
Message-ID: <27412e44-ab4b-4dd3-9685-481875683860@gmail.com> (raw)
In-Reply-To: <amHN9mOGj7oMak4-@sgarzare-redhat>
On 23/7/26 16:24, Stefano Garzarella wrote:
> On Thu, Jul 23, 2026 at 08:00:31AM +0200, Michal Luczaj wrote:
>> On 7/23/26 06:14, Nguyen Dinh Phi [SG] wrote:
>>> On 22/7/26 15:55, Stefano Garzarella wrote:
>>>> On Tue, Jul 21, 2026 at 01:34:03AM +0800, Phi Nguyen wrote:
>>>>> On 7/20/2026 4:17 PM, Stefano Garzarella wrote:
>>>>>> On Mon, Jul 20, 2026 at 05:57:47AM +0800, Nguyen Dinh Phi wrote:
>>>>>>> After vsock_connect() exits the wait loop due to sk->sk_err being
>>>>>>> set, the error was read but not cleared. This left sk->sk_err set
>>>>>>> for subsequent operations.
>>>>>>
>>>>>> So, is this a fix? If yes, we should put a Fixes tag.
>>>>>>
>>>>>> Also, can you describe how to trigger the issue?
>>>>>>
>>>>>> Because I see this in vsock_connect(), so I thought it was in some
>>>>>> way already handled:
>>>>>>
>>>>>> /* sk_err might have been set as a result of an earlier
>>>>>> * (failed) connect attempt.
>>>>>> */
>>>>>> sk->sk_err = 0;
>>>>>>
>>>>> This only handles the case where the function following the failed
>>>>> connect is another connect() call.
>>>>
>>>> So, can we remove that with this patch, or better to leave as defensive
>>>> action?
>>>>
>>>
>>> I prefer to keep it here as defensive action
>>
>> Is changing how vsock_poll() behaves intended?
>
I think connect() already delivered the error directly to the
caller when it returned -- there's no reason for poll() to keep
reporting that same, already-handled error afterward.
> Good point, but IIUC __inet_stream_connect() is also using consuming the
> error with sock_error().
>
>>
>> I.e. if sk_err should be kept after a failed connect(), what about
>> `sk->sk_err = 0;` in vsock_listen() instead?
>
> Yeah, maybe this is a bit less invasive.
>
yes, __inet_stream_connect() does it, and actually, other protocols like
Bluetooth, TIPC, x25... are also consume sk_err with sock_error() after
their wait loop.
I think it is an established pattern, so I'd rather keep sock_error() in
vsock_connect() than move it to vsock_listen(). vsock_listen() would
only protect the listen() path; I see other places in af_vsock.c use
this sk_err.
>>
>>>> ...
>>>> Yeah, we need to handle that part better, I think it's a leftover when
>>>> we generalized AF_VSOCK to support more transport than vmci.
>>
>> Speaking of leftovers, I have trouble understanding where does vsock set
>> sk_err on listener sockets anyway. If it doesn't, why vsock_accept()
>> checks
>> for it?
>
> I can't also see where it can be set TBH. Should we remove it ?
I couldn't find it for listener side too.
Thanks,
Phi.
next prev parent reply other threads:[~2026-07-23 10:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-19 21:57 [PATCH] vsock: use sock_error() to consume sk_err after connect timeout Nguyen Dinh Phi
2026-07-20 8:17 ` Stefano Garzarella
2026-07-20 17:34 ` Phi Nguyen
2026-07-22 7:55 ` Stefano Garzarella
2026-07-23 4:14 ` Nguyen Dinh Phi [SG]
2026-07-23 6:00 ` Michal Luczaj
2026-07-23 8:24 ` Stefano Garzarella
2026-07-23 10:26 ` Nguyen Dinh Phi [SG] [this message]
2026-07-23 21:43 ` Michal Luczaj
2026-07-24 7:34 ` Nguyen Dinh Phi [SG]
2026-07-28 8:21 ` Stefano Garzarella
2026-07-29 9:46 ` Nguyen Dinh Phi [SG]
2026-07-29 13:03 ` Stefano Garzarella
2026-07-29 13:20 ` Michal Luczaj
2026-07-29 13:29 ` Stefano Garzarella
2026-07-29 15:49 ` Michal Luczaj
2026-07-29 16:51 ` Phi Nguyen
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=27412e44-ab4b-4dd3-9685-481875683860@gmail.com \
--to=phind.uet@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhal@rbox.co \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=syzbot+1b2c9c4a0f8708082678@syzkaller.appspotmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.