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: <CAP-5=fV4Agxe3UMpkbWkh9CuG1tYho413w7xehy0SiMX+tPv1Q@mail.gmail.com>
Date:   Tue, 15 Sep 2020 13:17:44 -0700
From:   Ian Rogers <irogers@...gle.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Jiri Olsa <jolsa@...nel.org>, lkml <linux-kernel@...r.kernel.org>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Ingo Molnar <mingo@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Michael Petlan <mpetlan@...hat.com>,
        Song Liu <songliubraving@...com>,
        "Frank Ch. Eigler" <fche@...hat.com>,
        Stephane Eranian <eranian@...gle.com>,
        Alexey Budankov <alexey.budankov@...ux.intel.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Adrian Hunter <adrian.hunter@...el.com>
Subject: Re: [PATCH 16/26] perf tools: Synthesize modules with mmap3

On Mon, Sep 14, 2020 at 9:08 AM Arnaldo Carvalho de Melo
<acme@...nel.org> wrote:
>
> Em Sun, Sep 13, 2020 at 11:03:03PM +0200, Jiri Olsa escreveu:
> > Synthesizing modules with mmap3 events so we can
> > get build id data for module's maps as well.
>
> Ditto as for 15/26
>
> > Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> > ---
> >  tools/perf/util/synthetic-events.c | 37 +++++++++++++++++++-----------
> >  1 file changed, 24 insertions(+), 13 deletions(-)
> >
> > diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> > index bd6e7b84283d..6bd2423ce2f3 100644
> > --- a/tools/perf/util/synthetic-events.c
> > +++ b/tools/perf/util/synthetic-events.c
> > @@ -605,7 +605,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t
> >       int rc = 0;
> >       struct map *pos;
> >       struct maps *maps = machine__kernel_maps(machine);
> > -     union perf_event *event = zalloc((sizeof(event->mmap) +
> > +     union perf_event *event = zalloc((sizeof(event->mmap3) +
> >                                         machine->id_hdr_size));
> >       if (event == NULL) {
> >               pr_debug("Not enough memory synthesizing mmap event "
> > @@ -613,8 +613,6 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t
> >               return -1;
> >       }
> >
> > -     event->header.type = PERF_RECORD_MMAP;
> > -
> >       /*
> >        * kernel uses 0 for user space maps, see kernel/perf_event.c
> >        * __perf_event_mmap
> > @@ -631,17 +629,30 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t
> >                       continue;
> >
> >               size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64));
> > -             event->mmap.header.type = PERF_RECORD_MMAP;
> > -             event->mmap.header.size = (sizeof(event->mmap) -
> > -                                     (sizeof(event->mmap.filename) - size));
> > -             memset(event->mmap.filename + size, 0, machine->id_hdr_size);
> > -             event->mmap.header.size += machine->id_hdr_size;
> > -             event->mmap.start = pos->start;
> > -             event->mmap.len   = pos->end - pos->start;
> > -             event->mmap.pid   = machine->pid;
> > -
> > -             memcpy(event->mmap.filename, pos->dso->long_name,
> > +             event->mmap3.header.type = PERF_RECORD_MMAP3;
> > +             event->mmap3.header.size = (sizeof(event->mmap3) -
> > +                                        (sizeof(event->mmap3.filename) - size));
> > +             memset(event->mmap3.filename + size, 0, machine->id_hdr_size);
> > +             event->mmap3.header.size += machine->id_hdr_size;
> > +             event->mmap3.start = pos->start;
> > +             event->mmap3.len   = pos->end - pos->start;
> > +             event->mmap3.pid   = machine->pid;
> > +
> > +             memcpy(event->mmap3.filename, pos->dso->long_name,
> >                      pos->dso->long_name_len + 1);
> > +
> > +             rc = filename__read_build_id(event->mmap3.filename, event->mmap3.buildid,
> > +                                          BUILD_ID_SIZE);
> > +             if (rc != BUILD_ID_SIZE) {

IIRC BUILD_ID_SIZE is 20 bytes which is the correct size for SHA-1. A
build ID may be 128-bits (16 bytes) if md5 or uuid hashes are used.
Should this test just be "> 0" ?

Thanks,
Ian

> > +                     if (event->mmap3.filename[0] == '/') {
> > +                             pr_debug2("Failed to read build ID for %s\n",
> > +                                       event->mmap3.filename);
> > +                     }
> > +                     memset(event->mmap3.buildid, 0x0, sizeof(event->mmap3.buildid));
> > +             }
> > +
> > +             rc = 0;
> > +
> >               if (perf_tool__process_synth_event(tool, event, machine, process) != 0) {
> >                       rc = -1;
> >                       break;
> > --
> > 2.26.2
> >
>
> --
>
> - Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ