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 18:09:11 +0200	[thread overview]
Message-ID: <20150520160911.GM18673@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20150520152607.GK18673@twins.programming.kicks-ass.net>

On Wed, May 20, 2015 at 05:26:07PM +0200, Peter Zijlstra wrote:
> Except of course that ->event_init() likes to do an allocation :/
> 
> Needs to be fixed differently.

So this puts the lock in the x86 code, it seems to build and run.

But my brain is fried after staring at this pmu scheduling code all day,
so maybe its wrong again.

Stephane, can you have a look?

---
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 87848eb..344bb90 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1823,6 +1823,9 @@ static int validate_group(struct perf_event *event)
 	fake_cpuc = allocate_fake_cpuc();
 	if (IS_ERR(fake_cpuc))
 		return PTR_ERR(fake_cpuc);
+
+
+	raw_spin_lock_irq(&leader->ctx->lock);
 	/*
 	 * the event is not yet connected with its
 	 * siblings therefore we must first collect
@@ -1843,6 +1846,8 @@ static int validate_group(struct perf_event *event)
 	ret = x86_pmu.schedule_events(fake_cpuc, n, NULL);
 
 out:
+	raw_spin_unlock_irq(&leader->ctx->lock);
+
 	free_fake_cpuc(fake_cpuc);
 	return ret;
 }

  reply	other threads:[~2015-05-20 16:09 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
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 [this message]
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=20150520160911.GM18673@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