From: Josh Law <objecting@objecting.org>
To: David Howells <dhowells@redhat.com>
Cc: dhowells@redhat.com, Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] lib/assoc_array: fix stale nr_leaves_on_tree after gc
Date: Thu, 19 Mar 2026 15:15:09 +0000 [thread overview]
Message-ID: <971D421B-D22B-4C0F-AF6C-704CC95A9F02@objecting.org> (raw)
In-Reply-To: <4186139.1773929698@warthog.procyon.org.uk>
On 19 March 2026 14:14:58 GMT, David Howells <dhowells@redhat.com> wrote:
>Josh Law <objecting@objecting.org> wrote:
>
>> In assoc_array_gc(), assoc_array_apply_edit() publishes the new tree
>> root before nr_leaves_on_tree is updated, creating a window where the
>> tree is visible with a stale leaf count. Move the nr_leaves_on_tree
>> assignment before assoc_array_apply_edit() so the count is consistent
>> when the new root becomes visible.
>
>This just moves the window. The count is then inconsistent before the new
>root becomes visible.
>
>Note that there's no guarantee that nr_leaves_on_tree is stable if you're not
>locking against modification. Further, if you look in:
>
> Documentation/core-api/assoc_array.rst
>
>there's no mention of nr_leaves_on_tree being part of the API. Unfortunately,
>C doesn't allow me to put in a private: marker as C++ does.
>
>Note that neither assoc_array_iterate() nor assoc_array_find() make reference
>to the value.
>
>Are you actually seeing a problem stemming from this?
>
>David
>
Well, the bug actually is there, and if i made a mistake, this patch should atleast be hardening level, (As i say, better safe than sorry)
V/R
Josh Law
next prev parent reply other threads:[~2026-03-19 15:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 20:45 Josh Law
2026-03-19 14:14 ` David Howells
2026-03-19 15:15 ` Josh Law [this message]
2026-03-19 17:04 ` David Howells
2026-03-19 17:30 ` Josh Law
2026-03-19 19:25 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=971D421B-D22B-4C0F-AF6C-704CC95A9F02@objecting.org \
--to=objecting@objecting.org \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®