The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Denis Arefev <arefev@swemel.ru>
Cc: Ian Abbott <abbotti@mev.co.uk>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	open list <linux-kernel@vger.kernel.org>,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
Date: Thu, 18 Jan 2024 10:32:00 +0100	[thread overview]
Message-ID: <2024011831-morphine-showroom-bc8f@gregkh> (raw)
In-Reply-To: <20240118073619.40538-1-arefev@swemel.ru>

On Thu, Jan 18, 2024 at 10:36:19AM +0300, Denis Arefev wrote:
> The value of an arithmetic expression period_ns * 1000 is subject
> to overflow due to a failure to cast operands to a larger data
> type before performing arithmetic
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
> Signed-off-by: Denis Arefev <arefev@swemel.ru>
> ---
>  drivers/comedi/drivers/ni_tio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/comedi/drivers/ni_tio.c b/drivers/comedi/drivers/ni_tio.c
> index da6826d77e60..acc914903c70 100644
> --- a/drivers/comedi/drivers/ni_tio.c
> +++ b/drivers/comedi/drivers/ni_tio.c
> @@ -800,7 +800,7 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter,
>  				GI_PRESCALE_X2(counter_dev->variant) |
>  				GI_PRESCALE_X8(counter_dev->variant), bits);
>  	}
> -	counter->clock_period_ps = period_ns * 1000;
> +	counter->clock_period_ps = period_ns * 1000UL;

Can period_ns ever be "too big" to cause such an overflow?

And what commit id does this fix?

thanks,

greg k-h

  reply	other threads:[~2024-01-18  9:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18  7:36 [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow Denis Arefev
2024-01-18  9:32 ` Greg Kroah-Hartman [this message]
2024-01-18 11:11   ` Ian Abbott
  -- strict thread matches above, loose matches on Subject: below --
2024-01-18 12:37 Denis Arefev
2024-01-18 14:14 ` Greg Kroah-Hartman
2024-01-18 14:37   ` David Laight
2024-01-18 15:23     ` Ian Abbott
2024-01-18 12:33 Denis Arefev
2024-01-17 12:42 Denis Arefev
2024-01-17 13:52 ` Ian Abbott

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=2024011831-morphine-showroom-bc8f@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=abbotti@mev.co.uk \
    --cc=arefev@swemel.ru \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    /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