All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 4/4] selftests/bpf: Check for flag presence in bpf_program__flags()
Date: Tue, 01 Sep 2026 08:56:03 +0000	[thread overview]
Message-ID: <20260901085604.0076E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901-libbpf-frags-flags-v3-4-4eb6f14968b0@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing NULL check for `prog` before calling `bpf_program__flags()`.
--

commit 05df19ea2fe700cefa5c96da6572795ffbe95855
Author: Toke Høiland-Jørgensen <toke@redhat.com>
Date:   Tue Sep 1 08:46:57 2026 +0000

selftests/bpf: Check for flag presence in bpf_program__flags()

This commit adds assertions to verify that the BPF_F_XDP_HAS_FRAGS and
BPF_F_SLEEPABLE flags are present in bpf_program__flags() when opening BPF
programs that have these flags in their section definitions.

> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_frags.c b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_frags.c
> index fce203640f8cf..a894b1ab46f4e 100644
> --- a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_frags.c
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_frags.c
> @@ -18,6 +18,9 @@ static void test_xdp_update_frags(void)
>  		return;
>  
>  	prog = bpf_object__next_program(obj, NULL);
> +	ASSERT_EQ(bpf_program__flags(prog) & BPF_F_XDP_HAS_FRAGS,
> +		  BPF_F_XDP_HAS_FRAGS, "frags in program flags");
> +

[Severity: Medium]
Is a NULL check needed for prog here?

If the BPF object file test_xdp_update_frags.bpf.o is valid but contains no
programs (for instance, due to a build issue or a stripped ELF),
bpf_object__next_program() will return NULL. The prog pointer is then passed
directly to bpf_program__flags(), which will unconditionally dereference it
and cause a segmentation fault in the test suite.

Prior to this patch, prog was safely passed down to bpf_program__fd(), which
gracefully handled the NULL by returning -EINVAL and failing the test cleanly.
Would it be safer to check prog with ASSERT_OK_PTR() before attempting to
verify its flags?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-libbpf-frags-flags-v3-0-4eb6f14968b0@redhat.com?part=4

  reply	other threads:[~2026-09-01  8:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  8:46 [PATCH bpf-next v3 0/4] libbpf: Move section-defined program flags to prog_flags Toke Høiland-Jørgensen
2026-09-01  8:46 ` [PATCH bpf-next v3 1/4] bpftool: Set BPF_F_XDP_DEV_BOUND_ONLY flag non-destructively Toke Høiland-Jørgensen
2026-09-03  0:22   ` Andrii Nakryiko
2026-09-03  7:53     ` Toke Høiland-Jørgensen
2026-09-01  8:46 ` [PATCH bpf-next v3 2/4] selftests/bpf: Set BPF program flags non-destructively Toke Høiland-Jørgensen
2026-09-01  9:54   ` bot+bpf-ci
2026-09-01  8:46 ` [PATCH bpf-next v3 3/4] libbpf: Move section-defined program flags to prog_flags Toke Høiland-Jørgensen
2026-09-01  9:54   ` bot+bpf-ci
2026-09-03  0:22     ` Andrii Nakryiko
2026-09-01  8:46 ` [PATCH bpf-next v3 4/4] selftests/bpf: Check for flag presence in bpf_program__flags() Toke Høiland-Jørgensen
2026-09-01  8:56   ` sashiko-bot [this message]
2026-09-03  0:30 ` [PATCH bpf-next v3 0/4] libbpf: Move section-defined program flags to prog_flags 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=20260901085604.0076E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=toke@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.