net/unix: sk_socket can disappear when state is unlocked
got a rare NULL pointer dereference in clear_bit Signed-off-by: Mark Salyzyn <salyzyn@google.com> Bug: 21252747 Change-Id: I27e70f2543034097c8a590a212c2c6fa846fe695 Git-commit: 7449299aa1e791d60abc5556f2ecf7f1ba039be9 Git-repo: https://android.googlesource.com/kernel/common.git Signed-off-by: Kaushal Kumar <kaushalk@codeaurora.org>
This commit is contained in:
parent
659e4f9211
commit
09485d1b94
|
@ -332,6 +332,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);
|
||||
}
|
||||
|
||||
|
@ -376,6 +380,10 @@ static int caif_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
|
|||
struct sk_buff *skb;
|
||||
|
||||
lock_sock(sk);
|
||||
if (sock_flag(sk, SOCK_DEAD)) {
|
||||
err = -ECONNRESET;
|
||||
goto unlock;
|
||||
}
|
||||
skb = skb_dequeue(&sk->sk_receive_queue);
|
||||
caif_check_flow_release(sk);
|
||||
|
||||
|
|
|
@ -1899,6 +1899,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);
|
||||
}
|
||||
|
||||
|
@ -1958,6 +1962,10 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
|
|||
struct sk_buff *skb, *last;
|
||||
|
||||
unix_state_lock(sk);
|
||||
if (sock_flag(sg, SOCK_DEAD)) {
|
||||
err = -ECONNRESET;
|
||||
goto unlock;
|
||||
}
|
||||
last = skb = skb_peek(&sk->sk_receive_queue);
|
||||
again:
|
||||
if (skb == NULL) {
|
||||
|
|
Loading…
Reference in New Issue