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: <CAM9d7ciTeePbQokkn_OAhwpa3cPfun-VacQRP4eOMmRzOkd6=w@mail.gmail.com>
Date:   Thu, 6 Oct 2022 10:12:37 -0700
From:   Namhyung Kim <namhyung@...nel.org>
To:     Sumanth Korikkar <sumanthk@...ux.ibm.com>
Cc:     tip-bot2@...utronix.de, linux-kernel@...r.kernel.org,
        linux-tip-commits@...r.kernel.org, peterz@...radead.org,
        x86@...nel.org, iii@...ux.ibm.com, gor@...ux.ibm.com,
        hca@...ux.ibm.com, svens@...ux.ibm.com, tmricht@...ux.ibm.com,
        bpf@...r.kernel.org
Subject: Re: [PATCH] Re: [tip: perf/core] perf: Use sample_flags for raw_data

Hello,

On Thu, Oct 6, 2022 at 9:01 AM Sumanth Korikkar <sumanthk@...ux.ibm.com> wrote:
>
> Hi,
>
> This causes segfaults.
>
> Steps to recreate:
> *  Run ./samples/bpf/trace_output
> BUG pid 9 cookie 1001000000004 sized 4
> BUG pid 9 cookie 1001000000004 sized 4
> BUG pid 9 cookie 1001000000004 sized 4
> Segmentation fault (core dumped)
>
> Problem:
> * The following commit sets data->raw to NULL, when the raw data is not filled
> by PMU driver. This leads to stale data.
>
> * raw data could also be filled by bpf_perf_event_output(), bpf_event_output()
> ...
>  686         perf_sample_data_init(sd, 0, 0);
>  687         sd->raw = &raw;
>  688
>  689         err = __bpf_perf_event_output(regs, map, flags, sd);
> ...
>
> * The below patch eliminates segfaults. However, contradicts with
> the description mentioned in this commit (Filled by only PMU driver).

Thank you for the fix.  Don't worry about the description - it said
it's usually filled by PMU drivers and it should be fine as long as
you set the sample flags after filling the raw data.

Acked-by: Namhyung Kim <namhyung@...nel.org>

Thanks,
Namhyung

>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 49fb9ec8366d..1ed08967fb97 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -687,6 +687,7 @@ BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map,
>
>         perf_sample_data_init(sd, 0, 0);
>         sd->raw = &raw;
> +       sd->sample_flags |= PERF_SAMPLE_RAW;
>
>         err = __bpf_perf_event_output(regs, map, flags, sd);
>
> @@ -745,6 +746,7 @@ u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
>         perf_fetch_caller_regs(regs);
>         perf_sample_data_init(sd, 0, 0);
>         sd->raw = &raw;
> +       sd->sample_flags |= PERF_SAMPLE_RAW;
>
>         ret = __bpf_perf_event_output(regs, map, flags, sd);
>  out:
>
> --
> Thanks,
> Sumanth

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ