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] [day] [month] [year] [list]
Message-ID: <CAM_iQpVT73pofGYYys+OC5OCs8w+Q+rnfnwBaQQRuobnqcEJUg@mail.gmail.com>
Date:   Wed, 25 Jul 2018 11:44:34 -0700
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...hat.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH v2] perf/core: fix a possible deadlock scenario

On Tue, Jul 24, 2018 at 2:18 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Mon, Jul 23, 2018 at 06:44:43PM -0700, Cong Wang wrote:
> > On Mon, Jul 23, 2018 at 6:35 PM Cong Wang <xiyou.wangcong@...il.com> wrote:
> > >
> > > Hi, Peter, Andi
> > >
> > > While reviewing the deadlock, I find out it looks like we could have the
> > > following infinite recursion too:
> > >
> > > perf_event_account_interrupt()
> > > __perf_event_account_interrupt()
> > > perf_adjust_period()
> > > event->pmu->stop
> > > x86_pmu_stop()
> > > x86_pmu.disable()
> >
> > Hmm, x86_pmu_stop() calls __test_and_clear_bit(), so
> > we should not call x86_pmu.disable() twice here.
>
> Right, but since we set HES_UPTODATE after calling
> x86_perf_event_update() that can in fact recurse.

I don't see how HES_UPTODATE flag or x86_perf_event_update()
could affect the path on this call chain.


>
> Now, I don't think that'll be fatal, but it might be good to test that.
>
> If you pick these patches:
>
>   https://lkml.kernel.org/r/20170928121823.430053219@infradead.org
>
> use force_early_printk (and actually configure a serial early_printk)
> and put a printk() in x86_pmu_stop() and then run the perf_fuzzer or
> something to try and reproduce.

Is this patchset to make printk() working in NMI context?
But printk() is already used in NMI context, see perf_event_print_debug()
which is called in intel_pmu_handle_irq().


>
> But paranoia suggets moving that HES_UPTODATE thing one line up.
>
> > > intel_pmu_disable_event()
> > > intel_pmu_pebs_disable()
> > > intel_pmu_drain_pebs_buffer()
> > > intel_pmu_drain_pebs_nhm()
> > > <repeat....>
> > >
> > > This time is pure hardware events, attr.freq must be non-zero.
> > >
> > > And, we could enter this infinite recursion in NMI handler too:
> > >
> > > intel_pmu_handle_irq()
> > > perf_event_overflow()
> > > __perf_event_overflow()
> > > __perf_event_account_interrupt()
> > > ....
> > >
> > > Or this is impossible too?
>
> I'm not sure I see this second one.. can you be a little more specific?

In fact, it is this:

intel_pmu_handle_irq()
x86_pmu.drain_pebs()
intel_pmu_drain_pebs_nhm()
perf_event_account_interrupt()
__perf_event_account_interrupt()
perf_adjust_period()
event->pmu->stop()
x86_pmu_stop()
x86_pmu.disable()
intel_pmu_disable_event()
intel_pmu_pebs_disable()
intel_pmu_drain_pebs_buffer()
<repeat....>


Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ