[patch, lock validator] fix proc_inum_lock related deadlock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>

----

 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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux