Skip to contentSkip to conversation

net/unix: sk_socket can disappear when state is unlocked

PATCH Superseded Mark Salyzyn 1 participant 1 message May 22, 2015

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/unix: sk_socket can disappear when state is unlocked

got a rare NULL pointer dereference in clear_bit

----
v2: switch to sock_flag(sk, SOCK_DEAD) and added net/caif/caif_socket.c

 net/caif/caif_socket.c | 4 ++++
 net/unix/af_unix.c     | 4 ++++
 2 files changed, 8 insertions(+)
net/caif/caif_socket.c +4 -0
index 4ec0c80..8f44c38 100644
@@ -330,6 +330,10 @@ static long caif_stream_data_wait(struct sock *sk, long timeo)
 		release_sock(sk);
 		timeo = schedule_timeout(timeo);
 		lock_sock(sk);
+
+		if (sock_flag(sk, SOCK_DEAD))
+			break;
+
 		clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
 	}
 
net/unix/af_unix.c +4 -0
index 5266ea7..7b68dc8 100644
@@ -1880,6 +1880,10 @@ static long unix_stream_data_wait(struct sock *sk, long timeo,
 		unix_state_unlock(sk);
 		timeo = freezable_schedule_timeout(timeo);
 		unix_state_lock(sk);
+
+		if (sock_flag(sk, SOCK_DEAD))
+			break;
+
 		clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
 	}
 
Signature · 1 line
2.2.0.rc0.207.ga3a616c