linux/drivers/block/drbd
Qiu-ji Chen 2f02b5af3a drbd: Fix atomicity violation in drbd_uuid_set_bm()
The violation of atomicity occurs when the drbd_uuid_set_bm function is
executed simultaneously with modifying the value of
device->ldev->md.uuid[UI_BITMAP]. Consider a scenario where, while
device->ldev->md.uuid[UI_BITMAP] passes the validity check when its
value is not zero, the value of device->ldev->md.uuid[UI_BITMAP] is
written to zero. In this case, the check in drbd_uuid_set_bm might refer
to the old value of device->ldev->md.uuid[UI_BITMAP] (before locking),
which allows an invalid value to pass the validity check, resulting in
inconsistency.

To address this issue, it is recommended to include the data validity
check within the locked section of the function. This modification
ensures that the value of device->ldev->md.uuid[UI_BITMAP] does not
change during the validation process, thereby maintaining its integrity.

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.

Fixes: 9f2247bb9b ("drbd: Protect accesses to the uuid set with a spinlock")
Cc: stable@vger.kernel.org
Signed-off-by: Qiu-ji Chen <chenqiuji666@gmail.com>
Reviewed-by: Philipp Reisner <philipp.reisner@linbit.com>
Link: https://lore.kernel.org/r/20240913083504.10549-1-chenqiuji666@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2024-09-18 04:16:23 -06:00
..
drbd_actlog.c drbd: actlog: fix kernel-doc warnings and spelling 2023-12-22 07:18:35 -07:00
drbd_bitmap.c drbd: use __bio_add_page to add page to bio 2023-05-31 09:50:02 -06:00
drbd_buildtag.c drbd: split off drbd_config into separate file 2023-01-29 15:18:33 -07:00
drbd_debugfs.c drbd: drop API_VERSION define 2023-01-29 15:18:33 -07:00
drbd_debugfs.h drbd: use consistent license 2022-11-22 19:38:39 -07:00
drbd_int.h drbd: Remove an unused field in struct drbd_device 2024-08-26 07:15:53 -06:00
drbd_interval.c drbd: drbd_insert_interval(): Clarify comment 2023-01-29 15:18:33 -07:00
drbd_interval.h drbd: use consistent license 2022-11-22 19:38:39 -07:00
drbd_main.c drbd: Fix atomicity violation in drbd_uuid_set_bm() 2024-09-18 04:16:23 -06:00
drbd_nl.c for-6.9/block-20240310 2024-03-11 11:43:44 -07:00
drbd_nla.c drbd: use consistent license 2022-11-22 19:38:39 -07:00
drbd_nla.h drbd: use consistent license 2022-11-22 19:38:39 -07:00
drbd_polymorph_printk.h drbd: add context parameter to expect() macro 2022-12-01 11:33:49 -07:00
drbd_proc.c drbd: drop API_VERSION define 2023-01-29 15:18:33 -07:00
drbd_protocol.h drbd: use consistent license 2022-11-22 19:38:39 -07:00
drbd_receiver.c drbd: stop defining __KERNEL_SYSCALLS__ 2023-06-05 10:45:25 -06:00
drbd_req.c drbd: Pass a peer device to the resync and online verify functions 2023-04-01 20:27:55 -06:00
drbd_req.h drbd: pass drbd_peer_device to __req_mod 2023-04-01 20:27:55 -06:00
drbd_state_change.h drbd: fix function cast warnings in state machine 2024-02-13 08:55:40 -07:00
drbd_state.c drbd: Add NULL check for net_conf to prevent dereference in state validation 2024-09-10 13:44:06 -06:00
drbd_state.h drbd: use consistent license 2022-11-22 19:38:39 -07:00
drbd_strings.c drbd: use consistent license 2022-11-22 19:38:39 -07:00
drbd_strings.h drbd: use consistent license 2022-11-22 19:38:39 -07:00
drbd_vli.h drbd: remove unnecessary assignment in vli_encode_bits 2023-01-29 15:18:33 -07:00
drbd_worker.c drbd: Pass a peer device to the resync and online verify functions 2023-04-01 20:27:55 -06:00
Kconfig drbd: use consistent license 2022-11-22 19:38:39 -07:00
Makefile drbd: split off drbd_buildtag into separate file 2023-01-29 15:18:33 -07:00