Re: [PATCH v2] lib/assoc_array: fix stale nr_leaves_on_tree after gc

From: David Howells

Date: Thu Mar 19 2026 - 13:10:42 EST


Josh Law <objecting@xxxxxxxxxxxxx> wrote:

> Well, the bug actually is there,

But is there a bug? The field is internal to assoc_array, and the assoc_array
code only accesses it if the caller is holding a lock to prevent other
modifications. The field is not pertinent to searching the tree under just
the RCU read lock.

> and if i made a mistake, this patch should atleast be hardening level, (As i
> say, better safe than sorry)

Your patch doesn't actually fix the issue; it merely slides the window. The
window *could* be closed on x86_64, say, by using CMPXCHG16 to change both the
root pointer and the counter simultaneously, but beyond that you can't close
it without using a lock.

David