Skip to content

Commit a12a2fa

Browse files
nixiaominggregkh
authored andcommitted
nfc: Avoid endless loops caused by repeated llcp_sock_connect()
commit 4b5db93 upstream. When sock_wait_state() returns -EINPROGRESS, "sk->sk_state" is LLCP_CONNECTING. In this case, llcp_sock_connect() is repeatedly invoked, nfc_llcp_sock_link() will add sk to local->connecting_sockets twice. sk->sk_node->next will point to itself, that will make an endless loop and hang-up the system. To fix it, check whether sk->sk_state is LLCP_CONNECTING in llcp_sock_connect() to avoid repeated invoking. Fixes: b401123 ("NFC: llcp: Fix non blocking sockets connections") Reported-by: "kiyin(尹亮)" <kiyin@tencent.com> Link: https://www.openwall.com/lists/oss-security/2020/11/01/1 Cc: <stable@vger.kernel.org> #v3.11 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 568ac94 commit a12a2fa

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎net/nfc/llcp_sock.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,10 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
673673
ret = -EISCONN;
674674
goto error;
675675
}
676+
if (sk->sk_state == LLCP_CONNECTING) {
677+
ret = -EINPROGRESS;
678+
goto error;
679+
}
676680

677681
dev = nfc_get_device(addr->dev_idx);
678682
if (dev == NULL) {

0 commit comments

Comments
 (0)