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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACVXFVNBiXxVvRWxnXiKPRm5dkj6qziFtXA_OH5kYFg4GZ+-pQ@mail.gmail.com>
Date:	Sat, 26 May 2012 17:23:53 +0800
From:	Ming Lei <ming.lei@...onical.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org, Alan Cox <alan@...ux.intel.com>,
	Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH] tty: tty_mutex: fix lockdep warning in tty_lock_pair(v3)

On Sat, May 26, 2012 at 3:16 PM, Peter Zijlstra <peterz@...radead.org> wrote:

>
>
> I've still to hear what's wrong with a simple:
>
>
>  if (!tty2 || tty == tty2) {
>        tty_lock(tty);
>        return;
>  }
>
>  if (tty > tty2)
>        swap(tty, tty2);
>
>  tty_lock(tty);
>  tty_lock_nested(tty2, SINGLE_DEPTH_NESTING);

I remember that the patch may cause kernel hang in
my test. I will test it again to see if it is good.

>
>
> That's a lot more readable than the proposed code.
>
>> @@ -55,8 +64,13 @@ EXPORT_SYMBOL(tty_lock_pair);
>>  void __lockfunc tty_unlock_pair(struct tty_struct *tty,
>>                                               struct tty_struct *tty2)
>>  {
>> -     tty_unlock(tty);
>> -     if (tty2 && tty2 != tty)
>> +     if (tty < tty2) {
>>               tty_unlock(tty2);
>> +             tty_unlock(tty);
>> +     } else {
>> +             tty_unlock(tty);
>> +             if (tty2 && tty2 != tty)
>> +                     tty_unlock(tty2);
>> +     }
>>  }
>>  EXPORT_SYMBOL(tty_unlock_pair);
>
> This is complete crap, unlock order doesn't matter.

You mean that the below is good usage of lock?

        LOCK A
        LOCK B

        UNLOCK A
        UNLOCK B


Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ