Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
@ 2024-01-18 12:33 Denis Arefev
  2024-01-18 12:34 ` kernel test robot
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Arefev @ 2024-01-18 12:33 UTC (permalink / raw)
  To: Ian Abbott
  Cc: Greg Kroah-Hartman, H Hartley Sweeten, linux-kernel, lvc-project,
	# v5 . 15+

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.

Fixes: 3e90b1c7ebe9 ("staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers")
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Denis Arefev <arefev@swemel.ru>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 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;
 	ni_tio_set_sync_mode(counter);
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
  2024-01-18 12:33 [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow Denis Arefev
@ 2024-01-18 12:34 ` kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2024-01-18 12:34 UTC (permalink / raw)
  To: Denis Arefev; +Cc: stable, oe-kbuild-all

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
Link: https://lore.kernel.org/stable/20240118123348.45690-1-arefev%40swemel.ru

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
@ 2024-01-18 12:37 Denis Arefev
  2024-01-18 14:14 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Arefev @ 2024-01-18 12:37 UTC (permalink / raw)
  To: Ian Abbott
  Cc: Greg Kroah-Hartman, H Hartley Sweeten, linux-kernel, lvc-project,
	stable

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.

Fixes: 3e90b1c7ebe9 ("staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers")
Cc: <stable@vger.kernel.org> # v5.15+ 
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Denis Arefev <arefev@swemel.ru>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 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;
 	ni_tio_set_sync_mode(counter);
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
  2024-01-18 12:37 Denis Arefev
@ 2024-01-18 14:14 ` Greg Kroah-Hartman
  2024-01-18 14:37   ` David Laight
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2024-01-18 14:14 UTC (permalink / raw)
  To: Denis Arefev
  Cc: Ian Abbott, H Hartley Sweeten, linux-kernel, lvc-project, stable

On Thu, Jan 18, 2024 at 03:37:47PM +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.
> 
> Fixes: 3e90b1c7ebe9 ("staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers")
> Cc: <stable@vger.kernel.org> # v5.15+ 
> Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
> Signed-off-by: Denis Arefev <arefev@swemel.ru>
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
>  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;
>  	ni_tio_set_sync_mode(counter);
>  	return 0;
>  }
> -- 
> 2.25.1
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/process/submitting-patches.rst for what
  needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
  2024-01-18 14:14 ` Greg Kroah-Hartman
@ 2024-01-18 14:37   ` David Laight
  2024-01-18 15:23     ` Ian Abbott
  0 siblings, 1 reply; 6+ messages in thread
From: David Laight @ 2024-01-18 14:37 UTC (permalink / raw)
  To: 'Greg Kroah-Hartman', Denis Arefev
  Cc: Ian Abbott, H Hartley Sweeten, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org, stable@vger.kernel.org



> -----Original Message-----
> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Sent: 18 January 2024 14:14
> To: Denis Arefev <arefev@swemel.ru>
> Cc: Ian Abbott <abbotti@mev.co.uk>; H Hartley Sweeten <hsweeten@visionengravers.com>; linux-
> kernel@vger.kernel.org; lvc-project@linuxtesting.org; stable@vger.kernel.org
> Subject: Re: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
> 
> On Thu, Jan 18, 2024 at 03:37:47PM +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.
> >
> > Fixes: 3e90b1c7ebe9 ("staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers")
> > Cc: <stable@vger.kernel.org> # v5.15+
> > Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
> > Signed-off-by: Denis Arefev <arefev@swemel.ru>
> > Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> > ---
> >  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;

What about 32bit systems...

> >  	ni_tio_set_sync_mode(counter);
> >  	return 0;
> >  }
> > --
> > 2.25.1
> >
> >
> 
> Hi,
> 
> This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
> a patch that has triggered this response.  He used to manually respond
> to these common problems, but in order to save his sanity (he kept
> writing the same thing over and over, yet to different people), I was
> created.  Hopefully you will not take offence and will fix the problem
> in your patch and resubmit it so that it can be accepted into the Linux
> kernel tree.
> 
> You are receiving this message because of the following common error(s)
> as indicated below:
> 
> - This looks like a new version of a previously submitted patch, but you
>   did not list below the --- line any changes from the previous version.
>   Please read the section entitled "The canonical patch format" in the
>   kernel file, Documentation/process/submitting-patches.rst for what
>   needs to be done here to properly describe this.
> 
> If you wish to discuss this problem further, or you have questions about
> how to resolve this issue, please feel free to respond to this email and
> Greg will reply once he has dug out from the pending patches received
> from other developers.
> 
> thanks,
> 
> greg k-h's patch email bot

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
  2024-01-18 14:37   ` David Laight
@ 2024-01-18 15:23     ` Ian Abbott
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Abbott @ 2024-01-18 15:23 UTC (permalink / raw)
  To: David Laight, 'Greg Kroah-Hartman', Denis Arefev
  Cc: H Hartley Sweeten, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org, stable@vger.kernel.org

On 2024-01-18 14:37, David Laight wrote:
>> -----Original Message-----
>> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Sent: 18 January 2024 14:14
>> To: Denis Arefev <arefev@swemel.ru>
>> Cc: Ian Abbott <abbotti@mev.co.uk>; H Hartley Sweeten <hsweeten@visionengravers.com>; linux-
>> kernel@vger.kernel.org; lvc-project@linuxtesting.org; stable@vger.kernel.org
>> Subject: Re: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow
>>
>> On Thu, Jan 18, 2024 at 03:37:47PM +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.
>>>
>>> Fixes: 3e90b1c7ebe9 ("staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers")
>>> Cc: <stable@vger.kernel.org> # v5.15+
>>> Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
>>> Signed-off-by: Denis Arefev <arefev@swemel.ru>
>>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
>>> ---
>>>   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;
> 
> What about 32bit systems...

Oh, good point.  It should be 1000ULL.

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-18 16:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-18 12:33 [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow Denis Arefev
2024-01-18 12:34 ` kernel test robot
  -- 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox