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: <CAM9d7ciW1wF7YGszv4KQ_KRUhCeBVynQsuRi2+NoRAYgy3xsRw@mail.gmail.com>
Date:   Wed, 12 Oct 2022 09:20:10 -0700
From:   Namhyung Kim <namhyung@...nel.org>
To:     Adrian Hunter <adrian.hunter@...el.com>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...hat.com>, Ian Rogers <irogers@...gle.com>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        linux-perf-users <linux-perf-users@...r.kernel.org>
Subject: Re: [PATCH 1/2] perf intel-pt: Fix segfault in intel_pt_print_info()
 with uClibc

Hi Adrian,

On Wed, Oct 12, 2022 at 1:23 AM Adrian Hunter <adrian.hunter@...el.com> wrote:
>
> uClibc segfaulted because NULL was passed as the format to fprintf().

Sounds like glibc has a NULL check in fprintf().

>
> That happened because one of the format strings was missing and
> intel_pt_print_info() didn't check that before calling fprintf().
>
> Add the missing format string, and check format is not NULL before calling
> fprintf().
>
> Fixes: 11fa7cb86b56 ("perf tools: Pass Intel PT information for decoding MTC and CYC")
> Cc: stable@...r.kernel.org
> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>

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

Thanks,
Namhyung


> ---
>  tools/perf/util/intel-pt.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
> index b34cb3dec1aa..e3548ddef254 100644
> --- a/tools/perf/util/intel-pt.c
> +++ b/tools/perf/util/intel-pt.c
> @@ -4046,6 +4046,7 @@ static const char * const intel_pt_info_fmts[] = {
>         [INTEL_PT_SNAPSHOT_MODE]        = "  Snapshot mode       %"PRId64"\n",
>         [INTEL_PT_PER_CPU_MMAPS]        = "  Per-cpu maps        %"PRId64"\n",
>         [INTEL_PT_MTC_BIT]              = "  MTC bit             %#"PRIx64"\n",
> +       [INTEL_PT_MTC_FREQ_BITS]        = "  MTC freq bits       %#"PRIx64"\n",
>         [INTEL_PT_TSC_CTC_N]            = "  TSC:CTC numerator   %"PRIu64"\n",
>         [INTEL_PT_TSC_CTC_D]            = "  TSC:CTC denominator %"PRIu64"\n",
>         [INTEL_PT_CYC_BIT]              = "  CYC bit             %#"PRIx64"\n",
> @@ -4060,8 +4061,12 @@ static void intel_pt_print_info(__u64 *arr, int start, int finish)
>         if (!dump_trace)
>                 return;
>
> -       for (i = start; i <= finish; i++)
> -               fprintf(stdout, intel_pt_info_fmts[i], arr[i]);
> +       for (i = start; i <= finish; i++) {
> +               const char *fmt = intel_pt_info_fmts[i];
> +
> +               if (fmt)
> +                       fprintf(stdout, fmt, arr[i]);
> +       }
>  }
>
>  static void intel_pt_print_info_str(const char *name, const char *str)
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ