From: Saket Kumar Bhaskar <skb99@linux.ibm.com>
To: bot+bpf-ci@kernel.org
Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, hbathini@linux.ibm.com,
sachinpb@linux.ibm.com, venkat88@linux.ibm.com,
andrii@kernel.org, eddyz87@gmail.com, ast@kernel.org,
daniel@iogearbox.net, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, shuah@kernel.org, martin.lau@kernel.org,
clm@meta.com, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v2] selftests/bpf: Fix htab_update/reenter_update selftest failure
Date: Fri, 14 Nov 2025 22:49:35 +0530 [thread overview]
Message-ID: <aRdkp7ztSM1JNZME@linux.ibm.com> (raw)
In-Reply-To: <3b15cc4d71bfa87ffcd49f69c1453d88c6457ef0c9c312c11b8a550f862e8f2b@mail.kernel.org>
On Fri, Nov 14, 2025 at 03:50:44PM +0000, bot+bpf-ci@kernel.org wrote:
> > diff --git a/tools/testing/selftests/bpf/prog_tests/htab_update.c b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > index 2bc85f481..96b65c1a3 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > @@ -15,17 +15,17 @@ struct htab_update_ctx {
> > static void test_reenter_update(void)
> > {
> > struct htab_update *skel;
> > - unsigned int key, value;
> > + void *value = NULL;
> > + unsigned int key, value_size;
> ^^^
>
> Is key supposed to be initialized? The old code had 'unsigned int key = 0,
> value = 0;' but the new code drops the initialization. Later uses of key
> at the bpf_map_update_elem() calls will pass uninitialized stack memory.
>
> > int err;
> >
> > skel = htab_update__open();
> > if (!ASSERT_OK_PTR(skel, "htab_update__open"))
> > return;
>
> [ ... ]
>
> > @@ -33,14 +33,32 @@ static void test_reenter_update(void)
> > if (!ASSERT_OK(err, "htab_update__attach"))
> > goto out;
> >
> > - /* Will trigger the reentrancy of bpf_map_update_elem() */
> > - key = 0;
> > - value = 0;
> > - err = bpf_map_update_elem(bpf_map__fd(skel->maps.htab), &key, &value, 0);
> > - if (!ASSERT_OK(err, "add element"))
> > + value_size = bpf_map__value_size(skel->maps.htab);
> > +
> > + value = calloc(1, value_size);
> > + if (!ASSERT_OK_PTR(value, "calloc value"))
> > + goto out;
> > + /*
> > + * First update: plain insert. This should NOT trigger the re-entrancy
> > + * path, because there is no old element to free yet.
> > + */
> > + err = bpf_map_update_elem(bpf_map__fd(skel->maps.htab), &key, &value, BPF_ANY);
> > + if (!ASSERT_OK(err, "first update (insert)"))
> > + goto out;
> > +
> > + /*
> > + * Second update: replace existing element with same key and trigger
> > + * the reentrancy of bpf_map_update_elem().
> > + * check_and_free_fields() calls bpf_obj_free_fields() on the old
> > + * value, which is where fentry program runs and performs a nested
> > + * bpf_map_update_elem(), triggering -EDEADLK.
> > + */
> > + memset(&value, 0, sizeof(value));
> ^^^^^^^
>
> Does this memset zero the allocated memory? It looks like this zeros the
> pointer variable itself (8 bytes) rather than the memory it points to.
> Should this be 'memset(value, 0, value_size)' instead?
>
> > + err = bpf_map_update_elem(bpf_map__fd(skel->maps.htab), &key, &value, BPF_ANY);
> > + if (!ASSERT_OK(err, "second update (replace)"))
> > goto out;
> >
> > - ASSERT_EQ(skel->bss->update_err, -EBUSY, "no reentrancy");
> > + ASSERT_EQ(skel->bss->update_err, -EDEADLK, "no reentrancy");
> > out:
> > htab_update__destroy(skel);
> > }
>
>
> ---
> 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/19369517166
Will fix these.
prev parent reply other threads:[~2025-11-14 17:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 15:26 [PATCH bpf-next v2] selftests/bpf: Fix htab_update/reenter_update selftest failure Saket Kumar Bhaskar
2025-11-14 15:50 ` bot+bpf-ci
2025-11-14 17:19 ` Saket Kumar Bhaskar [this message]
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=aRdkp7ztSM1JNZME@linux.ibm.com \
--to=skb99@linux.ibm.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=haoluo@google.com \
--cc=hbathini@linux.ibm.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=sachinpb@linux.ibm.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=venkat88@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox