History

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.

John Ericson committed 4 months ago

Commit f0d9c3f1 parent 4787a6d1 file · +1 −0Browse files

Unified · Split

net/unix/af_unix.c+1−0
@@ -823,6 +823,7 @@ static int unix_listen(struct socket *sock, int backlog) · 822 unmodified lines
823823 if (err)
824824 goto out;
825825 unix_state_lock(sk);
826+ err = -EINVAL;
826827 if (sk->sk_state != TCP_CLOSE && sk->sk_state != TCP_LISTEN)
827828 goto out_unlock;
828829 if (backlog > sk->sk_max_ack_backlog)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t