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: <20190524070124.GA11882@gmail.com>
Date:   Fri, 24 May 2019 09:01:24 +0200
From:   Ingo Molnar <mingo@...nel.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     yabinc@...gle.com, acme@...nel.org,
        alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
        namhyung@...nel.org, mark.rutland@....com,
        linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH 1/4] perf/ring_buffer: Fix exposing a temporarily
 decreased data_head.


* Peter Zijlstra <peterz@...radead.org> wrote:

> On Fri, May 17, 2019 at 03:05:09PM +0200, Ingo Molnar wrote:
> > 
> > * Peter Zijlstra <peterz@...radead.org> wrote:
> > 
> > > In perf_output_put_handle(), an IRQ/NMI can happen in below location and
> > > write records to the same ring buffer:
> > > 	...
> > > 	local_dec_and_test(&rb->nest)
> > > 	...                          <-- an IRQ/NMI can happen here
> > > 	rb->user_page->data_head = head;
> > > 	...
> > > 
> > > In this case, a value A is written to data_head in the IRQ, then a value
> > > B is written to data_head after the IRQ. And A > B. As a result,
> > > data_head is temporarily decreased from A to B. And a reader may see
> > > data_head < data_tail if it read the buffer frequently enough, which
> > > creates unexpected behaviors.
> > > 
> > > This can be fixed by moving dec(&rb->nest) to after updating data_head,
> > > which prevents the IRQ/NMI above from updating data_head.
> > > 
> > > Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
> > > Cc: Ingo Molnar <mingo@...hat.com>
> > > Cc: Jiri Olsa <jolsa@...hat.com>
> > > Cc: Namhyung Kim <namhyung@...nel.org>
> > > Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> > > Fixes: ef60777c9abd ("perf: Optimize the perf_output() path by removing IRQ-disables")
> > > Signed-off-by: Yabin Cui <yabinc@...gle.com>
> > > Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> > > Link: https://lkml.kernel.org/r/20190516184010.167903-1-yabinc@google.com
> > 
> > So these are missing a bunch of:
> > 
> >   From: Yabin Cui <yabinc@...gle.com>
> > 
> > lines, right?
> > 
> 
> The first. certainly, the rest, while inspired by his patch, is more
> complete than what he did.

Oh, indeed - I adjusted the first patch only.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ