Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit f2b0b52

Browse files
V4bel-theoridavem330
authored andcommitted
net/x25: Fix to not accept on connected socket
When listen() and accept() are called on an x25 socket that connect() succeeds, accept() succeeds immediately. This is because x25_connect() queues the skb to sk->sk_receive_queue, and x25_accept() dequeues it. This creates a child socket with the sk of the parent x25 socket, which can cause confusion. Fix x25_listen() to return -EINVAL if the socket has already been successfully connect()ed to avoid this issue. Signed-off-by: Hyunwoo Kim <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2a48216 commit f2b0b52

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/x25/af_x25.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ static int x25_listen(struct socket *sock, int backlog)
482482
int rc = -EOPNOTSUPP;
483483

484484
lock_sock(sk);
485+
if (sock->state != SS_UNCONNECTED) {
486+
rc = -EINVAL;
487+
release_sock(sk);
488+
return rc;
489+
}
490+
485491
if (sk->sk_state != TCP_LISTEN) {
486492
memset(&x25_sk(sk)->dest_addr, 0, X25_ADDR_LEN);
487493
sk->sk_max_ack_backlog = backlog;

0 commit comments

Comments
 (0)