mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 08:44:21 +08:00
da9065caa5
In min_key_size_set():
if (val > hdev->le_max_key_size || val < SMP_MIN_ENC_KEY_SIZE)
return -EINVAL;
hci_dev_lock(hdev);
hdev->le_min_key_size = val;
hci_dev_unlock(hdev);
In max_key_size_set():
if (val > SMP_MAX_ENC_KEY_SIZE || val < hdev->le_min_key_size)
return -EINVAL;
hci_dev_lock(hdev);
hdev->le_max_key_size = val;
hci_dev_unlock(hdev);
The atomicity violation occurs due to concurrent execution of set_min and
set_max funcs.Consider a scenario where setmin writes a new, valid 'min'
value, and concurrently, setmax writes a value that is greater than the
old 'min' but smaller than the new 'min'. In this case, setmax might check
against the old 'min' value (before acquiring the lock) but write its
value after the 'min' has been updated by setmin. This leads to a
situation where the 'max' value ends up being smaller than the 'min'
value, which is an inconsistency.
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 5.17.
To resolve this issue, it is suggested to encompass the validity checks
within the locked sections in both set_min and set_max funcs. The
modification ensures that the validation of 'val' against the
current min/max values is atomic, thus maintaining the integrity of the
settings. With this patch applied, our tool no longer reports the 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:
|
||
---|---|---|
.. | ||
bnep | ||
cmtp | ||
hidp | ||
rfcomm | ||
6lowpan.c | ||
a2mp.c | ||
a2mp.h | ||
af_bluetooth.c | ||
amp.c | ||
amp.h | ||
aosp.c | ||
aosp.h | ||
coredump.c | ||
ecdh_helper.c | ||
ecdh_helper.h | ||
eir.c | ||
eir.h | ||
hci_codec.c | ||
hci_codec.h | ||
hci_conn.c | ||
hci_core.c | ||
hci_debugfs.c | ||
hci_debugfs.h | ||
hci_event.c | ||
hci_request.c | ||
hci_request.h | ||
hci_sock.c | ||
hci_sync.c | ||
hci_sysfs.c | ||
iso.c | ||
Kconfig | ||
l2cap_core.c | ||
l2cap_sock.c | ||
leds.c | ||
leds.h | ||
lib.c | ||
Makefile | ||
mgmt_config.c | ||
mgmt_config.h | ||
mgmt_util.c | ||
mgmt_util.h | ||
mgmt.c | ||
msft.c | ||
msft.h | ||
sco.c | ||
selftest.c | ||
selftest.h | ||
smp.c | ||
smp.h |