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] [day] [month] [year] [list]
Message-ID: <CAP-5=fXrPR5gq4mz8WaOkBinfR0cAutxjysaynqGj-qUSwa2oA@mail.gmail.com>
Date: Mon, 22 Jul 2024 13:49:16 -0700
From: Ian Rogers <irogers@...gle.com>
To: Casey Chen <cachen@...estorage.com>
Cc: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org, 
	namhyung@...nel.org, yzhong@...estorage.com
Subject: Re: [PATCHv4] perf tool: fix dereferencing NULL al->maps

On Mon, Jul 22, 2024 at 12:19 PM Casey Chen <cachen@...estorage.com> wrote:
>
> With 0dd5041c9a0e ("perf addr_location: Add init/exit/copy functions"),
> when cpumode is 3 (macro PERF_RECORD_MISC_HYPERVISOR),
> thread__find_map() could return with al->maps being NULL.
>
> The path below could add a callchain_cursor_node with NULL ms.maps.
>
> add_callchain_ip()
>   thread__find_symbol(.., &al)
>     thread__find_map(.., &al)   // al->maps becomes NULL
>   ms.maps = maps__get(al.maps)
>   callchain_cursor_append(..., &ms, ...)
>     node->ms.maps = maps__get(ms->maps)
>
> Then the path below would dereference NULL maps and get segfault.
>
> fill_callchain_info()
>   maps__machine(node->ms.maps);
>
> Fix it by checking if maps is NULL in fill_callchain_info().

Thanks for doing this. Can:
Signed-off-by: Casey Chen <cachen@...estorage.com>

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

Thanks,
Ian

> ---
>  tools/perf/util/callchain.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index 1730b852a947..6d075648d2cc 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -1141,7 +1141,7 @@ int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *samp
>  int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node,
>                         bool hide_unresolved)
>  {
> -       struct machine *machine = maps__machine(node->ms.maps);
> +       struct machine *machine = node->ms.maps ? maps__machine(node->ms.maps) : NULL;
>
>         maps__put(al->maps);
>         al->maps = maps__get(node->ms.maps);
> --
> 2.45.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ