From: Stanislav Fomichev <stfomichev@gmail.com>
To: Yonghong Song <yonghong.song@linux.dev>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Fix two net related test failures with 64K page size
Date: Mon, 9 Jun 2025 15:55:10 -0700 [thread overview]
Message-ID: <aEdmTuCtAJ2D9gam@mini-arch> (raw)
In-Reply-To: <20250608165539.1020481-1-yonghong.song@linux.dev>
On 06/08, Yonghong Song wrote:
> When running BPF selftests on arm64 with a 64K page size, I encountered
> the following two test failures:
> sockmap_basic/sockmap skb_verdict change tail:FAIL
> tc_change_tail:FAIL
>
> With further debugging, I identified the root cause in the following
> kernel code within __bpf_skb_change_tail():
>
> u32 max_len = BPF_SKB_MAX_LEN;
> u32 min_len = __bpf_skb_min_len(skb);
> int ret;
>
> if (unlikely(flags || new_len > max_len || new_len < min_len))
> return -EINVAL;
>
> With a 4K page size, new_len = 65535 and max_len = 16064, the function
> returns -EINVAL. However, With a 64K page size, max_len increases to
> 261824, allowing execution to proceed further in the function. This is
> because BPF_SKB_MAX_LEN scales with the page size and larger page sizes
> result in higher max_len values.
>
> Updating the new_len parameter in both tests from 65535 to 262143 (0x3ffff)
> resolves the failures.
>
> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
> ---
> tools/testing/selftests/bpf/progs/test_sockmap_change_tail.c | 2 +-
> tools/testing/selftests/bpf/progs/test_tc_change_tail.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_sockmap_change_tail.c b/tools/testing/selftests/bpf/progs/test_sockmap_change_tail.c
> index 2796dd8545eb..4f7f08364c75 100644
> --- a/tools/testing/selftests/bpf/progs/test_sockmap_change_tail.c
> +++ b/tools/testing/selftests/bpf/progs/test_sockmap_change_tail.c
> @@ -31,7 +31,7 @@ int prog_skb_verdict(struct __sk_buff *skb)
> change_tail_ret = bpf_skb_change_tail(skb, skb->len + 1, 0);
> return SK_PASS;
> } else if (data[0] == 'E') { /* Error */
> - change_tail_ret = bpf_skb_change_tail(skb, 65535, 0);
> + change_tail_ret = bpf_skb_change_tail(skb, 262143, 0);
> return SK_PASS;
> }
> return SK_PASS;
> diff --git a/tools/testing/selftests/bpf/progs/test_tc_change_tail.c b/tools/testing/selftests/bpf/progs/test_tc_change_tail.c
> index 28edafe803f0..b1057fda58a0 100644
> --- a/tools/testing/selftests/bpf/progs/test_tc_change_tail.c
> +++ b/tools/testing/selftests/bpf/progs/test_tc_change_tail.c
> @@ -94,7 +94,7 @@ int change_tail(struct __sk_buff *skb)
> bpf_skb_change_tail(skb, len, 0);
> return TCX_PASS;
> } else if (payload[0] == 'E') { /* Error */
> - change_tail_ret = bpf_skb_change_tail(skb, 65535, 0);
> + change_tail_ret = bpf_skb_change_tail(skb, 262143, 0);
> return TCX_PASS;
> } else if (payload[0] == 'Z') { /* Zero */
> change_tail_ret = bpf_skb_change_tail(skb, 0, 0);
nit: this seems to be exercising BPF_SKB_MAX_LEN case. To make it easier to
spot in the future, can we do the following in both tests?
#define PAGE_SIZE 65536 /* make it work on 64K page arches */
#define BPF_SKB_MAX_LEN (PAGE_SIZE << 2)
... = bpf_skb_change_tail(skb, BPF_SKB_MAX_LEN, 0);
next prev parent reply other threads:[~2025-06-09 22:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-08 16:55 [PATCH bpf-next 1/2] bpf: Fix an issue in bpf_prog_test_run_xdp when page size greater than 4K Yonghong Song
2025-06-08 16:55 ` [PATCH bpf-next 2/2] selftests/bpf: Fix two net related test failures with 64K page size Yonghong Song
2025-06-09 22:55 ` Stanislav Fomichev [this message]
2025-06-10 1:24 ` Yonghong Song
2025-06-09 22:45 ` [PATCH bpf-next 1/2] bpf: Fix an issue in bpf_prog_test_run_xdp when page size greater than 4K Stanislav Fomichev
2025-06-10 1:31 ` Yonghong Song
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=aEdmTuCtAJ2D9gam@mini-arch \
--to=stfomichev@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--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