Skip to content

Commit 46c28bb

Browse files
Denis Sergeevgroeck
authored andcommitted
hwmon: (dell-smm) Limit fan multiplier to avoid overflow
The fan nominal speed returned by SMM is limited to 16 bits, but the driver allows the fan multiplier to be set via a module parameter. Clamp the computed fan multiplier so that fan_nominal_speed * i8k_fan_mult always fits into a signed 32-bit integer and refuse to initialize the driver if the value is too large. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 20bdeeb ("hwmon: (dell-smm) Introduce helper function for data init") Signed-off-by: Denis Sergeev <denserg.edu@gmail.com> Link: https://lore.kernel.org/r/20251209063706.49008-1-denserg.edu@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 8f0b4cc commit 46c28bb

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/hwmon/dell-smm-hwmon.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
#define DELL_SMM_NO_TEMP 10
7777
#define DELL_SMM_NO_FANS 4
7878

79+
/* limit fan multiplier to avoid overflow */
80+
#define DELL_SMM_MAX_FAN_MULT (INT_MAX / U16_MAX)
81+
7982
struct smm_regs {
8083
unsigned int eax;
8184
unsigned int ebx;
@@ -1253,6 +1256,12 @@ static int dell_smm_init_data(struct device *dev, const struct dell_smm_ops *ops
12531256
data->ops = ops;
12541257
/* All options must not be 0 */
12551258
data->i8k_fan_mult = fan_mult ? : I8K_FAN_MULT;
1259+
if (data->i8k_fan_mult > DELL_SMM_MAX_FAN_MULT) {
1260+
dev_err(dev,
1261+
"fan multiplier %u is too large (max %u)\n",
1262+
data->i8k_fan_mult, DELL_SMM_MAX_FAN_MULT);
1263+
return -EINVAL;
1264+
}
12561265
data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH;
12571266
data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max);
12581267

0 commit comments

Comments
 (0)