linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Andrew Morton <akpm@osdl.org>
Cc: rostedt@goodmis.org, linux-kernel@vger.kernel.org, viro@ftp.linux.org.uk
Subject: [patch, lock validator] fix proc_inum_lock related deadlock
Date: Thu, 26 Jan 2006 01:02:00 +0100	[thread overview]
Message-ID: <20060126000200.GA12809@elte.hu> (raw)
In-Reply-To: <20060125102351.28cd52b8.akpm@osdl.org>

there's another VFS lock that just popped up, hopefully the last one.  
Fix below. (All this is still related to proc_subdir_lock, and the 
original BKL bug it fixed.)

	Ingo

-------------

&proc_inum_lock also nests within proc_subdir_lock, and &proc_inum_lock
is used in a softirq-unsafe manner. The lock validator noticed the
following scenario:

  =====================================
  [ BUG: lock inversion bug detected! ]
  -------------------------------------
  ifup-eth/2308 just changed the state of lock {proc_subdir_lock} at:
   [<c0197083>] remove_proc_entry+0x33/0x1f0
  but this lock took lock {proc_inum_lock} in the past, acquired at:
   [<c0196fee>] free_proc_entry+0x2e/0x90
  and interrupts could create an inverse lock dependency between them,
  which could lead to deadlocks!

  other info that might help in debugging this:
  locks held by ifup-eth/2308:
   [<c010432d>] show_trace+0xd/0x10
   [<c0104347>] dump_stack+0x17/0x20
   [<c0137a41>] check_no_lock_2_mask+0x131/0x180
   [<c013852b>] mark_lock+0xfb/0x2a0
   [<c0138b63>] debug_lock_chain+0x493/0xdc0
   [<c01394cd>] debug_lock_chain_spin+0x3d/0x60
   [<c026594d>] _raw_spin_lock+0x2d/0x90
   [<c04d91a2>] _spin_lock_bh+0x12/0x20
   [<c0197083>] remove_proc_entry+0x33/0x1f0
   [<c01429e9>] unregister_handler_proc+0x19/0x20
   [<c01421ab>] free_irq+0x7b/0xe0
   [<c02f25b2>] floppy_release_irq_and_dma+0x1b2/0x210
   [<c02f0aa7>] set_dor+0xc7/0x1b0
   [<c02f3b21>] motor_off_callback+0x21/0x30
   [<c01274d5>] run_timer_softirq+0xf5/0x1f0
   [<c0122e27>] __do_softirq+0x97/0x130
   [<c0105519>] do_softirq+0x69/0x100
   =======================

the fix is to take proc_inum_lock in a softirq-safe manner.

Signed-off-by: Ingo Molnar <mingo@elte.hu>

----

 fs/proc/generic.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Index: linux/fs/proc/generic.c
===================================================================
--- linux.orig/fs/proc/generic.c
+++ linux/fs/proc/generic.c
@@ -329,9 +329,9 @@ retry:
 	if (idr_pre_get(&proc_inum_idr, GFP_KERNEL) == 0)
 		return 0;
 
-	spin_lock(&proc_inum_lock);
+	spin_lock_bh(&proc_inum_lock);
 	error = idr_get_new(&proc_inum_idr, NULL, &i);
-	spin_unlock(&proc_inum_lock);
+	spin_unlock_bh(&proc_inum_lock);
 	if (error == -EAGAIN)
 		goto retry;
 	else if (error)
@@ -350,9 +350,9 @@ static void release_inode_number(unsigne
 {
 	int id = (inum - PROC_DYNAMIC_FIRST) | ~MAX_ID_MASK;
 
-	spin_lock(&proc_inum_lock);
+	spin_lock_bh(&proc_inum_lock);
 	idr_remove(&proc_inum_idr, id);
-	spin_unlock(&proc_inum_lock);
+	spin_unlock_bh(&proc_inum_lock);
 }
 
 static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd)

  parent reply	other threads:[~2006-01-26  0:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-25 17:03 [patch, validator] fix proc_subdir_lock related deadlock Ingo Molnar
2006-01-25 17:14 ` Steven Rostedt
2006-01-25 18:08   ` Ingo Molnar
2006-01-25 18:14     ` [patch, validator] fix files_lock " Ingo Molnar
2006-01-25 18:23     ` [patch, validator] fix proc_subdir_lock " Andrew Morton
2006-01-25 20:21       ` Ingo Molnar
2006-01-26  0:02       ` Ingo Molnar [this message]
2006-01-26  0:11         ` [patch, lock validator] fix proc_inum_lock " Ingo Molnar

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=20060126000200.GA12809@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=viro@ftp.linux.org.uk \
    /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).