Skip to content

Commit

Permalink
af_iucv: Fix race when queuing incoming iucv messages
Browse files Browse the repository at this point in the history
AF_IUCV runs into a race when queuing incoming iucv messages
and receiving the resulting backlog.

If the Linux system is under pressure (high load or steal time),
the message queue grows up, but messages are not received and queued
onto the backlog queue. In that case, applications do not
receive any data with recvmsg() even if AF_IUCV puts incoming
messages onto the message queue.

The race can be avoided if the message queue spinlock in the
message_pending callback is spreaded across the entire callback
function.

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 e14ad5f commit 3fa6b5a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions net/iucv/af_iucv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,8 @@ static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg)
return;
}

spin_lock(&iucv->message_q.lock);

if (!list_empty(&iucv->message_q.list) ||
!skb_queue_empty(&iucv->backlog_skb_q))
goto save_message;
Expand All @@ -1137,9 +1139,8 @@ static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg)
if (!skb)
goto save_message;

spin_lock(&iucv->message_q.lock);
iucv_process_message(sk, skb, path, msg);
spin_unlock(&iucv->message_q.lock);
goto out_unlock;

return;

Expand All @@ -1150,8 +1151,9 @@ static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg)
save_msg->path = path;
save_msg->msg = *msg;

spin_lock(&iucv->message_q.lock);
list_add_tail(&save_msg->list, &iucv->message_q.list);

out_unlock:
spin_unlock(&iucv->message_q.lock);
}

Expand Down

0 comments on commit 3fa6b5a

Please sign in to comment.