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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQK7Qa5v=fkQtnx_A2OiXDDrWZAYY6qGi8ruVn_dOXmrUw@mail.gmail.com>
Date: Wed, 5 Nov 2025 14:45:48 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Hoyeon Lee <hoyeon.lee@...e.com>
Cc: Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, bpf <bpf@...r.kernel.org>, 
	Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, Eduard <eddyz87@...il.com>, 
	Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>, 
	John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>, 
	Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>, 
	Shuah Khan <shuah@...nel.org>, 
	"open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [bpf-next] selftests/bpf: refactor snprintf_btf test to use bpf_strncmp

On Wed, Nov 5, 2025 at 12:14 PM Hoyeon Lee <hoyeon.lee@...e.com> wrote:
>
> The netif_receive_skb BPF program used in snprintf_btf test still uses
> a custom __strncmp. This is unnecessary as the bpf_strncmp helper is
> available and provides the same functionality.
>
> This commit refactors the test to use the bpf_strncmp helper, removing
> the redundant custom implementation.
>
> Signed-off-by: Hoyeon Lee <hoyeon.lee@...e.com>
> ---
>  .../selftests/bpf/progs/netif_receive_skb.c       | 15 +--------------
>  1 file changed, 1 insertion(+), 14 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/netif_receive_skb.c b/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> index 9e067dcbf607..186b8c82b9e6 100644
> --- a/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> +++ b/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> @@ -31,19 +31,6 @@ struct {
>         __type(value, char[STRSIZE]);
>  } strdata SEC(".maps");
>
> -static int __strncmp(const void *m1, const void *m2, size_t len)
> -{
> -       const unsigned char *s1 = m1;
> -       const unsigned char *s2 = m2;
> -       int i, delta = 0;
> -
> -       for (i = 0; i < len; i++) {
> -               delta = s1[i] - s2[i];
> -               if (delta || s1[i] == 0 || s2[i] == 0)
> -                       break;
> -       }
> -       return delta;
> -}
>
>  #if __has_builtin(__builtin_btf_type_id)
>  #define        TEST_BTF(_str, _type, _flags, _expected, ...)                   \
> @@ -69,7 +56,7 @@ static int __strncmp(const void *m1, const void *m2, size_t len)
>                                        &_ptr, sizeof(_ptr), _hflags);   \
>                 if (ret)                                                \
>                         break;                                          \
> -               _cmp = __strncmp(_str, _expectedval, EXPECTED_STRSIZE); \
> +               _cmp = bpf_strncmp(_str, EXPECTED_STRSIZE, _expectedval); \

Though it's equivalent, the point of the test is to be heavy
for the verifier with open coded __strncmp().

pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ