Skip to content

Commit

Permalink
perf inject: Enter namespace when reading build-id
Browse files Browse the repository at this point in the history
It should be in a proper mnt namespace when accessing the file.

I think this had no problem since the build-id was actually read from
map__load() -> dso__load() already.  But I'd like to change it in the
following commit.

Acked-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20201012070214.2074921-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Oct 13, 2020
1 parent 2946ece commit 336c95b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "util/symbol.h"
#include "util/synthetic-events.h"
#include "util/thread.h"
#include "util/namespaces.h"
#include <linux/err.h>

#include <subcmd/parse-options.h>
Expand Down Expand Up @@ -419,16 +420,19 @@ static int perf_event__repipe_tracing_data(struct perf_session *session,

static int dso__read_build_id(struct dso *dso)
{
struct nscookie nsc;

if (dso->has_build_id)
return 0;

nsinfo__mountns_enter(dso->nsinfo, &nsc);
if (filename__read_build_id(dso->long_name, dso->build_id,
sizeof(dso->build_id)) > 0) {
dso->has_build_id = true;
return 0;
}
nsinfo__mountns_exit(&nsc);

return -1;
return dso->has_build_id ? 0 : -1;
}

static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool,
Expand Down

0 comments on commit 336c95b

Please sign in to comment.