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=fVMdX+vLPNBSe-8arKGvAGcdgHGt7ypEX-J-SZpUi2PGg@mail.gmail.com>
Date:   Sun, 24 Sep 2023 11:03:20 -0700
From:   Ian Rogers <irogers@...gle.com>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        linux-perf-users@...r.kernel.org, Song Liu <song@...nel.org>,
        Hao Luo <haoluo@...gle.com>, bpf@...r.kernel.org
Subject: Re: [PATCH] perf record: Fix BTF type checks in the off-cpu profiling

On Fri, Sep 22, 2023 at 4:44 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> The BTF func proto for a tracepoint has one more argument than the
> actual tracepoint function since it has a context argument at the
> begining.  So it should compare to 5 when the tracepoint has 4
> arguments.
>
>   typedef void (*btf_trace_sched_switch)(void *, bool, struct task_struct *, struct task_struct *, unsigned int);
>
> Also, recent change in the perf tool would use a hand-written minimal
> vmlinux.h to generate BTF in the skeleton.  So it won't have the info
> of the tracepoint.  Anyway it should use the kernel's vmlinux BTF to
> check the type in the kernel.
>
> Fixes: b36888f71c85 ("perf record: Handle argument change in sched_switch")
> Cc: Song Liu <song@...nel.org>
> Cc: Hao Luo <haoluo@...gle.com>
> CC: bpf@...r.kernel.org
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>

Reviewed-by: Ian Rogers <irogers@...gle.com>

> ---
>  tools/perf/util/bpf_off_cpu.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/bpf_off_cpu.c b/tools/perf/util/bpf_off_cpu.c
> index 01f70b8e705a..21f4d9ba023d 100644
> --- a/tools/perf/util/bpf_off_cpu.c
> +++ b/tools/perf/util/bpf_off_cpu.c
> @@ -98,7 +98,7 @@ static void off_cpu_finish(void *arg __maybe_unused)
>  /* v5.18 kernel added prev_state arg, so it needs to check the signature */
>  static void check_sched_switch_args(void)
>  {
> -       const struct btf *btf = bpf_object__btf(skel->obj);
> +       const struct btf *btf = btf__load_vmlinux_btf();
>         const struct btf_type *t1, *t2, *t3;
>         u32 type_id;
>
> @@ -116,7 +116,8 @@ static void check_sched_switch_args(void)
>                 return;
>
>         t3 = btf__type_by_id(btf, t2->type);
> -       if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) == 4) {
> +       /* btf_trace func proto has one more argument for the context */
> +       if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) == 5) {
>                 /* new format: pass prev_state as 4th arg */

nit: does this comment need updating?

>                 skel->rodata->has_prev_state = true;
>         }
> --
> 2.42.0.515.g380fc7ccd1-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ