It needs to go into a namespace before reading a file.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/synthetic-events.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index e6978b2dee8f..d0d540d09196 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -391,6 +391,8 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
struct build_id _bid, *bid = &_bid;
struct dso *dso = NULL;
struct dso_id id;
+ struct nsinfo *nsi;
+ struct nscookie nc;
int rc;
if (is_kernel) {
@@ -410,8 +412,14 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
goto out;
}
+ nsi = nsinfo__new(event->pid);
+ nsinfo__mountns_enter(nsi, &nc);
+
rc = filename__read_build_id(event->filename, bid) > 0 ? 0 : -1;
+ nsinfo__mountns_exit(&nc);
+ nsinfo__put(nsi);
+
out:
if (rc == 0) {
memcpy(event->build_id, bid->data, sizeof(bid->data));
--
2.37.3.968.ga6b4b080e4-goog
On 16/09/22 20:59, Namhyung Kim wrote:
> It needs to go into a namespace before reading a file.
This looks like a fix, in which case make it the first patch
and add a fixes tag?
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/util/synthetic-events.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> index e6978b2dee8f..d0d540d09196 100644
> --- a/tools/perf/util/synthetic-events.c
> +++ b/tools/perf/util/synthetic-events.c
> @@ -391,6 +391,8 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
> struct build_id _bid, *bid = &_bid;
> struct dso *dso = NULL;
> struct dso_id id;
> + struct nsinfo *nsi;
> + struct nscookie nc;
> int rc;
>
> if (is_kernel) {
> @@ -410,8 +412,14 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
> goto out;
> }
>
> + nsi = nsinfo__new(event->pid);
> + nsinfo__mountns_enter(nsi, &nc);
> +
> rc = filename__read_build_id(event->filename, bid) > 0 ? 0 : -1;
>
> + nsinfo__mountns_exit(&nc);
> + nsinfo__put(nsi);
> +
> out:
> if (rc == 0) {
> memcpy(event->build_id, bid->data, sizeof(bid->data));
On Tue, Sep 20, 2022 at 6:36 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 16/09/22 20:59, Namhyung Kim wrote:
> > It needs to go into a namespace before reading a file.
>
> This looks like a fix, in which case make it the first patch
> and add a fixes tag?
Good point, will do.
Thanks,
Namhyung
>
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/util/synthetic-events.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> > index e6978b2dee8f..d0d540d09196 100644
> > --- a/tools/perf/util/synthetic-events.c
> > +++ b/tools/perf/util/synthetic-events.c
> > @@ -391,6 +391,8 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
> > struct build_id _bid, *bid = &_bid;
> > struct dso *dso = NULL;
> > struct dso_id id;
> > + struct nsinfo *nsi;
> > + struct nscookie nc;
> > int rc;
> >
> > if (is_kernel) {
> > @@ -410,8 +412,14 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
> > goto out;
> > }
> >
> > + nsi = nsinfo__new(event->pid);
> > + nsinfo__mountns_enter(nsi, &nc);
> > +
> > rc = filename__read_build_id(event->filename, bid) > 0 ? 0 : -1;
> >
> > + nsinfo__mountns_exit(&nc);
> > + nsinfo__put(nsi);
> > +
> > out:
> > if (rc == 0) {
> > memcpy(event->build_id, bid->data, sizeof(bid->data));
>
© 2016 - 2026 Red Hat, Inc.