summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaotian Zhang <vulab@iscas.ac.cn>2026-07-11 22:21:55 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-09-07 17:18:23 +0200
commit24a952786a5fb317e2cb1c057cd354546e7f5f33 (patch)
tree01e02df0079973d6d18464dd6a9b197426140e2a
parentc3f211b7a277dd404b4e7d23095be964b5b46a27 (diff)
downloadlinux-stable-24a952786a5fb317e2cb1c057cd354546e7f5f33.tar.gz
linux-stable-24a952786a5fb317e2cb1c057cd354546e7f5f33.zip
dm-switch: use WRITE_ONCE() in switch_region_table_write()
commit c7391ebe33162c7962b313caea4d8e6b0bc2a671 upstream. switch_region_table_read() accesses the region table with READ_ONCE() and is called from the lockless switch_map() IO path. However, switch_region_table_write() stores to the same array with a plain assignment. This results in an inconsistent access pattern for a lockless shared variable and may trigger data race reports. Use WRITE_ONCE() to pair with the existing READ_ONCE() in switch_region_table_read(). Cc: stable@vger.kernel.org Fixes: 99eb1908e643 ("dm switch: factor out switch_region_table_read") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/md/dm-switch.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/dm-switch.c b/drivers/md/dm-switch.c
index dfd9fb52a6f3..50e1c7211c37 100644
--- a/drivers/md/dm-switch.c
+++ b/drivers/md/dm-switch.c
@@ -184,7 +184,7 @@ static void switch_region_table_write(struct switch_ctx *sctx, unsigned long reg
pte = sctx->region_table[region_index];
pte &= ~((((region_table_slot_t)1 << sctx->region_table_entry_bits) - 1) << bit);
pte |= (region_table_slot_t)value << bit;
- sctx->region_table[region_index] = pte;
+ WRITE_ONCE(sctx->region_table[region_index], pte);
}
/*