public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Vince Weaver <vincent.weaver@maine.edu>
Cc: Stephane Eranian <eranian@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Ingo Molnar <mingo@redhat.com>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: perf: fuzzer triggers NULL pointer derefreence in x86_schedule_events
Date: Wed, 20 May 2015 15:03:12 +0200	[thread overview]
Message-ID: <20150520130312.GL3644@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <alpine.DEB.2.11.1505181325110.32481@vincent-weaver-1.umelst.maine.edu>

On Mon, May 18, 2015 at 01:40:31PM -0400, Vince Weaver wrote:
> On Thu, 7 May 2015, Peter Zijlstra wrote:
> 
> > On Mon, May 04, 2015 at 12:32:56PM -0700, Stephane Eranian wrote:
> > > I think it is more likely related to the bitmask (idxmsk).  But then
> > > it is always allocated with the constraint even with the HT bug
> > > workaround.  So most, likely the index is bogus and you touch outside
> > > the idxmsk[] array.
> > 
> > [428232.701319] BUG: unable to handle kernel NULL pointer dereference at           (null)
> > 
> > But the thing really tried to touch NULL, not some random address that
> > faulted.
> > 
> > As always, Vince has found us a good puzzle ;-)
> 
> so the Haswell machine turned up the following oops that looks related.
> 
> Yet again we are ending up with a NULL pointer in the constraint table 
> somehow.
> 
> This maps to 
> 
> static bool __perf_sched_find_counter(struct perf_sched *sched)
> 
>         c = sched->events[sched->state.event]->hw.constraint;
> 
>         /* Prefer fixed purpose counters */
> --->	if (c->idxmsk64 & (~0ULL << INTEL_PMC_IDX_FIXED)) {
> 
> ffffffff81029ce4:       48 8b 55 88             mov    -0x78(%rbp),%rdx
> ffffffff81029ce8:       48 8b 04 c2             mov    (%rdx,%rax,8),%rax
> ffffffff81029cec:       ba 20 00 00 00          mov    $0x20,%edx
> ffffffff81029cf1:       48 8b 98 98 01 00 00    mov    0x198(%rax),%rbx
> ffffffff81029cf8:       4c 85 23                test   %r12,(%rbx)
> 
> 
> [306672.100641] BUG: unable to handle kernel NULL pointer dereference at           (null)
> [306672.109653] IP: [<ffffffff81029cf8>] perf_assign_events+0xa8/0x290

So new in this release is:

static void intel_put_event_constraints(struct cpu_hw_events *cpuc,
					struct perf_event *event)
{
	...

	/* cleanup dynamic constraint */
	if (c && (c->flags & PERF_X86_EVENT_DYNAMIC))
		event->hw.constraint = NULL;
}

Which is the only place that value is ever cleared...

Now, I've not quite figured out how that can intersect with scheduling,
typically we only call put_event_constraints() when we're done with the
event.

  reply	other threads:[~2015-05-20 13:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 19:08 perf: fuzzer triggers NULL pointer derefreence in x86_schedule_events Vince Weaver
2015-05-01 12:59 ` Peter Zijlstra
2015-05-04 19:32   ` Stephane Eranian
2015-05-07 12:43     ` Peter Zijlstra
2015-05-08  4:25       ` Vince Weaver
2015-05-18 17:40       ` Vince Weaver
2015-05-20 13:03         ` Peter Zijlstra [this message]
2015-05-20 13:15           ` Peter Zijlstra
2015-05-20 13:49           ` Peter Zijlstra
2015-05-20 15:26             ` Peter Zijlstra
2015-05-20 16:09               ` Peter Zijlstra
2015-05-24 19:14 ` Jiri Olsa

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=20150520130312.GL3644@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=vincent.weaver@maine.edu \
    /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