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: <5dab3b98-9134-4ee9-8cd1-2498c3eab49e@huaweicloud.com>
Date: Thu, 30 Oct 2025 20:03:12 +0800
From: Xu Kuohai <xukuohai@...weicloud.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
 linux-kernel@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
 Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
 Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman
 <eddyz87@...il.com>, Yonghong Song <yhs@...com>, Song Liu <song@...nel.org>
Subject: Re: [PATCH bpf-next v3 2/3] selftests/bpf: Add overwrite mode test
 for BPF ring buffer

On 10/28/2025 10:47 AM, Andrii Nakryiko wrote:
> On Fri, Oct 17, 2025 at 9:04 PM Xu Kuohai <xukuohai@...weicloud.com> wrote:
>>
>> From: Xu Kuohai <xukuohai@...wei.com>
>>
>> Add overwrite mode test for BPF ring buffer. The test creates a BPF ring
>> buffer in overwrite mode, then repeatedly reserves and commits records
>> to check if the ring buffer works as expected both before and after
>> overwriting occurs.
>>
>> Signed-off-by: Xu Kuohai <xukuohai@...wei.com>
>> ---
>>   tools/testing/selftests/bpf/Makefile          |  3 +-
>>   .../selftests/bpf/prog_tests/ringbuf.c        | 64 ++++++++++++
>>   .../bpf/progs/test_ringbuf_overwrite.c        | 98 +++++++++++++++++++
>>   3 files changed, 164 insertions(+), 1 deletion(-)
>>   create mode 100644 tools/testing/selftests/bpf/progs/test_ringbuf_overwrite.c
>>
>> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
>> index f00587d4ede6..43d133bf514d 100644
>> --- a/tools/testing/selftests/bpf/Makefile
>> +++ b/tools/testing/selftests/bpf/Makefile
>> @@ -498,7 +498,8 @@ LINKED_SKELS := test_static_linked.skel.h linked_funcs.skel.h               \
>>
>>   LSKELS := fexit_sleep.c trace_printk.c trace_vprintk.c map_ptr_kern.c  \
>>          core_kern.c core_kern_overflow.c test_ringbuf.c                 \
>> -       test_ringbuf_n.c test_ringbuf_map_key.c test_ringbuf_write.c
>> +       test_ringbuf_n.c test_ringbuf_map_key.c test_ringbuf_write.c    \
>> +       test_ringbuf_overwrite.c
>>
>>   LSKELS_SIGNED := fentry_test.c fexit_test.c atomics.c
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf.c b/tools/testing/selftests/bpf/prog_tests/ringbuf.c
>> index d1e4cb28a72c..5264af1dc768 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/ringbuf.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/ringbuf.c
>> @@ -17,6 +17,7 @@
>>   #include "test_ringbuf_n.lskel.h"
>>   #include "test_ringbuf_map_key.lskel.h"
>>   #include "test_ringbuf_write.lskel.h"
>> +#include "test_ringbuf_overwrite.lskel.h"
>>
>>   #define EDONE 7777
>>
>> @@ -497,6 +498,67 @@ static void ringbuf_map_key_subtest(void)
>>          test_ringbuf_map_key_lskel__destroy(skel_map_key);
>>   }
>>
>> +static void ringbuf_overwrite_mode_subtest(void)
>> +{
>> +       unsigned long size, len1, len2, len3, len4, len5;
>> +       unsigned long expect_avail_data, expect_prod_pos, expect_over_pos;
>> +       struct test_ringbuf_overwrite_lskel *skel;
>> +       int err;
>> +
>> +       skel = test_ringbuf_overwrite_lskel__open();
>> +       if (!ASSERT_OK_PTR(skel, "skel_open"))
>> +               return;
>> +
>> +       size = 0x1000;
> 
> this will fail on architecture with page size != 4KB, I adjusted this
> to use page_size, len1 to page_size / 2 and len2 to page_size / 4
>

Ah, good catch, thanks for fixing it!

>> +       len1 = 0x800;
>> +       len2 = 0x400;
>> +       len3 = size - len1 - len2 - BPF_RINGBUF_HDR_SZ * 3; /* 0x3e8 */
>> +       len4 = len3 - 8; /* 0x3e0 */
>> +       len5 = len3; /* retry with len3 */
>> +
> 
> [...]


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ