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=fWTCFx80Hd_97_4AxFV4KsRyYptLbQfw=XVw_j8i-EAyg@mail.gmail.com>
Date:   Thu, 14 May 2020 12:06:48 -0700
From:   Ian Rogers <irogers@...gle.com>
To:     "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc:     Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Subject: Re: [PATCH perf/core] perf intel-pt: Fix clang build failure in intel_pt_synth_pebs_sample

On Thu, May 14, 2020 at 8:01 AM Gustavo A. R. Silva
<gustavoars@...nel.org> wrote:
>
> On Thu, May 14, 2020 at 10:10:30AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, May 13, 2020 at 06:47:38PM -0500, Gustavo A. R. Silva escreveu:
> > > Fix the following build failure generated with command
> > > $ make CC=clang HOSTCC=clang -C tools/ perf:
> > >
> > > util/intel-pt.c:1802:24: error: field 'br_stack' with variable sized type 'struct branch_stack' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
> > >                         struct branch_stack br_stack;
> > >                                             ^
> > > 1 error generated.
> > >
> > > Fix this by reordering the members of struct br.
> >
> > Yeah, I noticed that as far back as with ubuntu 16.04's clang:
> >
> > clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
> >
> > util/intel-pt.c:1802:24: error: field 'br_stack' with variable sized type 'struct branch_stack' not at the end of a struct or class is a GNU
> >       extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
> >                         struct branch_stack br_stack;
> >                                             ^
> > 1 error generated.
> >
> >
> > Will fold this with the bug introducing the problem to avoid bisection
> > problems.
> >
>
> I agree. Also, the commit hash of the "Fixes" tag only applies to the
> perf/core branch and, I guess that might create confusion.


So while this fixes the warning I believe it breaks the intent of the code.

tools/perf/util/branch.h:
struct branch_stack {
       u64                     nr;
       u64                     hw_idx;
       struct branch_entry     entries[];
};

tools/perf/util/intel-pt.c:
               struct {
                       struct branch_stack br_stack;
                       struct branch_entry entries[LBRS_MAX];
               } br;

The array in br is trying to extend branch_stack's entries array. You
might have to do something like:

alignas(alignof(branch_stack)) char storage[sizeof(branch_stack) +
sizeof(branch_entry) * LBRS_MAX];
struct branch_stack *br = &storage;

malloc/free may be nicer on the eyeballs.

Thanks,
Ian

> Thanks
> --
> Gustavo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ