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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQKo3KiX5xHk=TzYJZy-irJu=qmUFXBbhu6ExpSGk4x7+w@mail.gmail.com>
Date: Thu, 28 Aug 2025 09:15:30 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Feng Yang <yangfeng59949@....com>
Cc: Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, 
	John Fastabend <john.fastabend@...il.com>, 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>, KP Singh <kpsingh@...nel.org>, 
	Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>, 
	bpf <bpf@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>, 
	"open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: Fix the issue where the error
 code is 0

On Thu, Aug 28, 2025 at 1:15 AM Feng Yang <yangfeng59949@....com> wrote:
>
> From: Feng Yang <yangfeng@...inos.cn>
>
> The error message printed here only uses the previous err value,
> which results in it being printed as 0.
> When bpf_map__attach_struct_ops encounters an error,
> it uses libbpf_err_ptr(err) to set errno = -err and returns NULL.

Yes, but libbpf_get_error() is better.
And decimal number is preferred as ASSERT_OK_PTR() macro does.

pw-bot: cr

> Therefore, strerror(errno) can be used to fix this issue.
>
> Fix before:
> run_subtest:FAIL:1019 bpf_map__attach_struct_ops failed for map pro_epilogue: err=0
>
> Fix after:
> run_subtest:FAIL:1019 bpf_map__attach_struct_ops failed for map pro_epilogue: Bad file descriptor
>
> Signed-off-by: Feng Yang <yangfeng@...inos.cn>
> ---
>  tools/testing/selftests/bpf/test_loader.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/selftests/bpf/test_loader.c
> index f361c8aa1daf..686a7d7f87b1 100644
> --- a/tools/testing/selftests/bpf/test_loader.c
> +++ b/tools/testing/selftests/bpf/test_loader.c
> @@ -1008,8 +1008,8 @@ void run_subtest(struct test_loader *tester,
>                         }
>                         link = bpf_map__attach_struct_ops(map);
>                         if (!link) {
> -                               PRINT_FAIL("bpf_map__attach_struct_ops failed for map %s: err=%d\n",
> -                                          bpf_map__name(map), err);
> +                               PRINT_FAIL("bpf_map__attach_struct_ops failed for map %s: %s\n",
> +                                          bpf_map__name(map), strerror(errno));
>                                 goto tobj_cleanup;
>                         }
>                         links[links_cnt++] = link;
> --
> 2.27.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ