mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Noralf Trønnes" <noralf@tronnes.org>
To: Nikita Zhandarovich <n.zhandarovich@fintech.ru>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Alex Lanzano <lanzano.alex@gmail.com>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH] drm/repaper: fix integer overflows in repeat functions
Date: Thu, 13 Feb 2025 18:08:32 +0100	[thread overview]
Message-ID: <cac5924e-5653-4385-b18f-6c7f1f8d6e8b@tronnes.org> (raw)
In-Reply-To: <d9e1c3a9-0a82-4908-b455-99227c5a2bd5@fintech.ru>

Adding Alex who is now the driver maintainer.


On 13.02.2025 17:57, Nikita Zhandarovich wrote:
> Gentle ping :)
> 
> On 1/16/25 16:48, 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@vger.kernel.org
>> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
>> ---
>>  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);
> 


  reply	other threads:[~2025-02-13 17:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 13:48 Nikita Zhandarovich
2025-02-13 16:57 ` Nikita Zhandarovich
2025-02-13 17:08   ` Noralf Trønnes [this message]
2025-02-14  1:54 ` Alex Lanzano
2025-02-14 13:29   ` David Laight
2025-02-15  1:02     ` Alex Lanzano
2025-02-15 11:48       ` David Laight
2025-02-15 16:35         ` Alex Lanzano
2025-02-15 18:09 ` Alex Lanzano
2025-02-25  0:47 ` Alex Lanzano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cac5924e-5653-4385-b18f-6c7f1f8d6e8b@tronnes.org \
    --to=noralf@tronnes.org \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lanzano.alex@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=n.zhandarovich@fintech.ru \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®