Skip to contentSkip to conversation

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

PATCH In review Lee Jones 2 participants 4 messages Apr 29

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
#1 lore raw
Quoted 26 lines · Lee Jones

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 -1
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);
 
--
Quoted 2 lines

2.54.0.545.g6539524ca2-goog

Why are you sending this patch a second time?

You forgot to add a Fixes: tag, as requested for all networking patches.

author
#2 lore raw
Quoted 26 lines · Eric Dumazet
Quoted 25 lines · Lee Jones

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);
 
Quoted 5 lines
Quoted 3 lines

--
2.54.0.545.g6539524ca2-goog

Why are you sending this patch a second time?

Because I am a dunce and forgot to clear out my send cache before sending a related but different patch.

Quoted 1 line

You forgot to add a Fixes: tag, as requested for all networking patches.

No problem. Please ignore both of these and I'll follow-up with a coherent set with Fixes: tags applied.

Signature · 1 line
Lee Jones
#3 lore raw
Quoted 4 lines · Lee Jones

No problem. Please ignore both of these and I'll follow-up with a coherent set with Fixes: tags applied.

Thanks a lot!