netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ursula Braun <ursula.braun@de.ibm.com>
To: davem@davemloft.net, netdev@vger.kernel.org, linux-s390@vger.kernel.org
Cc: schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
	Hendrik Brueckner <brueckner@linux.vnet.ibm.com>,
	Ursula Braun <ursula.braun@de.ibm.com>
Subject: [patch 13/13] [PATCH] af_iucv: Fix race when queuing incoming iucv messages
Date: Tue, 21 Apr 2009 12:35:10 +0200	[thread overview]
Message-ID: <20090421103706.782136000@linux.vnet.ibm.com> (raw)
In-Reply-To: 20090421103457.965299000@linux.vnet.ibm.com

[-- Attachment #1: 613-af_iucv-incoming-race.diff --]
[-- Type: text/plain, Size: 1694 bytes --]

From: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>

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>
---

 net/iucv/af_iucv.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Index: net-2.6-uschi/net/iucv/af_iucv.c
===================================================================
--- net-2.6-uschi.orig/net/iucv/af_iucv.c
+++ net-2.6-uschi/net/iucv/af_iucv.c
@@ -1409,6 +1409,8 @@ static void iucv_callback_rx(struct iucv
 		return;
 	}
 
+	spin_lock(&iucv->message_q.lock);
+
 	if (!list_empty(&iucv->message_q.list) ||
 	    !skb_queue_empty(&iucv->backlog_skb_q))
 		goto save_message;
@@ -1422,9 +1424,8 @@ static void iucv_callback_rx(struct iucv
 	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;
 
@@ -1435,8 +1436,9 @@ save_message:
 	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);
 }
 


  parent reply	other threads:[~2009-04-21 10:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-21 10:34 [patch 00/13] iucv / af_iucv patches for 2.6.30-rc1 Ursula Braun
2009-04-21 10:34 ` [patch 01/13] [PATCH] iucv: provide second per-cpu IUCV command parameter block Ursula Braun
2009-04-21 10:34 ` [patch 02/13] af_iucv: consider state IUCV_CLOSING when closing a socket Ursula Braun
2009-04-21 10:35 ` [patch 03/13] [PATCH] af_iucv: fix oops in iucv_sock_recvmsg() for MSG_PEEK flag Ursula Braun
2009-04-21 10:35 ` [patch 04/13] [PATCH] af_iucv: Reject incoming msgs if RECV_SHUTDOWN is set Ursula Braun
2009-04-21 10:35 ` [patch 05/13] [PATCH] af_iucv: sync sk shutdown flag if iucv path is quiesced Ursula Braun
2009-04-21 10:35 ` [patch 06/13] [PATCH] af_iucv: Test additional sk states in iucv_sock_shutdown Ursula Braun
2009-04-21 10:35 ` [patch 07/13] [PATCH] af_iucv: add sockopt() to enable/disable use of IPRM_DATA msgs Ursula Braun
2009-04-21 10:35 ` [patch 08/13] [PATCH] af_iucv: Support data in IUCV msg parameter lists (IPRMDATA) Ursula Braun
2009-04-21 10:35 ` [patch 09/13] [PATCH] af_iucv: Modify iucv msg target class using control msghdr Ursula Braun
2009-04-21 10:35 ` [patch 10/13] [PATCH] af_iucv: Provide new socket type SOCK_SEQPACKET Ursula Braun
2009-04-21 10:35 ` [patch 11/13] [PATCH] af_iucv: cleanup and refactor recvmsg() EFAULT handling Ursula Braun
2009-04-21 10:35 ` [patch 12/13] [PATCH] af_iucv: New socket option for setting IUCV MSGLIMITs Ursula Braun
2009-04-21 10:35 ` Ursula Braun [this message]
2009-04-21 10:39 ` [patch 00/13] iucv / af_iucv patches for 2.6.30-rc1 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090421103706.782136000@linux.vnet.ibm.com \
    --to=ursula.braun@de.ibm.com \
    --cc=brueckner@linux.vnet.ibm.com \
    --cc=davem@davemloft.net \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).