WSL2-Linux-Kernel/drivers/media/tuners
Gui-Dong Han fec5181960 media: xc4000: Fix atomicity violation in xc4000_get_frequency
[ Upstream commit 36d503ad547d1c75758a6fcdbec2806f1b6aeb41 ]

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, BassCheck[1]. 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.

[1] https://sites.google.com/view/basscheck/

Fixes: 4c07e32884 ("[media] xc4000: Fix get_frequency()")
Cc: stable@vger.kernel.org
Reported-by: BassCheck <bass@buaa.edu.cn>
Signed-off-by: Gui-Dong Han <2045gemini@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-10 16:18:34 +02:00
..
Kconfig media: tuners: Kconfig: add some missing VIDEO_V4L2 dependencies 2020-04-23 07:57:27 +02:00
Makefile
e4000.c
e4000.h
e4000_priv.h
fc001x-common.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
fc0011.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
fc0011.h
fc0012-priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
fc0012.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
fc0012.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
fc0013-priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
fc0013.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
fc0013.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
fc2580.c
fc2580.h
fc2580_priv.h
it913x.c media: tuners/it913x.c: fix missing error code 2021-01-27 08:33:01 +01:00
it913x.h media: media tuner headers: fix kernel-doc warnings 2021-03-22 10:24:27 +01:00
m88rs6000t.c media: m88rs6000t: avoid potential out-of-bounds reads on arrays 2021-03-22 17:41:39 +01:00
m88rs6000t.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
max2165.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
max2165.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
max2165_priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mc44s803.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
mc44s803.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mc44s803_priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
msi001.c media: msi001: fix possible null-ptr-deref in msi001_probe() 2022-01-27 11:03:36 +01:00
mt20xx.c
mt20xx.h
mt2060.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
mt2060.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mt2060_priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mt2063.c media: fix incorrect kernel doc usages 2021-03-11 11:59:44 +01:00
mt2063.h
mt2131.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
mt2131.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mt2131_priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mt2266.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
mt2266.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mxl301rf.c
mxl301rf.h
mxl5005s.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
mxl5005s.h
mxl5007t.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mxl5007t.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
qm1d1b0004.c
qm1d1b0004.h
qm1d1c0042.c media: qm1d1c0042: fix error return code in qm1d1c0042_init() 2021-01-27 12:59:17 +01:00
qm1d1c0042.h
qt1010.c media: tuners: qt1010: replace BUG_ON with a regular error 2023-09-23 11:09:58 +02:00
qt1010.h media: media tuner headers: fix kernel-doc warnings 2021-03-22 10:24:27 +01:00
qt1010_priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
r820t.c
r820t.h
si2157.c media: si2157: Fix "warm" tuner state detection 2022-01-27 11:03:30 +01:00
si2157.h media: si2157: Add option for not downloading firmware. 2019-10-10 07:07:14 -03:00
si2157_priv.h media: si2157: Add analog tuning related functions 2020-04-21 16:46:25 +02:00
tda827x.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tda827x.h media: media tuner headers: fix kernel-doc warnings 2021-03-22 10:24:27 +01:00
tda8290.c
tda8290.h
tda9887.c
tda9887.h
tda18212.c
tda18212.h
tda18218.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
tda18218.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tda18218_priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tda18250.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tda18250.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tda18250_priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tda18271-common.c
tda18271-fe.c media: Use fallthrough pseudo-keyword 2020-08-29 08:35:27 +02:00
tda18271-maps.c
tda18271-priv.h
tda18271.h
tea5761.c
tea5761.h
tea5767.c
tea5767.h
tua9001.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tua9001.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tua9001_priv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
tuner-i2c.h media: tuners: fix error return code of hybrid_tuner_request_state() 2021-03-22 10:21:03 +01:00
tuner-simple.c media: tuner-simple: fix regression in simple_set_radio_freq 2020-08-26 18:51:50 +02:00
tuner-simple.h
tuner-types.c
tuner-xc2028-types.h media: tuners: Use the correct style for SPDX License Identifier 2019-10-24 18:57:55 -03:00
tuner-xc2028.c media: media/tuners: Use kmemdup rather than duplicating its implementation 2019-08-14 05:03:11 -03:00
tuner-xc2028.h media: tuners: Use the correct style for SPDX License Identifier 2019-10-24 18:57:55 -03:00
xc4000.c media: xc4000: Fix atomicity violation in xc4000_get_frequency 2024-04-10 16:18:34 +02:00
xc4000.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
xc5000.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
xc5000.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00