An RCU reader in xas_find_marked() can select a marked slot and move xa_index to it. A concurrent multi-index store can then replace that slot with a sibling. The reader sees the sibling, loops, and resolves it to its canonical slot. That leaves xa_offset behind xa_index and can return an entry already passed. xa_find_after() can mistake the result for a sibling of its starting entry and skip it. Once the search has selected a later marked slot, keep advancing when that slot has become a sibling. The next search starts after the slot already reached instead of resolving it to a lower canonical slot. RCU iteration may miss an entry changed concurrently, but must not move its cursor backwards or repeatedly return an old entry. Link: https://lore.kernel.org/r/20261127222110.3755894-1-heyheyco@gmail.com Signed-off-by: Andrew Morton Reported-by: Closes: Cc: Matthew Wilcox Cc: Qian Xiao lib/xarray.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/lib/xarray.c~xarray-fix-index-jumping-backwards-in-xas_find_marked-fix +++ a/lib/xarray.c @@ -1544,8 +1544,10 @@ void *xas_find_marked(struct xa_state *x entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) continue; - if (xa_is_sibling(entry)) + if (xa_is_sibling(entry)) { + advance = true; continue; + } if (!xa_is_node(entry)) return entry; if (xas->xa_offset != get_offset(xas->xa_index, xas->xa_node)) _