Message ID | 20240118123747.45795-1-arefev@swemel.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-30102-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp307920dyb; Thu, 18 Jan 2024 04:38:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHN58QPGUVdRD1MPiQo9pu3BFPnNebWmLf4mk61BoaTzoQbczlMcEEOTVz9aHoI1TsENxuV X-Received: by 2002:a17:903:2009:b0:1d5:f111:770 with SMTP id s9-20020a170903200900b001d5f1110770mr593450pla.74.1705581503256; Thu, 18 Jan 2024 04:38:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705581503; cv=pass; d=google.com; s=arc-20160816; b=EVriJB0ytjtrhE0fJOe2/0lIgd8rGNRVg+bTVmLJl0kFov2teRIdFdvjvapnulJU0k /BeAR5DiVLNUISQKlC/fGyM/417ZsOfd9a7ygtYRZIFELCBr74MjevlmOu9kL1DgG/hp LYMXIZypuFsExP6RfAzVs8326srhCDEvAWgxE37+vIwoQNwNrzryb7BvVUV6fh+ByO6+ 83QAoaEHOOgDLa+R4pNJwSpi/adJ/0Sg6tfOkgp6iBsOKxLZzIgqDAKK1UgTuX3D8Mmv vNH7Foji1ouS5kOgMpzYzzYrSPe0bOWhHZWuY/RuYOg4AVefw+RoUJYPHIiN0Wa4xuYL iwDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :dkim-signature:from; bh=kZPE9ryEyU6uy8bBTyu7cAdOqK0HdSpKBA8+uyMu3OI=; fh=aTtXnrKw9eZMiqaOnzqKQgsfy0mkH8plsV+WXgSSxm8=; b=k6J+xJp/X7rlB4E+qtoFNoqGWQ5+F8rAZ/10RHmzI3gJfHtmB5Wh5rBn6ScVTeQLXM gZyY9W02k6cwHXcii+vRQ/AezeqG/Xpcrri+0cKWx42RjOB5RHcA0AGtELXZ66H6RT5v EWLJoPBHygalG+zpjMp4dBCFIuVbM24ga0/BLzGRdR6ft/zncVlgJaPiDtCwNlRoQftr IV1wcRvqF7/UP1zOltS2+XbkS/CIr+xeYM+eIG5WSLTUVD/GRYy7/36X0KX1U+sS1L8K 9yjJx3CtIW1/La8iiSVg1uwKC4xSmPEvFjpV67qEAKergf7szZ8iSUyC0g++/PXiMAkl qBsQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=e+VtO6pX; arc=pass (i=1 spf=pass spfdomain=swemel.ru dkim=pass dkdomain=swemel.ru dmarc=pass fromdomain=swemel.ru); spf=pass (google.com: domain of linux-kernel+bounces-30102-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30102-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s12-20020a170902988c00b001d5af6a0736si1404437plp.451.2024.01.18.04.38.22 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 04:38:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30102-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=e+VtO6pX; arc=pass (i=1 spf=pass spfdomain=swemel.ru dkim=pass dkdomain=swemel.ru dmarc=pass fromdomain=swemel.ru); spf=pass (google.com: domain of linux-kernel+bounces-30102-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30102-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A5DFEB22BD3 for <ouuuleilei@gmail.com>; Thu, 18 Jan 2024 12:38:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D40B25112; Thu, 18 Jan 2024 12:37:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b="e+VtO6pX" Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D8E125101; Thu, 18 Jan 2024 12:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.143.211.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705581471; cv=none; b=MJsKBB6zXvM1YTFhCuVijhPlwYpoKR/LQtB7UZ5jUsaMCLTkbdOOfma9wTHqALz3EhPXBjJA51pCBJjCWOjHftEIcA3dFpVu7ZDB4pkG0R7yhTAOddfPV2viNqupkYInrIRNZzGnSkcgvt5YF6J2/PAOV/zRxmH4yLcYkx+W0Vs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705581471; c=relaxed/simple; bh=5YFQLtGOw9hoUhhBssqvlRRHGqh1xTlEvXtlZs5UWYw=; h=From:DKIM-Signature:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding; b=uqzRWuxO8+OJ9tvAIWtwH25bK0n+/DjWkl+l6xR3XWFh65IK6kBIUWH/xXYh57kypV+vJuupmtZ8iJiIABBpymPp88KCoYnAZAJ47TbSVCPzvnfd12iPTzj6VHfvkA0aGn7u5r82SDY1e7dTxRggf6pc3aOpK+xSuhfDk8k4lrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru; spf=pass smtp.mailfrom=swemel.ru; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b=e+VtO6pX; arc=none smtp.client-ip=95.143.211.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=swemel.ru From: Denis Arefev <arefev@swemel.ru> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1705581467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=kZPE9ryEyU6uy8bBTyu7cAdOqK0HdSpKBA8+uyMu3OI=; b=e+VtO6pX6tMF83Cj/ndwG8AVrAe8X6hPNKzES38olv4MrX2XzUJGQn2DStUV3H2r/ztxvc chnaAxV6jVNBbHtbYigEFM4bL8xfUERfSjCo92V6XG9nKyU6qz+2JedP80GoUJlNbs0foN 5fwAyfRGInlDKB4yzvEu97SFhbJJ9zY= To: Ian Abbott <abbotti@mev.co.uk> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, H Hartley Sweeten <hsweeten@visionengravers.com>, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, stable@vger.kernel.org Subject: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow Date: Thu, 18 Jan 2024 15:37:47 +0300 Message-Id: <20240118123747.45795-1-arefev@swemel.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788431571720256559 X-GMAIL-MSGID: 1788431830580287348 |
Series |
comedi: drivers: ni_tio: Fix arithmetic expression overflow
|
|
Commit Message
Denis Arefev
Jan. 18, 2024, 12:37 p.m. UTC
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(-)
Comments
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
> -----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)
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.
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; }