<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table"
href="https://bugs.freedesktop.org/show_bug.cgi?id=108609">108609</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table
</td>
</tr>
<tr>
<th>Product</th>
<td>DRI
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>x86-64 (AMD64)
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>DRM/AMDgpu
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dri-devel@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rstrube@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=142298" name="attach_142298" title="Patch to fix accessing mvdd_voltage_table.entries[] array out of bounds in vegam_smumgr.c">attachment 142298</a> <a href="attachment.cgi?id=142298&action=edit" title="Patch to fix accessing mvdd_voltage_table.entries[] array out of bounds in vegam_smumgr.c">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=108609&attachment=142298'>[review]</a>
Patch to fix accessing mvdd_voltage_table.entries[] array out of bounds in
vegam_smumgr.c
I believe I've discovered a small bug in the vegam_smumgr.c, specifically the
following function:
static int vegam_populate_smc_mvdd_table(struct pp_hwmgr *hwmgr,
SMU75_Discrete_DpmTable *table)
{
struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
uint32_t count, level;
if (SMU7_VOLTAGE_CONTROL_BY_GPIO == data->mvdd_control) {
count = data->mvdd_voltage_table.count;
if (count > SMU_MAX_SMIO_LEVELS)
count = SMU_MAX_SMIO_LEVELS;
for (level = 0; level < count; level++) {
table->SmioTable2.Pattern[level].Voltage =
PP_HOST_TO_SMC_US(
data->mvdd_voltage_table.entries[count].value * VOLTAGE_SCALE);
/* Index into DpmTable.Smio. Drive bits from Smio entry
to get this voltage level.*/
table->SmioTable2.Pattern[level].Smio =
(uint8_t) level;
table->Smio[level] |=
data->mvdd_voltage_table.entries[level].smio_low;
}
table->SmioMask2 = data->mvdd_voltage_table.mask_low;
table->MvddLevelCount = (uint32_t) PP_HOST_TO_SMC_UL(count);
}
return 0;
}
With the lines (within the for loop):
table->SmioTable2.Pattern[level].Voltage = PP_HOST_TO_SMC_US(
data->mvdd_voltage_table.entries[count].value * VOLTAGE_SCALE);
If this code was executed it would try to access the
mvdd_voltage_table.entries[] array out of bounds, because count > than the max
value for level.
I believe:
data->mvdd_voltage_table.entries[count].value
should actually be:
data->mvdd_voltage_table.entries[level].value
You can see in a similar function within vegam_smumgr.c, this bug is *not*
present:
static int vegam_populate_smc_vddci_table(struct pp_hwmgr *hwmgr,
struct SMU75_Discrete_DpmTable *table)
{
uint32_t count, level;
struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
count = data->vddci_voltage_table.count;
if (SMU7_VOLTAGE_CONTROL_BY_GPIO == data->vddci_control) {
if (count > SMU_MAX_SMIO_LEVELS)
count = SMU_MAX_SMIO_LEVELS;
for (level = 0; level < count; ++level) {
table->SmioTable1.Pattern[level].Voltage =
PP_HOST_TO_SMC_US(
data->vddci_voltage_table.entries[level].value * VOLTAGE_SCALE);
table->SmioTable1.Pattern[level].Smio = (uint8_t)
level;
table->Smio[level] |=
data->vddci_voltage_table.entries[level].smio_low;
}
}
table->SmioMask1 = data->vddci_voltage_table.mask_low;
return 0;
}
I've attached a patch for kernel 4.19, admittedly the change is trivial but I
figured I would try to do things the right way :)
Thanks!
Rob</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>