linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>,
	linux-kernel@vger.kernel.org, x86@kernel.org, mingo@redhat.com,
	kim.phillips@amd.com
Subject: Re: [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated
Date: Fri, 15 Apr 2022 17:49:46 -0700	[thread overview]
Message-ID: <20220416004946.tydhjaewitocy2cn@treble> (raw)
In-Reply-To: <YlVPpVC8chepOdzJ@hirez.programming.kicks-ass.net>

On Tue, Apr 12, 2022 at 12:08:37PM +0200, Peter Zijlstra wrote:
> On Tue, Apr 12, 2022 at 10:40:03AM +0300, Dmitry Monakhov wrote:
> > get_stack_info() detects stack type only by begin address, so we must
> > check that address range in question is fully covered by detected stack
> > 
> > Otherwise following crash is possible:
> > -> unwind_next_frame
> >    case ORC_TYPE_REGS:
> >      if (!deref_stack_regs(state, sp, &state->ip, &state->sp))
> >      -> deref_stack_regs
> >        -> stack_access_ok  <- here addr is inside stack range, but addr+len-1 is not, but we still exit with success
> >      *ip = READ_ONCE_NOCHECK(regs->ip); <- Here we hit stack guard fault
> > OOPS LOG:
> > <0>[ 1941.845743] BUG: stack guard page was hit at 000000000dd984a2 (stack is 00000000d1caafca..00000000613712f0)
> 
> 
> > <4>[ 1941.845751]  get_perf_callchain+0x10d/0x280
> > <4>[ 1941.845751]  perf_callchain+0x6e/0x80
> > <4>[ 1941.845752]  perf_prepare_sample+0x87/0x540
> > <4>[ 1941.845752]  perf_event_output_forward+0x31/0x90
> > <4>[ 1941.845753]  __perf_event_overflow+0x5a/0xf0
> > <4>[ 1941.845754]  perf_ibs_handle_irq+0x340/0x5b0
> > <4>[ 1941.845757]  perf_ibs_nmi_handler+0x34/0x60
> > <4>[ 1941.845757]  nmi_handle+0x79/0x190
> 
> Urgh, this is another instance of trying to unwind an IP that no longer
> matches the stack.
> 
> Fixing the unwinder bug is good, but arguable we should also fix this
> IBS stuff, see 6cbc304f2f36 ("perf/x86/intel: Fix unwind errors from PEBS entries (mk-II)")

I remember that nastiness well.  So it's still broken?  Or is this a
regression?  Maybe we wouldn't notice it except for this triggered
unwinder bug?

-- 
Josh


  reply	other threads:[~2022-04-16  2:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12  7:40 [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Dmitry Monakhov
2022-04-12  7:40 ` [PATCH 2/2] x86/unwind/orc: Fix address check size for deref_stack_iret_regs Dmitry Monakhov
2022-04-12 10:01   ` Peter Zijlstra
2022-04-12 10:57     ` Dmitry Monakhov
2022-04-12 10:08 ` [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Peter Zijlstra
2022-04-16  0:49   ` Josh Poimboeuf [this message]
2022-04-29  5:14   ` [PATCH] perf/amd/ibs: Use interrupt regs ip for stack unwinding Ravi Bangoria
2022-04-29 20:28     ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2022-05-02  6:07     ` [PATCH] " Namhyung Kim
2022-05-04  9:23     ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2022-05-10  9:11     ` tip-bot2 for Ravi Bangoria
2022-04-12 10:11 ` [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Peter Zijlstra
2022-04-14 15:18   ` Josh Poimboeuf
2022-04-16  0:46 ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220416004946.tydhjaewitocy2cn@treble \
    --to=jpoimboe@redhat.com \
    --cc=dmtrmonakhov@yandex-team.ru \
    --cc=kim.phillips@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).