Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp349149rdb; Thu, 18 Jan 2024 05:37:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/Ktsqg6TatG9NFXRz8p1ZGlNcWzVmSMUBBac23Qird3T8IRW9UYo8l+inRxucPr/5PovZ X-Received: by 2002:aca:d09:0:b0:3bd:970b:aa15 with SMTP id 9-20020aca0d09000000b003bd970baa15mr782657oin.54.1705585051204; Thu, 18 Jan 2024 05:37:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705585051; cv=pass; d=google.com; s=arc-20160816; b=XAZV+cIlyeRrh2bNWrg2u5OrJGKtdkF/9yBhiCvDiiCzlHr/9eHYiRQ+AjjnBDNAOs kNPjObRxAiqoeTXo2Tc45qADX7CB+zfjFpFchovxOUMChhw81EuziibYyVx7+UFnHJRO EcGnTtMB8rmNb6RDVACPSp9G/BJ6RLhRZJUIcO9mEJw/R3K1/FUfDbioEdD3OneFGWdk D8FFsfIXZGwc3Eft0RqN0Y4E7RBxYupNTTGYBeQSpZ9pb73BLl/FTHyb2ZFVC/7W46Vb AD6mE4ZbL4BM2HrjMqqu8afqfkpw2MIG+zYYpJNY/zC/MbD6vhGCXNSiG3wIj3ISGvm8 X1uQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=4Drt6Ma/KRCSlyXAD8kdnPZ08DfKxavzdDFtbVx9XlI=; fh=7sP0vc0iP1y5b+2wGhHrEogiEhL3u14eZvrmxic1+c4=; b=IpWhcqtbpEfNP+N5bc8couwv7pUz+qMWlttk6bdQLkr23XAnP0RUe6gJYpG5lSPCKk OedCcLVu+ZYshynRJBviz3d+rVympzXq3TZ2I1Q41KLgb7+4SNIcRxWl/VhdaJHF/H4I PhRGTrZlmLuoumHov03fIeczVZqc1LYUNdy4oRCX7yHLxt+0W0puIM1jFO5VIS5FwXtd V7lKmy97uUWbF0ezTXAKfccezM/aP+8QeDZfZ/vdLLcLjHr37cckUdl6fh/jjj35DWhG VHNY8XOzYPOVKb/oDxT/l6I0OjMdv/KxCm1K1EV27hjy/ht2xiXv8sHHW2PliR4RRkby 82iQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=UVDwdd11; arc=pass (i=1 spf=pass spfdomain=mev.co.uk dkim=pass dkdomain=mev.co.uk dmarc=pass fromdomain=mev.co.uk); spf=pass (google.com: domain of linux-kernel+bounces-30158-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30158-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o12-20020a05622a044c00b00429d35dada5si11081075qtx.708.2024.01.18.05.37.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 05:37:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30158-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=UVDwdd11; arc=pass (i=1 spf=pass spfdomain=mev.co.uk dkim=pass dkdomain=mev.co.uk dmarc=pass fromdomain=mev.co.uk); spf=pass (google.com: domain of linux-kernel+bounces-30158-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30158-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EC28B1C223CC for ; Thu, 18 Jan 2024 13:37:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78BAD2555A; Thu, 18 Jan 2024 13:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mev.co.uk header.i=@mev.co.uk header.b="UVDwdd11" Received: from smtp91.iad3b.emailsrvr.com (smtp91.iad3b.emailsrvr.com [146.20.161.91]) (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 211BF1E531 for ; Thu, 18 Jan 2024 13:37:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=146.20.161.91 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705585043; cv=none; b=ad/CET2CwNqX9fxUu5P4TnNsaKJ0Xw4sMrOy19PBjTjuthMtzxg/BHi1kF0q7AbO+gm/SIdti8p6Stb8KkBLUD1ZYCBGCFK2Ywkp2YsfoE3M/15fEScPoLmbdJx9UBJoUd9eZHtPaScIuSgsG1NST38qhEbGyOmCEUoVjDlbHKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705585043; c=relaxed/simple; bh=mXbhgCRiRp5xRyUf9RHxphlLEbt4CPMBAZblbL0e3ms=; h=DKIM-Signature:X-Auth-ID:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From: Organization:In-Reply-To:Content-Type:Content-Transfer-Encoding: X-Classification-ID; b=C79bZ2VIHpZaFc4veHRhMEwNF4VmHuRJNH/f1WIA4y4spcjvdp3v+hDs8n4tbWYyRAZgK6f9gF+t7eOQjLxhL0VT1DC1OBOu+7Ua4bZXryv+iwZKcre17IngDjrrXtQcE5CJvJCEMKYhrfcFkkp5IWsNTTMv1Z+Ys3A670idkeo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mev.co.uk; spf=pass smtp.mailfrom=mev.co.uk; dkim=pass (1024-bit key) header.d=mev.co.uk header.i=@mev.co.uk header.b=UVDwdd11; arc=none smtp.client-ip=146.20.161.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mev.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mev.co.uk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1705576280; bh=mXbhgCRiRp5xRyUf9RHxphlLEbt4CPMBAZblbL0e3ms=; h=Date:Subject:To:From:From; b=UVDwdd11HZBATTYkvTjJBkt2gDMiUA1xvCW/586+YsyRZZSLp3xWJeSt0YxD3PyLQ /pg56IDpprZIpL765MIbg+U9zTntPcKPo2kyEdxCryUVGeTdzPubcAqp2GAvCoxFzA 7oJYyh4t2xbODpYvkoWgkLLJkgSMBPpebnpBzUVs= X-Auth-ID: abbotti@mev.co.uk Received: by smtp4.relay.iad3b.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 808D720071; Thu, 18 Jan 2024 06:11:19 -0500 (EST) Message-ID: Date: Thu, 18 Jan 2024 11:11:18 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow To: Greg Kroah-Hartman , Denis Arefev Cc: H Hartley Sweeten , open list , lvc-project@linuxtesting.org References: <20240118073619.40538-1-arefev@swemel.ru> <2024011831-morphine-showroom-bc8f@gregkh> Content-Language: en-GB From: Ian Abbott Organization: MEV Ltd. In-Reply-To: <2024011831-morphine-showroom-bc8f@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Classification-ID: 337302d2-9ce4-4154-b6ec-dfafa35740e1-1-1 On 18/01/2024 09:32, Greg Kroah-Hartman wrote: > 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 >> Signed-off-by: Denis Arefev >> --- >> 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? The period_ns value comes from user-space and could be any unsigned int value. It's used to let the driver know the period of an external clock source. > And what commit id does this fix? Fixes: 3e90b1c7ebe9 ("staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers") Cc: # v5.15+ The first affected kernel version is v3.17. This patch should apply cleanly to v5.13 onwards (when comedi was moved out of drivers/staging), but earlier stable/longterm kernels would require a backported patch. @Denis, if you could add the above Fixes: and Cc: lines to a v2 patch, that would be great! > > thanks, > > greg k-h -- -=( Ian Abbott || 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 )=-