* [PATCH ] drm/radeon: Fix potential buffer overflow in ci_set_mc_special_registers()
@ 2019-12-20 1:55 ` chenmaodong
0 siblings, 0 replies; 3+ messages in thread
From: chenmaodong @ 2019-12-20 1:55 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, David1.Zhou, airlied, daniel
Cc: amd-gfx, dri-devel, linux-kernel, zhangpan26, wuxu.wu, hushiyuan,
chenmaodong
Hi,
The length of table->mc_reg_address is SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE.
In ci_set_mc_special_registers(), the boundary checking
here("if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)") allows 'j' equal to
SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE which can easily cause the
table->mc_reg_address to read out of bounds.
To solve this problem, we change ">" to ">=" and check this boundary
of table->mc_reg_address after "pi->mem_gddr5" is false.
Signed-off-by: chenmaodong <chenmaodong@huawei.com>
---
drivers/gpu/drm/radeon/ci_dpm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
index a97294a..42ef745a 100644
--- a/drivers/gpu/drm/radeon/ci_dpm.c
+++ b/drivers/gpu/drm/radeon/ci_dpm.c
@@ -4364,10 +4364,10 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev,
table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
}
j++;
- if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
- return -EINVAL;
if (!pi->mem_gddr5) {
+ if (j >= SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
+ return -EINVAL;
table->mc_reg_address[j].s1 = MC_PMG_AUTO_CMD >> 2;
table->mc_reg_address[j].s0 = MC_PMG_AUTO_CMD >> 2;
for (k = 0; k < table->num_entries; k++) {
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH ] drm/radeon: Fix potential buffer overflow in ci_set_mc_special_registers()
@ 2019-12-20 1:55 ` chenmaodong
0 siblings, 0 replies; 3+ messages in thread
From: chenmaodong @ 2019-12-20 1:55 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, David1.Zhou, airlied, daniel
Cc: chenmaodong, hushiyuan, linux-kernel, dri-devel, amd-gfx,
zhangpan26, wuxu.wu
Hi,
The length of table->mc_reg_address is SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE.
In ci_set_mc_special_registers(), the boundary checking
here("if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)") allows 'j' equal to
SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE which can easily cause the
table->mc_reg_address to read out of bounds.
To solve this problem, we change ">" to ">=" and check this boundary
of table->mc_reg_address after "pi->mem_gddr5" is false.
Signed-off-by: chenmaodong <chenmaodong@huawei.com>
---
drivers/gpu/drm/radeon/ci_dpm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
index a97294a..42ef745a 100644
--- a/drivers/gpu/drm/radeon/ci_dpm.c
+++ b/drivers/gpu/drm/radeon/ci_dpm.c
@@ -4364,10 +4364,10 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev,
table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
}
j++;
- if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
- return -EINVAL;
if (!pi->mem_gddr5) {
+ if (j >= SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
+ return -EINVAL;
table->mc_reg_address[j].s1 = MC_PMG_AUTO_CMD >> 2;
table->mc_reg_address[j].s0 = MC_PMG_AUTO_CMD >> 2;
for (k = 0; k < table->num_entries; k++) {
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH ] drm/radeon: Fix potential buffer overflow in ci_set_mc_special_registers()
@ 2019-12-20 1:55 ` chenmaodong
0 siblings, 0 replies; 3+ messages in thread
From: chenmaodong @ 2019-12-20 1:55 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, David1.Zhou, airlied, daniel
Cc: chenmaodong, hushiyuan, linux-kernel, dri-devel, amd-gfx,
zhangpan26, wuxu.wu
Hi,
The length of table->mc_reg_address is SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE.
In ci_set_mc_special_registers(), the boundary checking
here("if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)") allows 'j' equal to
SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE which can easily cause the
table->mc_reg_address to read out of bounds.
To solve this problem, we change ">" to ">=" and check this boundary
of table->mc_reg_address after "pi->mem_gddr5" is false.
Signed-off-by: chenmaodong <chenmaodong@huawei.com>
---
drivers/gpu/drm/radeon/ci_dpm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
index a97294a..42ef745a 100644
--- a/drivers/gpu/drm/radeon/ci_dpm.c
+++ b/drivers/gpu/drm/radeon/ci_dpm.c
@@ -4364,10 +4364,10 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev,
table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
}
j++;
- if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
- return -EINVAL;
if (!pi->mem_gddr5) {
+ if (j >= SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
+ return -EINVAL;
table->mc_reg_address[j].s1 = MC_PMG_AUTO_CMD >> 2;
table->mc_reg_address[j].s0 = MC_PMG_AUTO_CMD >> 2;
for (k = 0; k < table->num_entries; k++) {
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-23 8:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 1:55 [PATCH ] drm/radeon: Fix potential buffer overflow in ci_set_mc_special_registers() chenmaodong
2019-12-20 1:55 ` chenmaodong
2019-12-20 1:55 ` chenmaodong
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.