From: Peter Zijlstra <peterz@infradead.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: "Ni, BaoleX" <baolex.ni@intel.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"acme@kernel.org" <acme@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"Liu, Chuansheng" <chuansheng.liu@intel.com>
Subject: Re: hit a KASan bug related to Perf during stress test
Date: Mon, 24 Oct 2016 13:24:02 +0200 [thread overview]
Message-ID: <20161024112402.GI3102@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20161024111526.GA13509@redhat.com>
On Mon, Oct 24, 2016 at 01:15:27PM +0200, Oleg Nesterov wrote:
> On 10/24, Peter Zijlstra wrote:
> >
> > > [32738.867020] [<ffffffff810d9975>] task_tgid_nr_ns+0x35/0xb0
> >
> > So here we did: perf_event_[pt]id(event, current);
> >
> > How can _current_ not be valid anymore?
>
> ...
>
> > > [32739.040207] [<ffffffff81135a4c>] __call_rcu+0x12c/0x450
> >
> > And while we just called release_task(), that call_rcu() should still be
> > pending at this point,
>
> Yes, current is still valid.
>
> But nothing protects current->group_leader or parent/real_parent, they
> can point to the exited/freed task. We really need to nullify them in
> __unhash_process() to catch the problems like this, I wanted to do this
> many times...
>
> So you simply can't know your tgid or even tid after release_task() calls
> __unhash_process(). Actually after exit_notify() unless the exiting task
> autoreaps itself.
>
> How about the trivial fix below?
>
> Oleg.
>
> --- x/kernel/events/core.c
> +++ x/kernel/events/core.c
> @@ -1257,7 +1257,7 @@ static u32 perf_event_pid(struct perf_ev
> if (event->parent)
> event = event->parent;
>
> - return task_tgid_nr_ns(p, event->ns);
> + return pid_alive(p) ? task_tgid_nr_ns(p, event->ns) : 0;
> }
Hurm.. should we not push this into task_tgid_nr_ns() ? I mean, now the
user needs to be aware of this dinky detail.
next prev parent reply other threads:[~2016-10-24 11:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <318B87A793BE164187D8851D6CE09D64371C8811@shsmsx102.ccr.corp.intel.com>
2016-10-24 9:53 ` hit a KASan bug related to Perf during stress test Peter Zijlstra
2016-10-24 11:15 ` Oleg Nesterov
2016-10-24 11:24 ` Peter Zijlstra [this message]
2016-10-24 12:02 ` Oleg Nesterov
2016-10-24 12:10 ` Oleg Nesterov
2016-10-24 12:22 ` Peter Zijlstra
2016-10-24 12:29 ` Oleg Nesterov
2016-10-24 12:38 ` Peter Zijlstra
2016-10-24 13:25 ` Oleg Nesterov
2016-10-24 13:40 ` Oleg Nesterov
2016-10-24 14:17 ` Peter Zijlstra
2016-10-24 14:36 ` Peter Zijlstra
2016-10-24 15:39 ` Oleg Nesterov
2016-10-24 15:53 ` Oleg Nesterov
2016-10-25 6:55 ` Ni, BaoleX
2016-10-25 9:28 ` Peter Zijlstra
2016-10-25 14:41 ` Oleg Nesterov
2016-10-26 9:03 ` Peter Zijlstra
2016-10-26 16:10 ` Oleg Nesterov
2016-10-24 12:19 ` Peter Zijlstra
2016-10-24 11:27 ` Peter Zijlstra
2016-10-24 11:29 ` Peter Zijlstra
2016-10-24 12:04 ` Jiri Olsa
2016-10-24 12:12 ` Peter Zijlstra
2016-10-24 12:11 ` Peter Zijlstra
2016-10-24 12:21 ` Oleg Nesterov
2016-10-24 12:27 ` Peter Zijlstra
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=20161024112402.GI3102@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=baolex.ni@intel.com \
--cc=chuansheng.liu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
/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