linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Bernard F6BVP <f6bvp@free.fr>, David Miller <davem@davemloft.net>
Cc: Ralf Baechle DL5RB <ralf@linux-mips.org>,
	linux-kernel@vger.kernel.org,
	Linux Netdev List <netdev@vger.kernel.org>,
	linux-hams@vger.kernel.org
Subject: [PATCH] 6pack,mkiss: fix lock inconsistency
Date: Fri, 1 Jul 2011 23:28:46 +0200	[thread overview]
Message-ID: <201107012328.46256.arnd@arndb.de> (raw)
In-Reply-To: <4E0DC4F3.6010203@free.fr>

Lockdep found a locking inconsistency in the mkiss_close function:

> kernel: [ INFO: inconsistent lock state ]
> kernel: 2.6.39.1 #3
> kernel: ---------------------------------
> kernel: inconsistent {IN-SOFTIRQ-R} -> {SOFTIRQ-ON-W} usage.
> kernel: ax25ipd/2813 [HC0[0]:SC0[0]:HE1:SE1] takes:
> kernel: (disc_data_lock){+++?.-}, at: [<ffffffffa018552b>] mkiss_close+0x1b/0x90 [mkiss]
> kernel: {IN-SOFTIRQ-R} state was registered at:

The message hints that disc_data_lock is aquired with softirqs disabled,
but does not itself disable softirqs, which can in rare circumstances
lead to a deadlock. 
The same problem is present in the 6pack driver, this patch fixes both
by using write_lock_bh instead of write_lock.

Reported-by: Bernard F6BVP <f6bvp@free.fr>
Tested-by: Bernard F6BVP <f6bvp@free.fr>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ralf Baechle<ralf@linux-mips.org>
Cc: stable@kernel.org
---
On Friday 01 July 2011 15:00:35 Bernard F6BVP wrote:
> 
> Now, who is going to commit this mkiss patch and the equivalent one for 
> sixpack.c ?

Here's a formal patch with all the right tags, I assume that David Miller
will apply that to the netdev tree.

diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 9624cbf..fea7cb4 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -694,10 +694,10 @@ static void sixpack_close(struct tty_struct *tty)
 {
 	struct sixpack *sp;
 
-	write_lock(&disc_data_lock);
+	write_lock_bh(&disc_data_lock);
 	sp = tty->disc_data;
 	tty->disc_data = NULL;
-	write_unlock(&disc_data_lock);
+	write_unlock_bh(&disc_data_lock);
 	if (!sp)
 		return;
 
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 9f84c83..324f7bf 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -813,10 +813,10 @@ static void mkiss_close(struct tty_struct *tty)
 {
 	struct mkiss *ax;
 
-	write_lock(&disc_data_lock);
+	write_lock_bh(&disc_data_lock);
 	ax = tty->disc_data;
 	tty->disc_data = NULL;
-	write_unlock(&disc_data_lock);
+	write_unlock_bh(&disc_data_lock);
 
 	if (!ax)
 		return;

  reply	other threads:[~2011-07-01 21:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-19 13:38 kernel BUG at kernel/timer.c:951! Bernard Pidoux
2009-12-19 17:40 ` Jarek Poplawski
2009-12-20 18:04   ` Bernard Pidoux
2010-01-15 14:46     ` Bernard Pidoux
2010-01-15 20:36       ` [PATCH net-2.6] ax25: netrom: rose: Fix timer oopses Jarek Poplawski
2010-01-16  9:04         ` David Miller
2010-02-11 16:34           ` [PATCH 07/13] net: ax25: use seq_hlist_foo() helpers Bernard Pidoux
2011-06-16 20:23         ` [AX25] inconsistent lock state f6bvp
2011-06-17 13:28           ` Ralf Baechle
2011-06-17 13:36           ` Arnd Bergmann
2011-06-17 13:51             ` Ralf Baechle
2011-06-17 14:11               ` Arnd Bergmann
2011-06-17 15:31                 ` f6bvp
2011-06-25 15:51                 ` f6bvp
2011-06-25 16:39                   ` Ralf Baechle DL5RB
2011-07-01 13:00                     ` Bernard F6BVP
2011-07-01 21:28                       ` Arnd Bergmann [this message]
2011-07-02  0:30                         ` [PATCH] 6pack,mkiss: fix lock inconsistency David Miller
2012-10-21 15:18                   ` [NetRom] possible circular locking dependency detected Bernard f6bvp
2011-06-17 15:26               ` [AX25] inconsistent lock state f6bvp
2011-06-16 20:29         ` khubd [ INFO: possible circular locking dependency detected ] f6bvp
2011-06-16 20:40         ` [AX25] inconsistent lock state f6bvp

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=201107012328.46256.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=f6bvp@free.fr \
    --cc=linux-hams@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ralf@linux-mips.org \
    /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).