From: Dan Carpenter <dan.carpenter@linaro.org>
To: Muralidhara M K <muralidhara.mk@amd.com>
Cc: Yazen Ghannam <Yazen.Ghannam@amd.com>,
Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>,
linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH] RAS/AMD/ATL: Fix array overflow in get_logical_coh_st_fabric_id_mi300()
Date: Wed, 31 Jan 2024 11:24:25 +0300 [thread overview]
Message-ID: <279c8b5e-6c00-467a-9071-9c67926abea4@moroto.mountain> (raw)
Check against ARRAY_SIZE() which is the number of elements instead of
sizeof() which is the number of bytes. Otherwise we potentially read
beyond the end of the phy_to_log_coh_st_map_mi300[] array.
Fixes: 453f0ae79732 ("RAS/AMD/ATL: Add MI300 support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/ras/amd/atl/denormalize.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ras/amd/atl/denormalize.c b/drivers/ras/amd/atl/denormalize.c
index d5d0e1fda159..49a900e066f1 100644
--- a/drivers/ras/amd/atl/denormalize.c
+++ b/drivers/ras/amd/atl/denormalize.c
@@ -405,7 +405,7 @@ static const u16 phy_to_log_coh_st_map_mi300[] = {
static u16 get_logical_coh_st_fabric_id_mi300(struct addr_ctx *ctx)
{
- if (ctx->inst_id >= sizeof(phy_to_log_coh_st_map_mi300)) {
+ if (ctx->inst_id >= ARRAY_SIZE(phy_to_log_coh_st_map_mi300)) {
atl_debug(ctx, "Instance ID out of range");
return ~0;
}
--
2.43.0
next reply other threads:[~2024-01-31 8:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 8:24 Dan Carpenter [this message]
2024-01-31 8:49 ` [PATCH] RAS/AMD/ATL: Fix array overflow in get_logical_coh_st_fabric_id_mi300() Borislav Petkov
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=279c8b5e-6c00-467a-9071-9c67926abea4@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=Yazen.Ghannam@amd.com \
--cc=bp@alien8.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=muralidhara.mk@amd.com \
--cc=tony.luck@intel.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).