lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <af1f4106-62a7-4cd0-9891-2d9aaa77f057@roeck-us.net>
Date:   Fri, 19 May 2023 05:59:58 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Nikita Zhandarovich <n.zhandarovich@...tech.ru>
Cc:     Jean Delvare <jdelvare@...e.com>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>, linux-hwmon@...r.kernel.org,
        linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [PATCH] hwmon: (f71882fg) prevent possible division by zero

On Wed, May 10, 2023 at 07:35:37AM -0700, Nikita Zhandarovich wrote:
> In the unlikely event that something goes wrong with the device and
> its registers, the fan_from_reg() function may return 0. This value
> will cause a division-by-zero error in the show_pwm() function.
> 
> To prevent this, test the value of
> fan_from_reg(data->fan_full_speed[nr]) against 0 before performing
> the division. If the division-by-zero error is avoided, assign 0 to
> the val variable.
> 
> Found by Linux Verification Center (linuxtesting.org) with static
> analysis tool SVACE.
> 
> Fixes: df9ec2dae094 ("hwmon: (f71882fg) Reorder symbols to get rid of a few forward declarations")
> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@...tech.ru>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/f71882fg.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
> index 70121482a617..27207ec6f7fe 100644
> --- a/drivers/hwmon/f71882fg.c
> +++ b/drivers/hwmon/f71882fg.c
> @@ -1096,8 +1096,11 @@ static ssize_t show_pwm(struct device *dev,
>  		val = data->pwm[nr];
>  	else {
>  		/* RPM mode */
> -		val = 255 * fan_from_reg(data->fan_target[nr])
> -			/ fan_from_reg(data->fan_full_speed[nr]);
> +		if (fan_from_reg(data->fan_full_speed[nr]))
> +			val = 255 * fan_from_reg(data->fan_target[nr])
> +				/ fan_from_reg(data->fan_full_speed[nr]);
> +		else
> +			val = 0;
>  	}
>  	mutex_unlock(&data->update_lock);
>  	return sprintf(buf, "%d\n", val);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ