mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Milos Vyletel <milos@redhat.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Stephane Eranian <eranian@google.com>,
	"open list:PERFORMANCE EVENT..." <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf: fix race in build_id_cache__add_s()
Date: Fri, 20 Mar 2015 10:26:15 -0300	[thread overview]
Message-ID: <20150320132615.GE16485@kernel.org> (raw)
In-Reply-To: <20150320121807.GB6304@krava.brq.redhat.com>

Em Fri, Mar 20, 2015 at 01:18:07PM +0100, Jiri Olsa escreveu:
> On Fri, Mar 20, 2015 at 11:37:25AM +0100, Milos Vyletel wrote:
> > int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
> >                           const char *name, bool is_kallsyms, bool is_vdso)
> > {
> > ...
> >         if (access(filename, F_OK)) {
> >                ^--------------------------------------------------------- [1]
> >                 if (is_kallsyms) {
> >                          if (copyfile("/proc/kallsyms", filename))
> >                                 goto out_free;
> >                 } else if (link(realname, filename) && copyfile(name, filename))
> >                              ^-----------------------------^------------- [2]
> >                                                             \------------ [3]
> >                         goto out_free;
> >         }
> > ...
> > 
> > when multiple instances of perf record get to [1] at more or less same time and
> > run access() one or more may get failure because the file does not exist yet
> > (since the first instance did not have chance to link it yet). at this point the
> > race moves to link() at [2] where first thread to get there links file and goes
> > on but second one gets -EEXIST so it runs copyfile [3] which truncates the file.
> 
> nice.. :-\ 
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> 
> in addition we should use some inter-perf lock
> on all .debug dir operations

Yeah, would be nice to have that improved.

Thanks, applied.

- Arnaldo

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 10:37 Milos Vyletel
2015-03-20 12:18 ` Jiri Olsa
2015-03-20 13:26   ` Arnaldo Carvalho de Melo [this message]
2015-03-22 10:13 ` [tip:perf/core] perf tools: Fix " tip-bot for Milos Vyletel

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=20150320132615.GE16485@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=milos@redhat.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.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

Powered by JetHome