Skip to contentSkip to conversation

nfc: llcp: fix use-after-free in llcp_sock_release()

PATCH New Lee Jones 1 participant 1 message Apr 28

Subsystems (3)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

PATCH 1/1 nfc: llcp: fix use-after-free in llcp_sock_release()

llcp_sock_release() unconditionally unlinks the socket from the local sockets list. However, if the socket is still in connecting state, it is on the connecting list.

Fix this by checking the socket state and unlinking from the correct list.

---
 net/nfc/llcp_sock.c | 2 ++
 1 file changed, 2 insertions(+)
net/nfc/llcp_sock.c +2 -0
index f1be1e84f6653..feab29fc62f44 100644
@@ -633,6 +633,8 @@ static int llcp_sock_release(struct socket *sock)
 
 	if (sock->type == SOCK_RAW)
 		nfc_llcp_sock_unlink(&local->raw_sockets, sk);
+	else if (sk->sk_state == LLCP_CONNECTING)
+		nfc_llcp_sock_unlink(&local->connecting_sockets, sk);
 	else
 		nfc_llcp_sock_unlink(&local->sockets, sk);
 
Signature · 1 line
2.54.0.545.g6539524ca2-goog