From: sashiko-bot@kernel.org
To: chenyuan_fl@163.com
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 1/4] bpf: Cancel special fields in resizable hashtab on recycle
Date: Tue, 01 Sep 2026 06:49:00 +0000 [thread overview]
Message-ID: <20260901064901.0286F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901062845.1379760-2-chenyuan_fl@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing bpf_obj_free_fields() when overwriting a map value in rhtab_map_update_existing(), violating the BPF-001 guideline.
--
commit a386d962d0ebafb2260b7ce5bf02d3879316b1e8
Author: Yuan Chen <chenyuan@kylinos.cn>
bpf: Cancel special fields in resizable hashtab on recycle
This patch updates the resizable hashtab to use bpf_obj_cancel_fields()
instead of eagerly calling bpf_obj_free_fields() on recycle and update
paths. This is intended to prevent running kptr destructors in NMI context.
> diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
> index d40cb5dd446ca..aaedda3730f37 100644
> --- a/kernel/bpf/hashtab.c
> +++ b/kernel/bpf/hashtab.c
[ ... ]
> @@ -3022,10 +3013,12 @@ static long rhtab_map_update_existing(struct bpf_map *map, struct rhtab_elem *el
> * BPF_F_LOCK, matching arraymap semantics.
> *
> * 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.
> + * kptrs/etc. still sit in the slot. Cancel the NMI-safe ones after
> + * the copy to match arraymap's update semantics; referenced kptrs
> + * stay attached and are destroyed by rhtab_mem_dtor().
> */
> - rhtab_check_and_free_fields(rhtab, elem);
> + bpf_obj_cancel_fields(&rhtab->map,
> + rhtab_elem_value(elem, rhtab->map.key_size));
[Severity: High]
Does replacing this cleanup cause a resource leak during map updates?
According to the BPF subsystem guidelines, when copy_map_value() overwrites
an existing map value, bpf_obj_free_fields() must be called to release
resources held by the old value.
Since the patch removes the underlying bpf_obj_free_fields() call in
rhtab_map_update_existing() and substitutes it with bpf_obj_cancel_fields(),
it appears kptr references might leak when a map value is updated in place.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901062845.1379760-1-chenyuan_fl@163.com?part=1
next prev parent reply other threads:[~2026-09-01 6:49 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 9:55 [PATCH bpf-next 0/2] bpf: Cancel special fields in resizable hashtab on recycle chenyuan_fl
2026-08-11 9:55 ` [PATCH bpf-next 1/2] " chenyuan_fl
2026-08-11 10:50 ` bot+bpf-ci
2026-08-11 9:55 ` [PATCH bpf-next 2/2] selftests/bpf: Test rhtab kptr recycle from NMI context chenyuan_fl
2026-08-11 11:08 ` bot+bpf-ci
2026-08-11 14:22 ` [PATCH bpf-next 0/2] bpf: Cancel special fields in resizable hashtab on recycle Kumar Kartikeya Dwivedi
2026-08-24 14:36 ` [PATCH bpf-next v2 0/4] " chenyuan_fl
2026-08-24 14:36 ` [PATCH 1/4] " chenyuan_fl
2026-08-24 15:00 ` sashiko-bot
2026-08-24 15:42 ` bot+bpf-ci
2026-08-24 16:15 ` Mykyta Yatsenko
2026-09-01 6:28 ` [PATCH bpf-next v3 0/4] " chenyuan_fl
2026-09-01 6:28 ` [PATCH bpf-next v3 1/4] " chenyuan_fl
2026-09-01 6:49 ` sashiko-bot [this message]
2026-09-01 7:37 ` bot+bpf-ci
2026-09-01 16:57 ` Mykyta Yatsenko
2026-09-01 6:28 ` [PATCH bpf-next v3 2/4] bpf: Fix use-after-free of program BTF in mem-alloc destructor chenyuan_fl
2026-09-01 17:10 ` Mykyta Yatsenko
2026-09-01 6:28 ` [PATCH bpf-next v3 3/4] selftests/bpf: Test rhtab kptr recycle from NMI context chenyuan_fl
2026-09-01 6:40 ` sashiko-bot
2026-09-01 7:37 ` bot+bpf-ci
2026-09-01 6:28 ` [PATCH bpf-next v3 4/4] selftests/bpf: Test rhtab special-field combinations chenyuan_fl
2026-09-01 6:41 ` sashiko-bot
2026-09-01 7:37 ` bot+bpf-ci
2026-09-04 10:49 ` [PATCH bpf-next v3 0/4] bpf: Cancel special fields in resizable hashtab on recycle Kumar Kartikeya Dwivedi
2026-08-24 14:36 ` [PATCH 2/4] bpf: Fix use-after-free of program BTF in mem-alloc destructor chenyuan_fl
2026-08-24 15:17 ` sashiko-bot
2026-08-24 15:42 ` bot+bpf-ci
2026-08-24 14:36 ` [PATCH 3/4] selftests/bpf: Test rhtab kptr recycle from NMI context chenyuan_fl
2026-08-24 15:28 ` sashiko-bot
2026-08-24 15:42 ` bot+bpf-ci
2026-08-24 14:36 ` [PATCH 4/4] selftests/bpf: Test rhtab special-field combinations chenyuan_fl
2026-08-24 15:40 ` sashiko-bot
2026-08-24 15:42 ` bot+bpf-ci
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=20260901064901.0286F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyuan_fl@163.com \
--cc=sashiko-reviews@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox