[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <02c0b221-9d4e-43fd-9dc8-40827698e947@mev.co.uk>
Date: Thu, 18 Jan 2024 15:23:50 +0000
From: Ian Abbott <abbotti@....co.uk>
To: David Laight <David.Laight@...LAB.COM>,
'Greg Kroah-Hartman' <gregkh@...uxfoundation.org>,
Denis Arefev <arefev@...mel.ru>
Cc: H Hartley Sweeten <hsweeten@...ionengravers.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"lvc-project@...uxtesting.org" <lvc-project@...uxtesting.org>,
"stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: Re: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression
overflow
On 2024-01-18 14:37, David Laight wrote:
>> -----Original Message-----
>> From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
>> Sent: 18 January 2024 14:14
>> To: Denis Arefev <arefev@...mel.ru>
>> Cc: Ian Abbott <abbotti@....co.uk>; H Hartley Sweeten <hsweeten@...ionengravers.com>; linux-
>> kernel@...r.kernel.org; lvc-project@...uxtesting.org; stable@...r.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@...r.kernel.org> # v5.15+
>>> Reviewed-by: Ian Abbott <abbotti@....co.uk>
>>> Signed-off-by: Denis Arefev <arefev@...mel.ru>
>>> Signed-off-by: Ian Abbott <abbotti@....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@....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 )=-
Powered by blists - more mailing lists