[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <xn7ikpjzqddnrna72ojiitufruemineonyhh5cmwizrrnt4txp@gh2sy6ixddx7>
Date: Sat, 15 Feb 2025 13:09:11 -0500
From: Alex Lanzano <lanzano.alex@...il.com>
To: Nikita Zhandarovich <n.zhandarovich@...tech.ru>
Cc: Noralf Trønnes <noralf@...nnes.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>, David Laight <david.laight.linux@...il.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [PATCH] drm/repaper: fix integer overflows in repeat functions
On Thu, Jan 16, 2025 at 05:48:01AM -0800, Nikita Zhandarovich wrote:
> There are conditions, albeit somewhat unlikely, under which right hand
> expressions, calculating the end of time period in functions like
> repaper_frame_fixed_repeat(), may overflow.
>
> For instance, if 'factor10x' in repaper_get_temperature() is high
> enough (170), as is 'epd->stage_time' in repaper_probe(), then the
> resulting value of 'end' will not fit in unsigned int expression.
>
> Mitigate this by casting 'epd->factored_stage_time' to wider type before
> any multiplication is done.
>
> Found by Linux Verification Center (linuxtesting.org) with static
> analysis tool SVACE.
>
> Fixes: 3589211e9b03 ("drm/tinydrm: Add RePaper e-ink driver")
> Cc: stable@...r.kernel.org
> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@...tech.ru>
After discussing with David Laight I cleared up my concerns.
Reviewed-by: Alex Lanzano <lanzano.alex@...il.com>
> ---
> drivers/gpu/drm/tiny/repaper.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
> index 77944eb17b3c..d76c0e8e05f5 100644
> --- a/drivers/gpu/drm/tiny/repaper.c
> +++ b/drivers/gpu/drm/tiny/repaper.c
> @@ -456,7 +456,7 @@ static void repaper_frame_fixed_repeat(struct repaper_epd *epd, u8 fixed_value,
> enum repaper_stage stage)
> {
> u64 start = local_clock();
> - u64 end = start + (epd->factored_stage_time * 1000 * 1000);
> + u64 end = start + ((u64)epd->factored_stage_time * 1000 * 1000);
>
> do {
> repaper_frame_fixed(epd, fixed_value, stage);
> @@ -467,7 +467,7 @@ static void repaper_frame_data_repeat(struct repaper_epd *epd, const u8 *image,
> const u8 *mask, enum repaper_stage stage)
> {
> u64 start = local_clock();
> - u64 end = start + (epd->factored_stage_time * 1000 * 1000);
> + u64 end = start + ((u64)epd->factored_stage_time * 1000 * 1000);
>
> do {
> repaper_frame_data(epd, image, mask, stage);
Powered by blists - more mailing lists