DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marat Khalili <marat.khalili@huawei.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [PATCH v2 0/7] validate-bpf: add standalone validation debug tool
Date: Tue, 15 Sep 2026 19:27:34 +0000	[thread overview]
Message-ID: <905abb0efb254b63b887fb3b66848152@huawei.com> (raw)
In-Reply-To: <20260914114229.61d5e94c@phoenix.local>

Thanks a lot for looking, please see the answers inline below.

> Looks good to me, but AI had some nits to pick.
> 
> Re: [PATCH v2 0/7] bpf/validate: debug events and validation app
> 
> Errors
> ------
> 
> Patch 7/7 (app/validate-bpf: add BPF validation application)
> 
>   app/validate-bpf/parse_decl.c:
> 
>     +		arg->value.size *= array_length;
> 
>   array_length comes from take_number() on the --xsym text with no
>   upper bound, and the multiply is not checked for overflow, so a
>   large length silently wraps to a small size that is then reported
>   to the validator as the object size.  Reproduced:
> 
>     dpdk-validate-bpf --xsym='uint64_t[2305843009213693953] v' \
>         --section=.text prog.o
>     Validation succeeded.
> 
>   8 * 2305843009213693953 wraps to 8, so the tool accepts the
>   declaration and describes an 8-byte object.  Clamp array_length,
>   or check the product, and reject with the usual text error.

Addressed in v3.

> Warnings
> --------
> 
> Patch 5/7 (bpf/validate: add get current event API)
> 
>   lib/bpf/bpf_validate_debug.c:
> 
>     +		return -EINVAL;
> 
>   in rte_bpf_validate_debug_get_event(), whose return type is
>   enum rte_bpf_validate_debug_event.  Every enumerator in that enum
>   is non-negative, so the compatible type is unsigned and -EINVAL
>   arrives at the caller as 4294967274.  It equals no enumerator,
>   including RTE_BPF_VALIDATE_DEBUG_EVENT_END, so a caller cannot
>   test for it.  Either return
>   RTE_BPF_VALIDATE_DEBUG_EVENT_END for the NULL case and say so in
>   the doc comment, or change the signature to return int with the
>   event in an out-parameter.

Behavior is intentionally not defined and caller is intentionally not required
to check return value from this API for errors to keep its life easier.
The return value is always valid with the catchpoint callback.

> Patch 7/7
> 
>   app/validate-bpf/parse_decl.c:
> 
>     +	void * const val = calloc(1, RTE_MAX(1u, arg.value.size));
>     +	RTE_VERIFY(val != 0);
> 
>   arg.value.size is user-supplied, so an allocation failure driven by
>   the command line aborts with a core dump instead of an error
>   message.  Reproduced:
> 
>     dpdk-validate-bpf --xsym='uint64_t[18446744073709551615] v' \
>         --section=.text prog.o
>     EAL: PANIC in fill_var_xsym():
>     line 427	assert "val != 0" failed
> 
>   Return an error up through the parse path like the other --xsym
>   failures do.

Addressed in v3.

> 
>   app/validate-bpf/main.c:
> 
>     +	RTE_VERIFY(rte_eal_init(eal_init_argc, eal_init_argv) ==
>     +		eal_init_argc - 1);
> 
>   rte_eal_init() returns -1 for ordinary environmental failures such
>   as a missing runtime directory or insufficient permissions.  For a
>   command-line tool that should be a message and a non-zero exit, not
>   rte_panic().  Same for
> 
>     +	RTE_VERIFY(rte_eal_cleanup() == 0);

Addressed in v3.

>   app/validate-bpf/eal_init_args.c:
> 
>     +#define RTE_EAL_INIT_ARG_SIZE_MAX sizeof("--log-level=lib.eal:warning")
> 
>   and RTE_EAL_INIT_ARGS / RTE_EAL_INIT_ARGC below it.  The RTE_
>   prefix is reserved for the libraries; an application should not
>   define into it.  Drop the prefix.

Addressed in v3.

> Info
> ----
> 
> Patch 5/7
> 
>   debug->current_event is set only in debug_send_event().  A
>   breakpoint callback reached through debug_trigger_breakpoints()
>   therefore sees whatever event fired last.  The doc comment says the
>   value is undefined when no event is being processed, so this is
>   consistent, but a callback shared between a breakpoint and a
>   catchpoint will read a stale event rather than an obviously invalid
>   one.

There is currently no use case for this, and undefined behaviour allows
implementing this in the future.

>   rte_bpf_validate_debug_get_event() is new public experimental API
>   and gets no release note.  7/7 adds a release note, but only for
>   the application.

Technically true, but practically I suspect there are no users of this API
yet, so noise in release notes is kept to the minimum.

> Patch 7/7
> 
>   In --debug mode the result is printed twice: debug.c prints
>   "Validation succeeded." to stdout from the validation-success
>   catchpoint, and main.c prints it again to stderr.

There is a prompt between them, so the result looks ok.

>   Array declarations are written as "uint64_t[4] v", not the C
>   "uint64_t v[4]".  The C spelling is rejected with
> 
>     at offset 10: expect '(' or text end
> 
>   which does not point at the real problem.  Worth either accepting
>   the C form or naming the expected form in the message.  The
>   documented form is in --help, so this is a diagnostics nit.

Yes, this is a documented current limitation, patches are welcome.

>   "uint64_t[0] v" is accepted and yields value.size 0 while calloc
>   still allocates one byte.  Probably worth rejecting a zero length.

Decisions on validity of external symbols are left to the BPF loader.

> Patch 7/7 (app/validate-bpf: add BPF validation application)
> 
>   app/validate-bpf/parse_decl.c:
> 
>     +		arg->value.size *= array_length;
> 
>   array_length comes from take_number() on the --xsym text with no
>   upper bound, and the multiply is not checked for overflow, so a
>   large length silently wraps to a small size that is then reported
>   to the validator as the object size.  Reproduced:
> 
>     dpdk-validate-bpf --xsym='uint64_t[2305843009213693953] v' \
>         --section=.text prog.o
>     Validation succeeded.
> 
>   8 * 2305843009213693953 wraps to 8, so the tool accepts the
>   declaration and describes an 8-byte object.  Clamp array_length,
>   or check the product, and reject with the usual text error.

Addressed in v3.

> Build fails on FreeBSD
// snip
> ../app/validate-bpf/parse_decl.c:392:33: error: 'array_length' may be used uninitialized [-
> Werror=maybe-uninitialized]

Hopefully addressed in v3.

  reply	other threads:[~2026-09-15 19:27 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 10:39 [PATCH 0/7] validate-bpf: add standalone validation debug tool Marat Khalili
2026-09-11 10:39 ` [PATCH 1/7] bpf/validate: fix finished status on restart Marat Khalili
2026-09-11 10:40 ` [PATCH 2/7] bpf/validate: refactor internal step function Marat Khalili
2026-09-11 10:40 ` [PATCH 3/7] bpf/validate: formalize call back requirements Marat Khalili
2026-09-11 10:40 ` [PATCH 4/7] bpf/validate: add jump notification events Marat Khalili
2026-09-11 10:40 ` [PATCH 5/7] bpf/validate: add get current event API Marat Khalili
2026-09-11 10:40 ` [PATCH 6/7] app/test: add test for bpf validate debug events Marat Khalili
2026-09-11 10:40 ` [PATCH 7/7] app/validate-bpf: add BPF validation application Marat Khalili
2026-09-14 14:54 ` [PATCH v2 0/7] validate-bpf: add standalone validation debug tool Marat Khalili
2026-09-14 14:54   ` [PATCH v2 1/7] bpf/validate: fix finished status on restart Marat Khalili
2026-09-14 14:54   ` [PATCH v2 2/7] bpf/validate: refactor internal step function Marat Khalili
2026-09-14 14:54   ` [PATCH v2 3/7] bpf/validate: formalize call back requirements Marat Khalili
2026-09-14 14:54   ` [PATCH v2 4/7] bpf/validate: add jump notification events Marat Khalili
2026-09-14 14:54   ` [PATCH v2 5/7] bpf/validate: add get current event API Marat Khalili
2026-09-14 14:54   ` [PATCH v2 6/7] app/test: add test for bpf validate debug events Marat Khalili
2026-09-14 14:54   ` [PATCH v2 7/7] app/validate-bpf: add BPF validation application Marat Khalili
2026-09-14 18:41     ` Stephen Hemminger
2026-09-15 13:13     ` Stephen Hemminger
2026-09-14 18:42   ` [PATCH v2 0/7] validate-bpf: add standalone validation debug tool Stephen Hemminger
2026-09-15 19:27     ` Marat Khalili [this message]
2026-09-15 19:26   ` [PATCH v3 " Marat Khalili
2026-09-15 19:26     ` [PATCH v3 1/7] bpf/validate: fix finished status on restart Marat Khalili
2026-09-15 19:26     ` [PATCH v3 2/7] bpf/validate: refactor internal step function Marat Khalili
2026-09-15 19:26     ` [PATCH v3 3/7] bpf/validate: formalize call back requirements Marat Khalili
2026-09-15 19:26     ` [PATCH v3 4/7] bpf/validate: add jump notification events Marat Khalili
2026-09-15 19:26     ` [PATCH v3 5/7] bpf/validate: add get current event API Marat Khalili
2026-09-15 19:26     ` [PATCH v3 6/7] app/test: add test for bpf validate debug events Marat Khalili
2026-09-15 19:26     ` [PATCH v3 7/7] app/validate-bpf: add BPF validation application Marat Khalili
2026-09-16 16:36       ` Konstantin Ananyev
2026-09-17 14:35     ` [PATCH v4 0/7] validate-bpf: add standalone validation debug tool Marat Khalili
2026-09-17 14:35       ` [PATCH v4 1/7] bpf/validate: fix finished status on restart Marat Khalili
2026-09-17 14:35       ` [PATCH v4 2/7] bpf/validate: refactor internal step function Marat Khalili
2026-09-17 14:35       ` [PATCH v4 3/7] bpf/validate: formalize call back requirements Marat Khalili
2026-09-17 14:35       ` [PATCH v4 4/7] bpf/validate: add jump notification events Marat Khalili
2026-09-17 14:35       ` [PATCH v4 5/7] bpf/validate: add get current event API Marat Khalili
2026-09-17 14:35       ` [PATCH v4 6/7] app/test: add test for bpf validate debug events Marat Khalili
2026-09-17 14:35       ` [PATCH v4 7/7] app/validate-bpf: add BPF validation application Marat Khalili
2026-09-17 16:16       ` [PATCH v4 0/7] validate-bpf: add standalone validation debug tool Konstantin Ananyev

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=905abb0efb254b63b887fb3b66848152@huawei.com \
    --to=marat.khalili@huawei.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox