Re: [PATCH net v2 2/3] selftests/net/af_unix: test listen() rejects wrong socket states
From: Christian Brauner <brauner@kernel.org>
Date: 2026-07-03 13:17:59
Also in:
lkml
From: Christian Brauner <brauner@kernel.org>
Date: 2026-07-03 13:17:59
Also in:
lkml
Add a regression test for the `unix_listen()` state check. The key case
is `listen()` on a bound socket that has already been connected: it is
no longer in `TCP_CLOSE` or `TCP_LISTEN`, so it must fail with `EINVAL`.
A `prepare_peercred()` call slipped in ahead of that check once left
`err` at 0 and made `listen()` silently succeed there instead; this
guards against a repeat.
The neighbouring outcomes are covered too so they cannot regress the
same way: a bound socket in `TCP_CLOSE` listens fine, re-`listen()`ing a
socket already in `TCP_LISTEN` is allowed, and an unbound socket fails
with `EINVAL`.
Fixes: fd0a109a0f6b ("net, pidfs: prepare for handing out pidfds for reaped sk->sk_peer_pid")
Signed-off-by: John Ericson <redacted>Reviewed-by: Christian Brauner (Amutable) <brauner@kernel.org> -- Christian Brauner [off-list ref]