lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2375c9f91001260132l21e43fc4v2eed9ac39f433b8d@mail.gmail.com>
Date:	Tue, 26 Jan 2010 17:32:59 +0800
From:	Américo Wang <xiyou.wangcong@...il.com>
To:	"Eric W. Biederman" <ebiederm@...ssion.com>
Cc:	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Tavis Ormandy <taviso@...gle.com>,
	Jeff Dike <jdike@...toit.com>, Julien Tinnes <jln@...gle.com>,
	Matt Mackall <mpm@...enic.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Oleg Nesterov <oleg@...hat.com>,
	Alan Cox <alan@...rguk.ukuu.org.uk>
Subject: Re: [2.6.33-rc5] starting emacs makes lockdep warning

On Tue, Jan 26, 2010 at 5:14 PM, Eric W. Biederman
<ebiederm@...ssion.com> wrote:
> Américo Wang <xiyou.wangcong@...il.com> writes:
>
>> On Tue, Jan 26, 2010 at 3:45 PM, KOSAKI Motohiro
>> <kosaki.motohiro@...fujitsu.com> wrote:
>>> Hi
>>>
>>>> On Tue, Jan 26, 2010 at 02:01:12PM +0800, Am??rico Wang wrote:
>>>>
>>>> > I agree, it seems that patch is useless, since we already
>>>> > do lock_kernel() before calling __f_setown()...
>>>>
>>>> What's to prevent pid from being freed under us?  BKL won't...
>>>
>>> I don't understand this issue at all. so, this is stupid dumb question.
>>> Why can't we write following code?
>>>
>>>
>>>                enum pid_type type;
>>>                struct pid *pid;
>>>                if (!waitqueue_active(&tty->read_wait))
>>>                        tty->minimum_to_wake = 1;
>>>                spin_lock_irqsave(&tty->ctrl_lock, flags);
>>>                if (tty->pgrp) {
>>>                        pid = tty->pgrp;
>>>                        type = PIDTYPE_PGID;
>>>                } else {
>>>                        pid = task_pid(current);
>>>                        type = PIDTYPE_PID;
>>>                }
>>>                get_pid(pid)                                    // insert here
>>>                spin_unlock_irqrestore(&tty->ctrl_lock, flags);
>>>                retval = __f_setown(filp, pid, type, 0);
>>>                put_pid(pid)                                    // insert here
>>>
>>
>> Yeah, this seems reasonable for me, but not sure if this is the best fix.
>
> That or tweak __f_setown to use irqsave/irqrestore variants for it's
> locks, __f_setown is already atomic.  I prefer that direction because the
> code is just a little simpler.
>

Oh, very good advice!

Patch is below.

-------------->
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 ot write_lock_irqsave() and write_unlock_irqrestore(),
as suggested by Eric.

Reported-by: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
Signed-off-by: WANG Cong <xiyou.wangcong@...il.com>

----

View attachment "fs-fcntl-__f_setown_use-irqsave-lock.diff" of type "text/plain" (822 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ