From: James Clark <james.clark@linaro.org>
To: Nihar Chaithanya <niharchaithanya@gmail.com>, Leo Yan <leo.yan@arm.com>
Cc: skhan@linuxfoundation.org, john.g.garry@oracle.com,
will@kernel.org, mike.leach@linaro.org, leo.yan@linux.dev,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
irogers@google.com, adrian.hunter@intel.com,
kan.liang@linux.intel.com, graham.woodward@arm.com,
bwicaksono@nvidia.com, linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf: arm-spe: Fix null-ptr-deref in arm_spe__alloc_metadata()
Date: Fri, 20 Dec 2024 17:16:21 +0000 [thread overview]
Message-ID: <c98e8399-1471-4d38-b314-4fbcb8dcb27d@linaro.org> (raw)
In-Reply-To: <20241220145659.66066-1-niharchaithanya@gmail.com>
On 20/12/2024 2:57 pm, Nihar Chaithanya wrote:
> When metadata is allocated using arm_spe__alloc_metadata(), if the
> metadata version is 1, metadata is returned as NULL. This value
> is dereferenced later in arm_spe__free_metadata() and it can cause
> null-ptr-deref.
>
> Modify the NULL check for metadata to return -EINVAL even when
> metadata_ver == 1.
>
Hi Nihar,
I don't think this is the right fix. Doesn't that mean we can't open
files with V1 anymore? Did you test opening an old SPE file on a new
version of Perf? I actually thought I tested this before but maybe not
if there's a NULL deref.
Seems like the correct fix is to not dereference anything if metadata is
NULL, or make a fake placeholder one.
> This issue was reported by Coverity scan [1].
> [1] https://scan5.scan.coverity.com/#/project-view/63616/10063?selectedIssue=1636359
>
Is this supposed to be publicly accessible? It goes to a login page for me.
> Closes: https://scan5.scan.coverity.com/#/project-view/63616/10063?selectedIssue=1636359
> Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
Probably needs a fixes: tag too for the commit that introduced the issue.
Thanks
James
> ---
> tools/perf/util/arm-spe.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
> index dbf13f47879c..55827d8ce133 100644
> --- a/tools/perf/util/arm-spe.c
> +++ b/tools/perf/util/arm-spe.c
> @@ -1497,7 +1497,7 @@ int arm_spe_process_auxtrace_info(union perf_event *event,
>
> metadata = arm_spe__alloc_metadata(auxtrace_info, &metadata_ver,
> &nr_cpu);
> - if (!metadata && metadata_ver != 1) {
> + if (!metadata) {
> pr_err("Failed to parse Arm SPE metadata.\n");
> return -EINVAL;
> }
prev parent reply other threads:[~2024-12-20 17:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 14:57 Nihar Chaithanya
2024-12-20 17:16 ` James Clark [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c98e8399-1471-4d38-b314-4fbcb8dcb27d@linaro.org \
--to=james.clark@linaro.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bwicaksono@nvidia.com \
--cc=graham.woodward@arm.com \
--cc=irogers@google.com \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@arm.com \
--cc=leo.yan@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=niharchaithanya@gmail.com \
--cc=peterz@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®