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]
Date:   Tue, 10 Oct 2017 09:56:26 -0700
From:   Linus Torvalds <torvalds@...ux-foundation.org>
To:     Byungchul Park <byungchul.park@....com>
Cc:     Fengguang Wu <fengguang.wu@...el.com>,
        Ingo Molnar <mingo@...nel.org>,
        "Peter Zijlstra (Intel)" <peterz@...radead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        LKP <lkp@...org>, Josh Poimboeuf <jpoimboe@...hat.com>,
        kernel-team@....com
Subject: Re: [lockdep] b09be676e0 BUG: unable to handle kernel NULL pointer
 dereference at 000001f2

On Tue, Oct 10, 2017 at 9:22 AM, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> I really would like to see the sites that do cross-thread lock/unlock
> pairs themselves be annotated.
>
> So when you lock in one thread, and then unlock in another, I'd
> actually prefer to see something like
>
>  - T1:
>         lock_mutex_cross();
>
>  - T2:
>         unlock_mutex_cross();
>
> to make it very explicit that *these* particular lock/unlock
> operations are the fancy ones.

Actually, let's make it even *more* obvious, and even easier for
lockdep (and for humans) to see what's going on.

So I think the best model would be something like this:

 - T1:
        mutex_lock(&lock)
        ...
        mutex_transfer(&lock)

 - T2:
        mutex_receive(&lock);
        ...
        mutex_unlock(&lock);

where the "mutex_transfer() -> mutex_receive()" thing really makes it
obvious that "now thread 1 is transferring the lock to thread 2".

And for lockdep, those transfer points will be easy to check: verify
that the "mutex_transfer()" is done with the lock held, and maybe
clear the lock ownership at that point (or set it to "in flight" or
whatever). And then "mutex_receive()" can verify that (a) the
ownership was that "in tranfer" thing and that it's still held, before
it then sets the ownership to thread 2.

Wouldn't that be easier for lockdep? And I think it would be much more
obvious to users too, and really document those places where we do
something odd and transfer ownership of a lock from one thread to
another?

                Linus

Powered by blists - more mailing lists