lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150320121807.GB6304@krava.brq.redhat.com>
Date:	Fri, 20 Mar 2015 13:18:07 +0100
From:	Jiri Olsa <jolsa@...hat.com>
To:	Milos Vyletel <milos@...hat.com>
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Jiri Olsa <jolsa@...nel.org>,
	Stephane Eranian <eranian@...gle.com>,
	"open list:PERFORMANCE EVENT..." <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] perf: fix race in build_id_cache__add_s()

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@...nel.org>

in addition we should use some inter-perf lock
on all .debug dir operations

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ