]> git.ipfire.org Git - thirdparty/linux.git/commit
af_unix: fix listen() succeeding on sockets in the wrong state
authorJohn Ericson <mail@johnericson.me>
Sat, 18 Jul 2026 18:29:01 +0000 (14:29 -0400)
committerJakub Kicinski <kuba@kernel.org>
Fri, 24 Jul 2026 22:10:05 +0000 (15:10 -0700)
commitf0d9c3ffc2b5fc2ffacb56b3036155ce7a940a12
treee2a33295cb5acbdc139c9fc869d67c099dc1f1db
parent4787a6d2629b4e8c0b6bacab1f75c1660eca44d9
af_unix: fix listen() succeeding on sockets in the wrong state

Commit fd0a109a0f6b ("net, pidfs: prepare for handing out pidfds for
reaped sk->sk_peer_pid") inserted a prepare_peercred() call between err
= -EINVAL and the socket-state check in unix_listen(). Since
prepare_peercred() leaves err at 0 on success, listen() on an AF_UNIX
socket that is not in TCP_CLOSE or TCP_LISTEN state (e.g. one that is
already connected) now silently returns success without doing anything,
instead of failing with EINVAL as it did before.

Fixes: fd0a109a0f6b ("net, pidfs: prepare for handing out pidfds for reaped sk->sk_peer_pid")
Signed-off-by: John Ericson <mail@johnericson.me>
Link: https://patch.msgid.link/20260718182903.2295560-1-John.Ericson@Obsidian.Systems
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/unix/af_unix.c