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:   Sun, 28 Apr 2019 10:41:46 -0700
From:   Linus Torvalds <>
To:     Waiman Long <>
Cc:     Peter Zijlstra <>,
        Ingo Molnar <>,
        Will Deacon <>,
        Thomas Gleixner <>,
        Borislav Petkov <>,
        "H. Peter Anvin" <>,
        Linux List Kernel Mailing <>,
        "the arch/x86 maintainers" <>,
        Davidlohr Bueso <>,
        Tim Chen <>,
        huang ying <>,
        stable <>
Subject: Re: [PATCH-tip v6 01/20] locking/rwsem: Prevent decrement of reader
 count before increment

On Sun, Apr 28, 2019 at 8:58 AM Waiman Long <> wrote:
> +
> +       /* 2nd pass */
> +       list_for_each_entry(waiter, &wlist, list) {

This is not safe, as far as I can tell.

As this loop walks the list, you do that

                smp_store_release(&waiter->task, NULL);

and that very action means that the "waiter" is now released, and you
cannot possibly use it.


"list_for_each_entry()" will load "waiter->next" to go forward in the list.

So you absolutely *have* to use "list_for_each_entry_safe()" in this
loop, I think. You should treat that "smp_store_release()" as if you
deleted the list entry, because you cannot trust it after you've done
it, because the sleeper may have gone its own merry ways and released
the on-stack 'waiter' allocation.

It's the *first* loop that you could play games with, because you hold
the lock, and the list is stable during that loop. So the *first* loop
could just walk the list, and then do one list splitting operation
instead of doing that "list_move_tail()" thing for each entry.

But as long as you do "list_move_tail()" in the first loop, you'll
obviously have to use list_for_each_entry_safe() there too, since
right now you change that list as you walk it.

I'm just saying that you *could* optimize that first phase to just
walk it and then perhaps split it with list_cut_before() when you find
the first entry that isn't going to be woken up.


Powered by blists - more mailing lists