⬢ DragonFlyBSD Kernel Audit
DF-3746 / fix.diff
← back to finding ↓ download raw
Requires the bios_size plumbing described in DF-3744's fix.diff (ctx->bios_size).

--- a/sys/dev/drm/radeon/radeon_atombios.c
+++ b/sys/dev/drm/radeon/radeon_atombios.c
@@ -3388,8 +3388,13 @@ static ATOM_VOLTAGE_OBJECT *atom_lookup_voltage_object_v1(ATOM_VOLTAGE_OBJECT_IN
 	u32 offset = offsetof(ATOM_VOLTAGE_OBJECT_INFO, asVoltageObj[0]);
 	u8 *start = (u8 *)v1;
 
-	while (offset < size) {
+	while (offset + sizeof(ATOM_VOLTAGE_OBJECT) < size) {
 		ATOM_VOLTAGE_OBJECT *vo = (ATOM_VOLTAGE_OBJECT *)(start + offset);
 		if (vo->ucVoltageType == voltage_type)
 			return vo;
-		offset += offsetof(ATOM_VOLTAGE_OBJECT, asFormula.ucVIDAdjustEntries) +
-			vo->asFormula.ucNumOfVoltageEntries;
+		offset += offsetof(ATOM_VOLTAGE_OBJECT, asFormula.ucVIDAdjustEntries) +
+			(vo->asFormula.ucNumOfVoltageEntries * sizeof(VOLTAGE_LUT_ENTRY));
 	}
(the same size/stride guards apply to _v2/_v3 and to the leakage-array index math at :3255-3280)