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: <20170725062945.GM20323@X58A-UD3R>
Date:   Tue, 25 Jul 2017 15:29:45 +0900
From:   Byungchul Park <byungchul.park@....com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Byungchul Park <max.byungchul.park@...il.com>,
        Ingo Molnar <mingo@...nel.org>, tglx@...utronix.de,
        Michel Lespinasse <walken@...gle.com>, boqun.feng@...il.com,
        kirill@...temov.name,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        linux-mm@...ck.org, akpm@...ux-foundation.org, willy@...radead.org,
        npiggin@...il.com, kernel-team@....com
Subject: Re: [PATCH v7 06/16] lockdep: Detect and handle hist_lock ring
 buffer overwrite

On Fri, Jul 21, 2017 at 03:54:20PM +0200, Peter Zijlstra wrote:
> On Fri, Jul 14, 2017 at 03:42:10PM +0900, Byungchul Park wrote:
> > On Thu, Jul 13, 2017 at 08:23:33PM +0900, Byungchul Park wrote:
> > > On Thu, Jul 13, 2017 at 8:12 PM, Peter Zijlstra <peterz@...radead.org> wrote:
> > > > On Thu, Jul 13, 2017 at 12:29:05PM +0200, Peter Zijlstra wrote:
> > > >> On Thu, Jul 13, 2017 at 07:09:53PM +0900, Byungchul Park wrote:
> > > >> > On Thu, Jul 13, 2017 at 11:50:52AM +0200, Peter Zijlstra wrote:
> > > >> > >   wait_for_completion(&C);
> > > >> > >     atomic_inc_return();
> > > >> > >
> > > >> > >                                   mutex_lock(A1);
> > > >> > >                                   mutex_unlock(A1);
> > > >> > >
> > > >> > >
> > > >> > >                                   <IRQ>
> > > >> > >                                     spin_lock(B1);
> > > >> > >                                     spin_unlock(B1);
> > > >> > >
> > > >> > >                                     ...
> > > >> > >
> > > >> > >                                     spin_lock(B64);
> > > >> > >                                     spin_unlock(B64);
> > > >> > >                                   </IRQ>
> > > >> > >
> > > >> > >
> > > >
> > > > Also consider the alternative:
> > > >
> > > >                                         <IRQ>
> > > >                                           spin_lock(D);
> > > >                                           spin_unlock(D);
> > > >
> > > >                                           complete(&C);
> > > >                                         </IRQ>
> > > >
> > > > in which case the context test will also not work.
> > > 
> > > Context tests are done on xhlock with the release context, _not_
> > > acquisition context. For example, spin_lock(D) and complete(&C) are
> > > in the same context, so the test would pass in this example.
> 
> The point was, this example will also link C to B*.

_No_, as I already said.

> (/me copy paste from older email)
> 
> That gives:
> 
>         xhist[ 0] = A1
>         xhist[ 1] = B1
>         ...
>         xhist[63] = B63
> 
> then we wrap and have:
> 
>         xhist[0] = B64
> 
> then we rewind to 1 and invalidate to arrive at:

We invalidate xhist[_0_], as I already said.

>         xhist[ 0] = B64
>         xhist[ 1] = NULL   <-- idx
>         xhist[ 2] = B2
>         ...
>         xhist[63] = B63
> 
> 
> Then we do D and get
> 
>         xhist[ 0] = B64
>         xhist[ 1] = D   <-- idx
>         xhist[ 2] = B2
>         ...
>         xhist[63] = B63

We should get

         xhist[ 0] = NULL
         xhist[ 1] = D   <-- idx
         xhist[ 2] = B2
         ...
         xhist[63] = B63

By the way, did not you get my reply? I did exactly same answer.
Perhaps You have not received or read my replies.

> And now there is nothing that will invalidate B*, after all, the
> gen_id's are all after C's stamp, and the same_context_xhlock() test
> will also pass because they're all from IRQ context (albeit not the
> same, but it cannot tell).

It will stop at xhist[0] because it has been invalidated.

> Does this explain? Or am I still missing something?

Could you read the following reply? Not enough?

https://lkml.org/lkml/2017/7/13/214

I am sorry if my english makes you hard to understand. But I already
answered all you asked.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ