From: sashiko-bot@kernel.org
To: "Dong Chenchen" <dongchenchen2@huawei.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net 2/2] selftests/bpf: cover sockmap drop after partial TCP read
Date: Fri, 03 Jul 2026 14:01:22 +0000 [thread overview]
Message-ID: <20260703140124.509411F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260702140959.1806754-3-dongchenchen2@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The test `test_sockmap_drop_after_partial_read` relies on asynchronous packet processing without any synchronization, making it inherently flaky.
--
commit 375b8cdbb19df93db8af9c80a28cbeb5b3bdb312
Author: Dong Chenchen <dongchenchen2@huawei.com>
selftests/bpf: cover sockmap drop after partial TCP read
This commit adds a regression test for a TCP socket that is partially read
before it is inserted into a sockmap with an SK_DROP verdict. The test
sends an additional byte to drive the verdict path, removes the socket,
and checks sequence numbers via TCP_ZEROCOPY_RECEIVE.
> diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> index cb3229711f93a..106dd03cde84e 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
[ ... ]
> +static void test_sockmap_drop_after_partial_read(void)
> +{
[ ... ]
> + err = bpf_map_update_elem(map, &zero, &p0, BPF_NOEXIST);
> + if (!ASSERT_OK(err, "bpf_map_update_elem"))
> + goto end;
> +
> + sent = xsend(c0, buf, 1, 0);
> + if (!ASSERT_EQ(sent, 1, "xsend(drop)"))
> + goto end;
> +
> + err = bpf_map_delete_elem(map, &zero);
[Severity: Medium]
Will this map deletion race with the asynchronous packet processing?
Because TCP delivery and BPF program execution occur asynchronously in softirq
context, the map deletion might remove the socket from the map before the
queued byte is processed and dropped by the BPF program.
If that happens, the byte could bypass the SK_DROP verdict and be delivered
normally. This would add an unexpected byte to the receive queue, causing the
subsequent TCP_ZEROCOPY_RECEIVE step to copy 2 bytes instead of 1, which fails
the final ASSERT_EQ(zc.copybuf_len, 1, ...) assertion and leads to test
flakiness.
Is there a need for some form of synchronization here before deleting the map
element to ensure the packet is actually processed and dropped?
> + if (!ASSERT_OK(err, "bpf_map_delete_elem"))
> + goto end;
> +
> + sent = xsend(c0, buf, 1, 0);
> + if (!ASSERT_EQ(sent, 1, "xsend(native again)"))
> + goto end;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260702140959.1806754-1-dongchenchen2@huawei.com?part=2
prev parent reply other threads:[~2026-07-03 14:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 14:09 [PATCH net 0/2] bpf, sockmap: fix copied_seq after partial TCP read Dong Chenchen
2026-07-02 14:09 ` [PATCH net 1/2] bpf, sockmap: account only unread data in tcp_eat_skb Dong Chenchen
2026-07-03 14:01 ` sashiko-bot
2026-07-02 14:09 ` [PATCH net 2/2] selftests/bpf: cover sockmap drop after partial TCP read Dong Chenchen
2026-07-03 14:01 ` sashiko-bot [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=20260703140124.509411F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dongchenchen2@huawei.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