Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp59990rdb; Thu, 21 Dec 2023 02:49:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYuG07ulJhpvZFKHgMimk8bCVaQTrvjWNX8yp+/2QywwpFjtst1qlatMpn+0+ALjIB9bjI X-Received: by 2002:a05:622a:18a9:b0:427:8cb2:2570 with SMTP id v41-20020a05622a18a900b004278cb22570mr2353360qtc.102.1703155768780; Thu, 21 Dec 2023 02:49:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703155768; cv=none; d=google.com; s=arc-20160816; b=WPWL/eB60+nuNQyVxf5XEA2acQuZsCqJK+i1/LQ7EyhC8RNlCLXPBsR+oeTfXTVGJ2 M2K8STIPjD1zd4WIvp1UuUnVzjQm1qyDbm99RdEkBJny6hS0/Wqd/nsmbtyXG6L1Aoim JMMHL+37HWlHH2MYrW3gB3hNMB0AiiBP6zOIgwY3AjnZXgrsOwEVgpvy7ywJt0ayPSq7 yW94nyOyFzYvHIYwqg3vtUkS6BchYJe5ASM7Lb7jlxNZb8KwansXRL/+Cenx7CUQqN99 9BQd5vZiLes1H2be0cbdLZAm/O8Y6Chv+dPJbhEQ9wqfcil6/ow7unByn8Ey9gYG+kz4 zUdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FMU6py/2LljKZt5ZuchdidlkES8T2C9OZxD/TRt//m0=; fh=HJle8y2vQqTcQD4OXy+ZYw8zi0s0LxZndqUcqiRY8gA=; b=RofIGX0FxxvEQTrqUO75siWa7za06THJ87W5yuE/HI3mSoOq1bPC0qNF0Z2cmbos4/ Joe+ZQr722GJnvKeX+lG9kuvghrPjyXOk089I5Bo5//cN3xYwNp/KafF0rW08uS7s2no QuEyQhAoziurfQFQ1W5V8b5Smc1b6GFwhk2rjyFyWUjBg8h/FYyCULVcySkTLfowXWoc dgm7e1xTTakyG47I4n98zI/aGxCW7qNA4U+O7xbF3yKeA5JOGiHJSlvldJ9pC7aDCVAf RrTfTnkwaRyA6+iYFVVW876YLBS4E3HF0LvY0qvJ/r0D5F1wbcYagm1AcdZ+ZGD21jRa ELeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZRA0brZT; spf=pass (google.com: domain of linux-kernel+bounces-8240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y15-20020a05622a004f00b004237122a705si1807678qtw.646.2023.12.21.02.49.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 02:49:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8240-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=@linuxfoundation.org header.s=korg header.b=ZRA0brZT; spf=pass (google.com: domain of linux-kernel+bounces-8240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org 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 6F5181C2493C for ; Thu, 21 Dec 2023 10:49:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 942D36D1C2; Thu, 21 Dec 2023 10:48:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ZRA0brZT" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A8AF16BB42; Thu, 21 Dec 2023 10:48:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1BDFC433CA; Thu, 21 Dec 2023 10:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1703155723; bh=xBJcV4OMhJoXl7qkczHc+1YvxJ1wQh6siGSG4yUXEO8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZRA0brZT7oL4W5exoi8DBZmdiZOjy00+FqDTtvp3UMcVo7QfReUkeMCGGIRdSKSIN X2bGUyCKEk5o9vG0N+NcmUSqDl8dvy2tiFQG83FSXgDCeEPc7klY4qqEcrhMOgJiE6 AxBcx5Er7LFjhJUhQ0gBWZbR0wbNBV9rbJ/OqdXw= Date: Thu, 21 Dec 2023 11:48:40 +0100 From: Greg KH To: Gui-Dong Han <2045gemini@gmail.com> Cc: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, mcgrof@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, baijiaju1990@outlook.com, BassCheck Subject: Re: [PATCH] [media] xc4000: Fix atomicity violation in xc4000_get_frequency Message-ID: <2023122130-unmindful-raider-637b@gregkh> References: <20231221103707.4129-1-2045gemini@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231221103707.4129-1-2045gemini@gmail.com> On Thu, Dec 21, 2023 at 06:37:07PM +0800, Gui-Dong Han wrote: > In xc4000_get_frequency(): > *freq = priv->freq_hz + priv->freq_offset; > The code accesses priv->freq_hz and priv->freq_offset without holding any > lock. > > In xc4000_set_params(): > // Code that updates priv->freq_hz and priv->freq_offset > ... > > xc4000_get_frequency() and xc4000_set_params() may execute concurrently, > risking inconsistent reads of priv->freq_hz and priv->freq_offset. Since > these related data may update during reading, it can result in incorrect > frequency calculation, leading to atomicity violations. > > This possible bug is found by an experimental static analysis tool > developed by our team. This tool analyzes the locking APIs to extract > function pairs that can be concurrently executed, and then analyzes the > instructions in the paired functions to identify possible concurrency bugs > including data races and atomicity violations. The above possible bug is > reported when our tool analyzes the source code of Linux 6.2. > > To address this issue, it is proposed to add a mutex lock pair in > xc4000_get_frequency() to ensure atomicity. With this patch applied, our > tool no longer reports the possible bug, with the kernel configuration > allyesconfig for x86_64. Due to the lack of associated hardware, we cannot > test the patch in runtime testing, and just verify it according to the > code logic. > > Fixes: 4c07e32884ab6 ("[media] xc4000: Fix get_frequency()") > Reported-by: BassCheck > Signed-off-by: Gui-Dong Han <2045gemini@gmail.com> > --- > drivers/media/tuners/xc4000.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > 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: - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve 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