From: Dan Carpenter <dan.carpenter@linaro.org>
To: Evan Quan <evan.quan@amd.com>
Cc: "Horatio Zhang" <Hongkun.Zhang@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
"Yang Wang" <KevinYang.Wang@amd.com>,
"Kenneth Feng" <kenneth.feng@amd.com>,
"Lijo Lazar" <lijo.lazar@amd.com>,
kernel-janitors@vger.kernel.org, amd-gfx@lists.freedesktop.org,
"YiPeng Chai" <YiPeng.Chai@amd.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Candice Li" <candice.li@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Christian König" <christian.koenig@amd.com>,
"Hawking Zhang" <Hawking.Zhang@amd.com>
Subject: [PATCH] drm/amd/pm: Fix memory some memory corruption
Date: Tue, 6 Jun 2023 11:33:46 +0300 [thread overview]
Message-ID: <ZH7vaonsPEHJpy1j@moroto> (raw)
The "od_table" is a pointer to a large struct, but this code is doing
pointer math as if it were pointing to bytes. It results in writing
far outside the struct.
Fixes: f0a0c659fb96 ("drm/amd/pm: fulfill the OD support for SMU13.0.0")
Fixes: e3afa4f988b3 ("drm/amd/pm: fulfill the OD support for SMU13.0.7")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 4 ++--
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
index 5ac5ea770c1c..413e592f0ed6 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
@@ -1535,7 +1535,7 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,
* settings. Thus we do not cache it.
*/
offset_of_featurectrlmask = offsetof(OverDriveTable_t, FeatureCtrlMask);
- if (memcmp(od_table + offset_of_featurectrlmask,
+ if (memcmp((u8 *)od_table + offset_of_featurectrlmask,
table_context->user_overdrive_table + offset_of_featurectrlmask,
sizeof(OverDriveTableExternal_t) - offset_of_featurectrlmask)) {
smu_v13_0_0_dump_od_table(smu, od_table);
@@ -1548,7 +1548,7 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,
od_table->OverDriveTable.FeatureCtrlMask = 0;
memcpy(table_context->user_overdrive_table + offset_of_featurectrlmask,
- od_table + offset_of_featurectrlmask,
+ (u8 *)od_table + offset_of_featurectrlmask,
sizeof(OverDriveTableExternal_t) - offset_of_featurectrlmask);
if (!memcmp(table_context->user_overdrive_table,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
index 0bd086360efa..cda4e818aab7 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
@@ -1524,7 +1524,7 @@ static int smu_v13_0_7_od_edit_dpm_table(struct smu_context *smu,
* settings. Thus we do not cache it.
*/
offset_of_featurectrlmask = offsetof(OverDriveTable_t, FeatureCtrlMask);
- if (memcmp(od_table + offset_of_featurectrlmask,
+ if (memcmp((u8 *)od_table + offset_of_featurectrlmask,
table_context->user_overdrive_table + offset_of_featurectrlmask,
sizeof(OverDriveTableExternal_t) - offset_of_featurectrlmask)) {
smu_v13_0_7_dump_od_table(smu, od_table);
@@ -1537,7 +1537,7 @@ static int smu_v13_0_7_od_edit_dpm_table(struct smu_context *smu,
od_table->OverDriveTable.FeatureCtrlMask = 0;
memcpy(table_context->user_overdrive_table + offset_of_featurectrlmask,
- od_table + offset_of_featurectrlmask,
+ (u8 *)od_table + offset_of_featurectrlmask,
sizeof(OverDriveTableExternal_t) - offset_of_featurectrlmask);
if (!memcmp(table_context->user_overdrive_table,
--
2.39.2
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Evan Quan <evan.quan@amd.com>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Lijo Lazar" <lijo.lazar@amd.com>,
"Hawking Zhang" <Hawking.Zhang@amd.com>,
"Kenneth Feng" <kenneth.feng@amd.com>,
"Candice Li" <candice.li@amd.com>,
"YiPeng Chai" <YiPeng.Chai@amd.com>,
"Yang Wang" <KevinYang.Wang@amd.com>,
"Horatio Zhang" <Hongkun.Zhang@amd.com>,
amd-gfx@lists.freedesktop.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] drm/amd/pm: Fix memory some memory corruption
Date: Tue, 6 Jun 2023 11:33:46 +0300 [thread overview]
Message-ID: <ZH7vaonsPEHJpy1j@moroto> (raw)
The "od_table" is a pointer to a large struct, but this code is doing
pointer math as if it were pointing to bytes. It results in writing
far outside the struct.
Fixes: f0a0c659fb96 ("drm/amd/pm: fulfill the OD support for SMU13.0.0")
Fixes: e3afa4f988b3 ("drm/amd/pm: fulfill the OD support for SMU13.0.7")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 4 ++--
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
index 5ac5ea770c1c..413e592f0ed6 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
@@ -1535,7 +1535,7 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,
* settings. Thus we do not cache it.
*/
offset_of_featurectrlmask = offsetof(OverDriveTable_t, FeatureCtrlMask);
- if (memcmp(od_table + offset_of_featurectrlmask,
+ if (memcmp((u8 *)od_table + offset_of_featurectrlmask,
table_context->user_overdrive_table + offset_of_featurectrlmask,
sizeof(OverDriveTableExternal_t) - offset_of_featurectrlmask)) {
smu_v13_0_0_dump_od_table(smu, od_table);
@@ -1548,7 +1548,7 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,
od_table->OverDriveTable.FeatureCtrlMask = 0;
memcpy(table_context->user_overdrive_table + offset_of_featurectrlmask,
- od_table + offset_of_featurectrlmask,
+ (u8 *)od_table + offset_of_featurectrlmask,
sizeof(OverDriveTableExternal_t) - offset_of_featurectrlmask);
if (!memcmp(table_context->user_overdrive_table,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
index 0bd086360efa..cda4e818aab7 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
@@ -1524,7 +1524,7 @@ static int smu_v13_0_7_od_edit_dpm_table(struct smu_context *smu,
* settings. Thus we do not cache it.
*/
offset_of_featurectrlmask = offsetof(OverDriveTable_t, FeatureCtrlMask);
- if (memcmp(od_table + offset_of_featurectrlmask,
+ if (memcmp((u8 *)od_table + offset_of_featurectrlmask,
table_context->user_overdrive_table + offset_of_featurectrlmask,
sizeof(OverDriveTableExternal_t) - offset_of_featurectrlmask)) {
smu_v13_0_7_dump_od_table(smu, od_table);
@@ -1537,7 +1537,7 @@ static int smu_v13_0_7_od_edit_dpm_table(struct smu_context *smu,
od_table->OverDriveTable.FeatureCtrlMask = 0;
memcpy(table_context->user_overdrive_table + offset_of_featurectrlmask,
- od_table + offset_of_featurectrlmask,
+ (u8 *)od_table + offset_of_featurectrlmask,
sizeof(OverDriveTableExternal_t) - offset_of_featurectrlmask);
if (!memcmp(table_context->user_overdrive_table,
--
2.39.2
next reply other threads:[~2023-06-06 13:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-06 8:33 Dan Carpenter [this message]
2023-06-06 8:33 ` [PATCH] drm/amd/pm: Fix memory some memory corruption Dan Carpenter
2023-06-06 10:27 ` Quan, Evan
2023-06-06 10:27 ` Quan, Evan
2023-06-06 19:27 ` Alex Deucher
2023-06-06 19:27 ` Alex Deucher
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=ZH7vaonsPEHJpy1j@moroto \
--to=dan.carpenter@linaro.org \
--cc=Hawking.Zhang@amd.com \
--cc=Hongkun.Zhang@amd.com \
--cc=KevinYang.Wang@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=YiPeng.Chai@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=candice.li@amd.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=evan.quan@amd.com \
--cc=kenneth.feng@amd.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lijo.lazar@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.