lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250127.143703.343581919278286700.syoshida@redhat.com>
Date: Mon, 27 Jan 2025 14:37:03 +0900 (JST)
From: Shigeru Yoshida <syoshida@...hat.com>
To: martin.lau@...ux.dev, stfomichev@...il.com
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
 eddyz87@...il.com, song@...nel.org, yonghong.song@...ux.dev,
 john.fastabend@...il.com, kpsingh@...nel.org, sdf@...ichev.me,
 haoluo@...gle.com, jolsa@...nel.org, davem@...emloft.net,
 edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com, horms@...nel.org,
 hawk@...nel.org, lorenzo@...nel.org, toke@...hat.com, bpf@...r.kernel.org,
 netdev@...r.kernel.org
Subject: Re: [PATCH bpf v2 2/2] selftests/bpf: Adjust data size to have
 ETH_HLEN

On Fri, 24 Jan 2025 11:22:16 -0800, Martin KaFai Lau wrote:
> On 1/23/25 6:45 PM, Stanislav Fomichev wrote:
>> On 01/23, Martin KaFai Lau wrote:
>>> 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@...hat.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.
>> Ah, yes, you're right, I missed the remaining parts that make sure
>> the redirect happens
> 
> Thanks for confirming and the review.
> 
> Applied the fix.

Hi Martin, Stanislav,

Thank you for your comments and feedback!

> Shigeru, please followup with a selftest to test the "less than
> ETH_HLEN" bug addressed in Patch 1. You can reuse some of the
> boilerplate codes from the xdp_cpumap_attach.c. The bpf prog can
> simply be "return XDP_PASS;" and ensure that
> BPF_F_TEST_XDP_LIVE_FRAMES is included in the
> bpf_test_run_opts. Thanks.

I'm not very familiar with bpf and its selftests, but I will try to
make a new test according to your advice.

Thanks,
Shigeru


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ