[Devel] [PATCH hci-8.1 v4 07/11] dm-ploop: take bat_lock around md page lookup in ploop_llseek_hole()
Alexander Ivanov
alexander.ivanov at virtuozzo.com
Mon Oct 12 16:26:42 MSK 2026
ploop_llseek_hole() walks the md pages tree without any lock, while
resize inserts new md pages into it in ploop_add_md_pages(). A lookup
racing with rb-tree rebalancing may follow a stale pointer or miss the
page and return -EINVAL.
https://virtuozzo.atlassian.net/browse/VSTOR-148171
Feature: dm-ploop: ploop target driver
Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
---
drivers/md/dm-ploop-map.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 92ceadf41b42..691284a239df 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -2772,7 +2772,11 @@ loff_t ploop_llseek_hole(struct dm_target *ti, loff_t offset, int whence)
while (clu < READ_ONCE(ploop->nr_bat_entries)) {
if (id != ploop_bat_clu_to_page_nr(clu)) {
id = ploop_bat_clu_to_page_nr(clu);
+
+ spin_lock_irq(&ploop->bat_lock);
md = ploop_md_page_find(ploop, id);
+ spin_unlock_irq(&ploop->bat_lock);
+
if (!md)
return -EINVAL;
}
--
2.53.0
More information about the Devel
mailing list