Re: [PATCH net v3 0/6] vsock: Transport reassignment and error handling issues

2025-01-28 Thread Luigi Leonardi
On Tue, Jan 28, 2025 at 02:15:26PM +0100, Michal Luczaj wrote: Series deals with two issues: - socket reference count imbalance due to an unforgiving transport release (triggered by transport reassignment); - unintentional API feature, a failing connect() making the socket impossible to use for

[PATCH net v3 1/6] vsock: Keep the binding until socket destruction

2025-01-28 Thread Michal Luczaj
Preserve sockets bindings; this includes both resulting from an explicit bind() and those implicitly bound through autobind during connect(). Prevents socket unbinding during a transport reassignment, which fixes a use-after-free: 1. vsock_create() (refcnt=1) calls vsock_insert_unbound() (ref

[PATCH net v3 0/6] vsock: Transport reassignment and error handling issues

2025-01-28 Thread Michal Luczaj
Series deals with two issues: - socket reference count imbalance due to an unforgiving transport release (triggered by transport reassignment); - unintentional API feature, a failing connect() making the socket impossible to use for any subsequent connect() attempts. Luigi, I took the opportun

[PATCH net v3 3/6] vsock/test: Introduce vsock_bind()

2025-01-28 Thread Michal Luczaj
Add a helper for socket()+bind(). Adapt callers. Reviewed-by: Stefano Garzarella Reviewed-by: Luigi Leonardi Signed-off-by: Michal Luczaj --- tools/testing/vsock/util.c | 57 +--- tools/testing/vsock/util.h | 1 + tools/testing/vsock/vsock_test.

[PATCH net v3 5/6] vsock/test: Add test for UAF due to socket unbinding

2025-01-28 Thread Michal Luczaj
Fail the autobind, then trigger a transport reassign. Socket might get unbound from unbound_sockets, which then leads to a reference count underflow. Reviewed-by: Stefano Garzarella Signed-off-by: Michal Luczaj --- tools/testing/vsock/vsock_test.c | 58

[PATCH net v3 6/6] vsock/test: Add test for connect() retries

2025-01-28 Thread Michal Luczaj
Deliberately fail a connect() attempt; expect error. Then verify that subsequent attempt (using the same socket) can still succeed, rather than fail outright. Reviewed-by: Stefano Garzarella Reviewed-by: Luigi Leonardi Signed-off-by: Michal Luczaj --- tools/testing/vsock/vsock_test.c | 47

[PATCH net v3 4/6] vsock/test: Introduce vsock_connect_fd()

2025-01-28 Thread Michal Luczaj
Distill timeout-guarded vsock_connect_fd(). Adapt callers. Suggested-by: Stefano Garzarella Reviewed-by: Stefano Garzarella Signed-off-by: Michal Luczaj --- tools/testing/vsock/util.c | 45 + tools/testing/vsock/util.h | 1 + 2 files changed, 18 ins

[PATCH net v3 2/6] vsock: Allow retrying on connect() failure

2025-01-28 Thread Michal Luczaj
sk_err is set when a (connectible) connect() fails. Effectively, this makes an otherwise still healthy SS_UNCONNECTED socket impossible to use for any subsequent connection attempts. Clear sk_err upon trying to establish a connection. Fixes: d021c344051a ("VSOCK: Introduce VM Sockets") Reviewed-b