summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-mem.c
diff options
context:
space:
mode:
authorMilos Vyletel <milos@redhat.com>2015-03-20 13:37:25 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-03-20 23:49:50 +0300
commit0635b0f71424be7706793ac260d063491a2889a0 (patch)
treeb6ee8e3a907a220294f0ba9a3648c4164513f41b /tools/perf/builtin-mem.c
parent0c8c20779c5d56b93b8cb4cd30ba129a927ab437 (diff)
downloadlinux-0635b0f71424be7706793ac260d063491a2889a0.tar.xz
perf tools: Fix race in build_id_cache__add_s()
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. reproducer: rm -rf /root/.debug for cpu in $(awk '/processor/ {print $3}' /proc/cpuinfo); do perf record -a -v -T -F 1000 -C $cpu \ -o perf-${cpu}.data sleep 5 2> /dev/null & done wait and simply search for empty files by: find /lib/modules/`uname -r`/kernel/* -size 0 Signed-off-by: Milos Vyletel <milos@redhat.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1426847846-11112-1-git-send-email-milos@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-mem.c')
0 files changed, 0 insertions, 0 deletions