From: Nihar Chaithanya <niharchaithanya@gmail.com>
To: john.g.garry@oracle.com, will@kernel.org, james.clark@linaro.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
Cc: skhan@linuxfoundation.org, Nihar Chaithanya <niharchaithanya@gmail.com>
Subject: [PATCH] perf: arm-spe: Fix null-ptr-deref in arm_spe__alloc_metadata()
Date: Fri, 20 Dec 2024 20:27:02 +0530 [thread overview]
Message-ID: <20241220145659.66066-1-niharchaithanya@gmail.com> (raw)
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.
This issue was reported by Coverity scan [1].
[1] https://scan5.scan.coverity.com/#/project-view/63616/10063?selectedIssue=1636359
Closes: https://scan5.scan.coverity.com/#/project-view/63616/10063?selectedIssue=1636359
Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
---
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;
}
--
2.34.1
next reply other threads:[~2024-12-20 15:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 14:57 Nihar Chaithanya [this message]
2024-12-20 17:16 ` [PATCH] perf: arm-spe: Fix null-ptr-deref in arm_spe__alloc_metadata() James Clark
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=20241220145659.66066-1-niharchaithanya@gmail.com \
--to=niharchaithanya@gmail.com \
--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=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.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=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