Thread (12 messages) 12 messages, 2 authors, 2025-06-20

Re: [PATCH net 3/3] vsock: Fix transport_* TOCTOU

From: Michal Luczaj <hidden>
Date: 2025-06-20 12:57:52
Also in: lkml, virtualization

On 6/20/25 10:37, Stefano Garzarella wrote:
quoted
-	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.
quoted
+	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help