Skip to content

Commit

Permalink
af_iucv: fix oops in iucv_sock_recvmsg() for MSG_PEEK flag
Browse files Browse the repository at this point in the history
If iucv_sock_recvmsg() is called with MSG_PEEK flag set, the skb is enqueued
twice. If the socket is then closed, the pointer to the skb is freed twice.

Remove the skb_queue_head() call for MSG_PEEK, because the skb_recv_datagram()
function already handles MSG_PEEK (does not dequeue the skb).

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hendrik Brueckner authored and David S. Miller committed Apr 22, 2009
1 parent bbe188c commit 60d3705
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/iucv/af_iucv.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,8 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,

target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);

/* receive/dequeue next skb:
* the function understands MSG_PEEK and, thus, does not dequeue skb */
skb = skb_recv_datagram(sk, flags, noblock, &err);
if (!skb) {
if (sk->sk_shutdown & RCV_SHUTDOWN)
Expand Down Expand Up @@ -861,9 +863,7 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
iucv_process_message_q(sk);
spin_unlock_bh(&iucv->message_q.lock);
}

} else
skb_queue_head(&sk->sk_receive_queue, skb);
}

done:
return err ? : copied;
Expand Down

0 comments on commit 60d3705

Please sign in to comment.