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] [thread-next>] [day] [month] [year] [list]
Message-id: <54505D7D.4000704@samsung.com>
Date:	Wed, 29 Oct 2014 12:22:37 +0900
From:	Jaewon Kim <jaewon02.kim@...sung.com>
To:	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	linux-input@...r.kernel.org
Cc:	Chanwoo Choi <cw00.choi@...sung.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Input: max77693-haptic - fix potential overflow

Hi Dmitry,

2014년 10월 29일 01:43에 Dmitry Torokhov 이(가) 쓴 글:
> Expression haptic->pwm_dev->period * haptic->magnitude is of type 'unsigned
> int' and may overflow. We need to convert one of the operands to u64 before
> multiplying, instead of casting result (potentially overflown) to u64.
>
> Reported by Coverity: CID 1248753
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@...il.com>
> ---
>   drivers/input/misc/max77693-haptic.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c
> index 7b1fde9..ef6a9d6 100644
> --- a/drivers/input/misc/max77693-haptic.c
> +++ b/drivers/input/misc/max77693-haptic.c
> @@ -194,7 +194,7 @@ static int max77693_haptic_play_effect(struct input_dev *dev, void *data,
>   				       struct ff_effect *effect)
>   {
>   	struct max77693_haptic *haptic = input_get_drvdata(dev);
> -	uint64_t period_mag_multi;
> +	u64 period_mag_multi;
>   
>   	haptic->magnitude = effect->u.rumble.strong_magnitude;
>   	if (!haptic->magnitude)
> @@ -205,8 +205,7 @@ static int max77693_haptic_play_effect(struct input_dev *dev, void *data,
>   	 * The formula to convert magnitude to pwm_duty as follows:
>   	 * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF)
>   	 */
> -	period_mag_multi = (int64_t)(haptic->pwm_dev->period *
> -						haptic->magnitude);
> +	period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude;
>   	haptic->pwm_duty = (unsigned int)(period_mag_multi >>
>   						MAX_MAGNITUDE_SHIFT);
>   


There was casting miss in multiplying.
Thanks.

Acked-by : Jaewon Kim <jaewon02.kim@...sung.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ