[Patch] fix the lockdep warning in tty_fasync()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: =?utf-8?Q?Am=C3=A9rico?= Wang
Date: Tuesday, January 26, 2010 - 8:58 am

On Tue, Jan 26, 2010 at 04:33:38AM -0800, Eric W. Biederman wrote:

Right... Below is an updated version.

Thanks.

------------>

Commit 703625118 causes a lockdep warning:
 
[ INFO: possible irq lock inversion dependency detected ]
2.6.33-rc5 #77
---------------------------------------------------------
emacs/1609 just changed the state of lock:
 (&(&tty->ctrl_lock)->rlock){+.....}, at: [<ffffffff8127c648>]
tty_fasync+0xe8/0x190
but this lock took another, HARDIRQ-unsafe lock in the past:
 (&(&sighand->siglock)->rlock){-.....}

This is due to we use write_lock_irq() in __f_setown() which turns
the IRQ on in write_unlock_irq(), causes this warning.

Switch it to write_lock_irqsave() and write_unlock_irqrestore(),
as suggested by Eric.

Reported-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>

---
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 97e01dc..82cc8a7 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -199,7 +199,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
 static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
                      int force)
 {
-	write_lock_irq(&filp->f_owner.lock);
+	unsigned long flags;
+	write_lock_irqsave(&filp->f_owner.lock, flags);
 	if (force || !filp->f_owner.pid) {
 		put_pid(filp->f_owner.pid);
 		filp->f_owner.pid = get_pid(pid);
@@ -211,7 +212,7 @@ static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
 			filp->f_owner.euid = cred->euid;
 		}
 	}
-	write_unlock_irq(&filp->f_owner.lock);
+	write_unlock_irqrestore(&filp->f_owner.lock, flags);
 }
 
 int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[2.6.33-rc5] starting emacs makes lockdep warning, KOSAKI Motohiro, (Mon Jan 25, 8:20 pm)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, =?UTF-8?Q?Am=C3=A9ri ..., (Mon Jan 25, 10:25 pm)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, KOSAKI Motohiro, (Mon Jan 25, 10:37 pm)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, KOSAKI Motohiro, (Mon Jan 25, 10:49 pm)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, =?UTF-8?Q?Am=C3=A9ri ..., (Mon Jan 25, 11:01 pm)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, Eric W. Biederman, (Mon Jan 25, 11:17 pm)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, =?UTF-8?Q?Am=C3=A9ri ..., (Mon Jan 25, 11:24 pm)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, KOSAKI Motohiro, (Tue Jan 26, 12:45 am)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, =?UTF-8?Q?Am=C3=A9ri ..., (Tue Jan 26, 1:45 am)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, Eric W. Biederman, (Tue Jan 26, 2:14 am)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, =?UTF-8?Q?Am=C3=A9ri ..., (Tue Jan 26, 2:32 am)
Re: [2.6.33-rc5] starting emacs makes lockdep warning, Eric W. Biederman, (Tue Jan 26, 5:33 am)
[Patch] fix the lockdep warning in tty_fasync(), =?utf-8?Q?Am=C3=A9ri ..., (Tue Jan 26, 8:58 am)
Re: [Patch] fix the lockdep warning in tty_fasync(), KOSAKI Motohiro, (Tue Jan 26, 6:09 pm)
Re: check_usage_backwards() &amp;&amp; forwards? (Was: [2.6.33-rc5 ..., =?UTF-8?Q?Am=C3=A9ri ..., (Tue Jan 26, 7:58 pm)
[tip:core/urgent] lockdep: Fix check_usage_backwards() err ..., tip-bot for Oleg Nes ..., (Wed Jan 27, 6:15 am)