netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Stanislav Fomichev <stfomichev@gmail.com>,
	Shigeru Yoshida <syoshida@redhat.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev,
	john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
	haoluo@google.com, jolsa@kernel.org, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, hawk@kernel.org, lorenzo@kernel.org,
	toke@redhat.com, bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH bpf v2 2/2] selftests/bpf: Adjust data size to have ETH_HLEN
Date: Thu, 23 Jan 2025 14:09:09 -0800	[thread overview]
Message-ID: <5e342fea-764b-48a0-afda-4adfb504bd46@linux.dev> (raw)
In-Reply-To: <Z5KWE6J8OtRVCFDR@mini-arch>

On 1/23/25 11:18 AM, Stanislav Fomichev wrote:
> On 01/22, Shigeru Yoshida wrote:
>> The function bpf_test_init() now returns an error if user_size
>> (.data_size_in) is less than ETH_HLEN, causing the tests to
>> fail. Adjust the data size to ensure it meets the requirement of
>> ETH_HLEN.
>>
>> Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
>> ---
>>   .../testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c  | 4 ++--
>>   .../testing/selftests/bpf/prog_tests/xdp_devmap_attach.c  | 8 ++++----
>>   2 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c b/tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c
>> index c7f74f068e78..df27535995af 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c
>> @@ -52,10 +52,10 @@ static void test_xdp_with_cpumap_helpers(void)
>>   	ASSERT_EQ(info.id, val.bpf_prog.id, "Match program id to cpumap entry prog_id");
>>   
>>   	/* send a packet to trigger any potential bugs in there */
>> -	char data[10] = {};
>> +	char data[ETH_HLEN] = {};
>>   	DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
>>   			    .data_in = &data,
>> -			    .data_size_in = 10,
>> +			    .data_size_in = sizeof(data),
>>   			    .flags = BPF_F_TEST_XDP_LIVE_FRAMES,
>>   			    .repeat = 1,
>>   		);
> 
> We should still keep 10, but change the ASSERT_OK below to expect the
> error instead. Looking at the comment above, the purpose of the test
> is to exercise that error case.
> 

I think the bpf_prog_test_run_opts in this dev/cpumap test is to check the 
bpf_redirect_map() helper, so it expects the bpf_prog_test_run_opts to succeed.

It just happens the current data[10] cannot trigger the fixed bug because the 
bpf prog returns a XDP_REDIRECT instead of XDP_PASS, so xdp_recv_frames is not 
called.

To test patch 1, a separate test is probably needed to trigger the bug in 
xdp_recv_frames() with a bpf prog returning XDP_PASS.

  reply	other threads:[~2025-01-23 22:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21 15:06 [PATCH bpf v2 1/2] bpf, test_run: Fix use-after-free issue in eth_skb_pkt_type() Shigeru Yoshida
2025-01-21 15:06 ` [PATCH bpf v2 2/2] selftests/bpf: Adjust data size to have ETH_HLEN Shigeru Yoshida
2025-01-23 19:18   ` Stanislav Fomichev
2025-01-23 22:09     ` Martin KaFai Lau [this message]
2025-01-24  2:45       ` Stanislav Fomichev
2025-01-24 19:22         ` Martin KaFai Lau
2025-01-27  5:37           ` Shigeru Yoshida
2025-01-23 19:20 ` [PATCH bpf v2 1/2] bpf, test_run: Fix use-after-free issue in eth_skb_pkt_type() Stanislav Fomichev
2025-01-23 20:55 ` Daniel Borkmann
2025-01-24 19:20 ` patchwork-bot+netdevbpf

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=5e342fea-764b-48a0-afda-4adfb504bd46@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=haoluo@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=stfomichev@gmail.com \
    --cc=syoshida@redhat.com \
    --cc=toke@redhat.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;
as well as URLs for NNTP newsgroup(s).