Skip to contentSkip to conversation

qrtr: orphan socket in qrtr_release()

PATCH In review Cong Wang 3 participants 3 messages Jul 24, 2020 – Jul 25, 2020

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH v2 1/1 qrtr: orphan socket in qrtr_release()

We have to detach sock from socket in qrtr_release(), otherwise skb->sk may still reference to this socket when the skb is released in tun->queue, particularly sk->sk_wq still points to &sock->wq, which leads to a UAF.

Reported-and-tested-by [email protected]
Fixes 28fb4e59a47d ("net: qrtr: Expose tunneling endpoint to user space")
Cc Bjorn Andersson <[email protected]>
Cc Eric Dumazet <[email protected]>
---
 net/qrtr/qrtr.c | 1 +
 1 file changed, 1 insertion(+)
net/qrtr/qrtr.c +1 -0
index 24a8c3c6da0d..300a104b9a0f 100644
@@ -1180,6 +1180,7 @@ static int qrtr_release(struct socket *sock)
 		sk->sk_state_change(sk);
 
 	sock_set_flag(sk, SOCK_DEAD);
+	sock_orphan(sk);
 	sock->sk = NULL;
 
 	if (!sock_flag(sk, SOCK_ZAPPED))
Signature · 1 line
2.27.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 21 lines · Cong Wang

We have to detach sock from socket in qrtr_release(), otherwise skb->sk may still reference to this socket when the skb is released in tun->queue, particularly sk->sk_wq still points to &sock->wq, which leads to a UAF.

Reported-and-tested-by [email protected]
Fixes 28fb4e59a47d ("net: qrtr: Expose tunneling endpoint to user space")
Cc Bjorn Andersson <[email protected]>
Cc Eric Dumazet <[email protected]>
---
 net/qrtr/qrtr.c | 1 +
 1 file changed, 1 insertion(+)
net/qrtr/qrtr.c +0 -0
index 24a8c3c6da0d..300a104b9a0f 100644

net/qrtr/qrtr.c static int qrtr_release(struct socket *sock) · line 1186

Quoted 7 lines
net/qrtr/qrtr.c +1 -0
@@ -1180,6 +1180,7 @@ static int qrtr_release(struct socket *sock)
 		sk->sk_state_change(sk);
 
 	sock_set_flag(sk, SOCK_DEAD);
+	sock_orphan(sk);
 	sock->sk = NULL;
 
 	if (!sock_flag(sk, SOCK_ZAPPED))
maintainer
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Fri, 24 Jul 2020 09:45:51 -0700

Quoted 11 lines

We have to detach sock from socket in qrtr_release(), otherwise skb->sk may still reference to this socket when the skb is released in tun->queue, particularly sk->sk_wq still points to &sock->wq, which leads to a UAF.

Reported-and-tested-by [email protected]
Fixes 28fb4e59a47d ("net: qrtr: Expose tunneling endpoint to user space")
Cc Bjorn Andersson <[email protected]>
Cc Eric Dumazet <[email protected]>

Applied and queued up for -stable, thanks.