dm-switch: use WRITE_ONCE() in switch_region_table_write()
Subsystems (2)
PATCH 1/1 dm-switch: use WRITE_ONCE() in switch_region_table_write()
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().
Fixes 99eb1908e643 ("dm switch: factor out switch_region_table_read")
Signed-off-by Haotian Zhang <[email protected]>
--- drivers/md/dm-switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-switch.c +1 -1
@@ -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); }/*
Signature · 1 line
2.25.1