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
fc0011.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
fc0011.h
fc0012-priv.h
fc0012.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
fc0012.h
fc0013-priv.h
fc0013.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
fc0013.h
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
max2165.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
max2165.h
max2165_priv.h
mc44s803.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
mc44s803.h
mc44s803_priv.h
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
mt2060_priv.h
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
mt2131_priv.h
mt2266.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
mt2266.h
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
mxl5007t.h
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
r820t.c
r820t.h
si2157.c media: si2157: Fix "warm" tuner state detection 2022-01-27 11:03:30 +01:00
si2157.h
si2157_priv.h media: si2157: Add analog tuning related functions 2020-04-21 16:46:25 +02:00
tda827x.c
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
tda18218_priv.h
tda18250.c
tda18250.h
tda18250_priv.h
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
tua9001.h
tua9001_priv.h
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
tuner-xc2028.c
tuner-xc2028.h
xc4000.c media: xc4000: Fix atomicity violation in xc4000_get_frequency 2024-04-10 16:18:34 +02:00
xc4000.h
xc5000.c media: dvb: symbol fixup for dvb_attach() 2023-09-19 12:22:51 +02:00
xc5000.h