mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Luczaj <mhal@rbox.co>
To: Stefano Garzarella <sgarzare@redhat.com>
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>,
	virtualization@lists.linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 3/3] vsock: Fix transport_* TOCTOU
Date: Fri, 20 Jun 2025 14:57:33 +0200	[thread overview]
Message-ID: <f96fb2fc-53ca-4e47-ab94-81c2f7b7c61a@rbox.co> (raw)
In-Reply-To: <qvdeycblu6lsk7me77wsgoi3b5fyspz4gnrvl3m5lrqobveqwv@fhuhssggsxtk>

On 6/20/25 10:37, Stefano Garzarella wrote:
>> -	if (!new_transport || !try_module_get(new_transport->module))
>> -		return -ENODEV;
>> +	if (!new_transport || !try_module_get(new_transport->module)) {
>> +		ret = -ENODEV;
>> +		goto unlock;
>> +	}
>> +
> 
> I'd add a comment here to explain that we can release it since we
> successfully increased the `new_transport` refcnt.

Sure, will do.

>> +	mutex_unlock(&vsock_register_mutex);
>>
>> 	if (sk->sk_type == SOCK_SEQPACKET) {
>> 		if (!new_transport->seqpacket_allow ||
>> @@ -528,6 +539,9 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk)
>> 	vsk->transport = new_transport;
>>
>> 	return 0;
>> +unlock:
> 
> I'd call it `err:` so it's clear is the error path.

Right, that makes sense.

Thanks!
Michal


      reply	other threads:[~2025-06-20 12:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 12:33 [PATCH net 0/3] vsock: Fix transport_{h2g,g2h,dgram,local} TOCTOU issues Michal Luczaj
2025-06-18 12:34 ` [PATCH net 1/3] vsock: Fix transport_{h2g,g2h} TOCTOU Michal Luczaj
2025-06-20  8:32   ` Stefano Garzarella
2025-06-20 12:58     ` Michal Luczaj
2025-06-20 13:20       ` Stefano Garzarella
2025-06-20 14:23         ` Michal Luczaj
2025-06-20 14:43           ` Stefano Garzarella
2025-06-20 19:57             ` Michal Luczaj
2025-06-18 12:34 ` [PATCH net 2/3] vsock: Fix transport_g2h TOCTOU Michal Luczaj
2025-06-18 12:34 ` [PATCH net 3/3] vsock: Fix transport_* TOCTOU Michal Luczaj
2025-06-20  8:37   ` Stefano Garzarella
2025-06-20 12:57     ` Michal Luczaj [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=f96fb2fc-53ca-4e47-ab94-81c2f7b7c61a@rbox.co \
    --to=mhal@rbox.co \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.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=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®