From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org, ast@kernel.org,
andrii@kernel.org, daniel@iogearbox.net, kafai@meta.com,
kernel-team@meta.com, eddyz87@gmail.com, memxor@gmail.com,
herbert@gondor.apana.org.au
Cc: yatsenko@meta.com, martin.lau@kernel.org,
yonghong.song@linux.dev, clm@meta.com, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v4 05/11] bpf: Allow special fields in resizable hashtab
Date: Thu, 14 May 2026 12:00:20 +0100 [thread overview]
Message-ID: <77fb2a01-5318-4e7e-973d-aefcfaa71a8b@gmail.com> (raw)
In-Reply-To: <252dc423a3bc75b3f4d936e7706085da71939a88a7ef148926c317d463d20a12@mail.kernel.org>
On 5/14/26 12:21 AM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
>> index 61eb88cb9229..9cc41850dc79 100644
>> --- a/kernel/bpf/hashtab.c
>> +++ b/kernel/bpf/hashtab.c
>
> [ ... ]
>
>> @@ -2943,6 +2965,7 @@ static int rhtab_map_lookup_and_delete_elem(struct bpf_map *map, void *key, void
>> static long rhtab_map_update_existing(struct bpf_map *map, struct rhtab_elem *elem, void *value,
>> u64 map_flags)
>> {
>> + struct bpf_rhtab *rhtab = container_of(map, struct bpf_rhtab, map);
>> void *old_val = rhtab_elem_value(elem, map->key_size);
>>
>> if (map_flags & BPF_NOEXIST)
>> @@ -2952,6 +2975,13 @@ static long rhtab_map_update_existing(struct bpf_map *map, struct rhtab_elem *el
>> copy_map_value_locked(map, old_val, value, false);
>> else
>> copy_map_value(map, old_val, value);
>> +
>> + /*
>> + * copy_map_value() skips special-field offsets, so old timers/
>> + * kptrs/etc. still sit in the slot. Cancel them after the copy
>> + * to match arraymap's update semantics.
>> + */
>> + rhtab_check_and_free_fields(rhtab, elem);
>> return 0;
>> }
>
> Could calling rhtab_check_and_free_fields() after copy_map_value() create
> a race with concurrent BPF programs?
Same as arraymap, yes, there is a race.
>
> When copy_map_value() skips special field offsets, the old timer/kptr/etc.
> remains active in the slot during the copy. If a concurrent program acquires
> the spinlock (in the BPF_F_LOCK case via copy_map_value_locked) or just
> accesses the value between copy and free operations, couldn't it still use
> those special fields even after rhtab_check_and_free_fields() cancels them?
>
> In v3 of this series, sashiko-bot raised this concern about the ordering
> of these operations. While the patch moved rhtab_check_and_free_fields()
> to occur after the copy (matching arraymap semantics), the fundamental
> timing window between copy and free still allows concurrent access to
> special fields that are about to be canceled.
>
> [ ... ]
>
> Commit message:
>
>> bpf: Allow special fields in resizable hashtab
>>
>> Add support for timers, workqueues, task work and spin locks.
>> Without this, users needing deferred callbacks or BPF_F_LOCK in a
>> dynamically-sized map have no option - fixed-size htab is the only
>> map supporting these field types. Resizable hashtab should offer the
>> same capability.
>>
>> Properly clean up BTF record fields on element delete and map
>> teardown by wiring up bpf_obj_free_fields through a memory allocator
>> destructor, matching the pattern used by htab for non-prealloc maps.
>>
>> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
>
> This looks like a bug fix for resizable hashtab support. Should this
> include:
>
> Fixes: 9cf2facd6b40 ("bpf: Implement resizable hashmap basic functions")
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/25830929099
next prev parent reply other threads:[~2026-05-14 11:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 22:36 [PATCH bpf-next v4 00/11] bpf: Introduce resizable hash map Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 01/11] rhashtable: Add rhashtable_next_key() API Mykyta Yatsenko
2026-05-13 23:21 ` bot+bpf-ci
2026-05-13 22:36 ` [PATCH bpf-next v4 02/11] rhashtable: Add selftest for rhashtable_next_key() Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 03/11] bpf: Implement resizable hashmap basic functions Mykyta Yatsenko
2026-05-13 23:21 ` bot+bpf-ci
2026-05-14 10:59 ` Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 04/11] bpf: Implement iteration ops for resizable hashtab Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 05/11] bpf: Allow special fields in " Mykyta Yatsenko
2026-05-13 23:21 ` bot+bpf-ci
2026-05-14 11:00 ` Mykyta Yatsenko [this message]
2026-05-13 22:36 ` [PATCH bpf-next v4 06/11] bpf: Optimize word-sized keys for resizable hashtable Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 07/11] libbpf: Support " Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 08/11] selftests/bpf: Add basic tests for resizable hash map Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 09/11] selftests/bpf: Add BPF iterator " Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 10/11] bpftool: Add rhash map documentation Mykyta Yatsenko
2026-05-13 22:36 ` [PATCH bpf-next v4 11/11] selftests/bpf: Add resizable hashmap to benchmarks Mykyta Yatsenko
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=77fb2a01-5318-4e7e-973d-aefcfaa71a8b@gmail.com \
--to=mykyta.yatsenko5@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=ihor.solodrai@linux.dev \
--cc=kafai@meta.com \
--cc=kernel-team@meta.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
--cc=yatsenko@meta.com \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.