Re: [PATCH bpf-next 09/11] bpf: Return PTR_ERR from push_stack()

From: Eduard Zingerman
Date: Mon Mar 17 2025 - 05:19:41 EST


On Thu, 2025-03-13 at 18:41 +0100, Luis Gerhorst wrote:

[...]

> @@ -2011,8 +2011,10 @@ static struct bpf_verifier_state *push_stack(struct bpf_verifier_env *env,
> int err;
>
> elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL);
> - if (!elem)
> - goto err;
> + if (!elem) {
> + err = -ENOMEM;
> + goto unrecoverable_err;
> + }

Could you please point me to a location, where exact error code
returned by updated push_stack() matters?
I checked push_stack() callgraph (in the attachment), but can't find
anything.

>
> elem->insn_idx = insn_idx;
> elem->prev_insn_idx = prev_insn_idx;
> @@ -2022,12 +2024,19 @@ static struct bpf_verifier_state *push_stack(struct bpf_verifier_env *env,

[...]

digraph G {
Node0x55dd4a8d4b50 [label="{check_cond_jmp_op}", shape=record];
Node0x55dd4aa06790 [label="{sanitize_speculative_path}", shape=record];
Node0x55dd4a8ca580 [label="{check_helper_call}", shape=record];
Node0x55dd4a8cf260 [label="{check_kfunc_call}", shape=record];
Node0x55dd4a88d7d0 [label="{do_check}", shape=record];
Node0x55dd4aa3a360 [label="{adjust_ptr_min_max_vals}", shape=record];
Node0x55dd4a76c620 [label="{do_check_common}", shape=record];
Node0x55dd4a8ba850 [label="{adjust_reg_min_max_vals}", shape=record];
Node0x55dd4959fe40 [label="{process_iter_next_call}", shape=record];
Node0x55dd4aa5c1e0 [label="{sanitize_ptr_alu}", shape=record];
Node0x55dd4a9a3ac0 [label="{push_callback_call}", shape=record];
Node0x55dd4a9fb9d0 [label="{push_stack}", shape=record];
Node0x55dd4a778db0 [label="{do_check_subprogs}", shape=record];
Node0x55dd4a741990 [label="{bpf_check}", shape=record];
Node0x55dd4a741990 -> Node0x55dd4a778db0;
Node0x55dd4a741990 -> Node0x55dd4a76c620;
Node0x55dd4a778db0 -> Node0x55dd4a76c620;
Node0x55dd4a76c620 -> Node0x55dd4a88d7d0;
Node0x55dd4a88d7d0 -> Node0x55dd4a8d4b50;
Node0x55dd4a88d7d0 -> Node0x55dd4a8ca580;
Node0x55dd4a88d7d0 -> Node0x55dd4a8cf260;
Node0x55dd4a88d7d0 -> Node0x55dd4a8ba850;
Node0x55dd4a8cf260 -> Node0x55dd4959fe40;
Node0x55dd4a8cf260 -> Node0x55dd4a9a3ac0;
Node0x55dd4a8ca580 -> Node0x55dd4a9a3ac0;
Node0x55dd4a8d4b50 -> Node0x55dd4a9fb9d0;
Node0x55dd4a8d4b50 -> Node0x55dd4aa06790;
Node0x55dd4a8ba850 -> Node0x55dd4aa3a360;
Node0x55dd4aa3a360 -> Node0x55dd4aa5c1e0;
Node0x55dd4aa5c1e0 -> Node0x55dd4a9fb9d0;
Node0x55dd4aa06790 -> Node0x55dd4a9fb9d0;
Node0x55dd4a9a3ac0 -> Node0x55dd4a9fb9d0;
Node0x55dd4959fe40 -> Node0x55dd4a9fb9d0;
}