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 <bass@xxxxxxxxxxx> > Signed-off-by: Gui-Dong Han <2045gemini@xxxxxxxxx> > --- > 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