Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0884d7aa authored by Alexey Moiseytsev's avatar Alexey Moiseytsev Committed by David S. Miller
Browse files

AF_UNIX: Fix poll blocking problem when reading from a stream socket



poll() call may be blocked by concurrent reading from the same stream
socket.

Signed-off-by: default avatarAlexey Moiseytsev <himeraster@gmail.com>
Acked-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 83b98fb4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1957,6 +1957,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
			if ((UNIXCB(skb).pid  != siocb->scm->pid) ||
			    (UNIXCB(skb).cred != siocb->scm->cred)) {
				skb_queue_head(&sk->sk_receive_queue, skb);
				sk->sk_data_ready(sk, skb->len);
				break;
			}
		} else {
@@ -1974,6 +1975,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
		chunk = min_t(unsigned int, skb->len, size);
		if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) {
			skb_queue_head(&sk->sk_receive_queue, skb);
			sk->sk_data_ready(sk, skb->len);
			if (copied == 0)
				copied = -EFAULT;
			break;
@@ -1991,6 +1993,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
			/* put the skb back if we didn't use it up.. */
			if (skb->len) {
				skb_queue_head(&sk->sk_receive_queue, skb);
				sk->sk_data_ready(sk, skb->len);
				break;
			}

@@ -2006,6 +2009,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,

			/* put message back and return */
			skb_queue_head(&sk->sk_receive_queue, skb);
			sk->sk_data_ready(sk, skb->len);
			break;
		}
	} while (size);