linux-next: manual merge of the bpf-next tree with the bpf tree

From: Mark Brown

Date: Fri Nov 27 2026 - 10:56:05 EST


Hi all,

Today's linux-next merge of the bpf-next tree got a conflict in:

kernel/bpf/verifier.c

between commit:

02d3452bdd80c ("bpf: Set the run context for async callbacks")

from the bpf tree and commit:

d83c595d9480e ("bpf: Put a barrier where no mask fits")

from the bpf-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --cc kernel/bpf/verifier.c
index 85fec1f389277,b5dda95c286f7..0000000000000
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@@ -11493,13 -11472,9 +11477,15 @@@ static int push_callback_call(struct bp
if (bpf_is_async_callback_calling_insn(insn)) {
struct bpf_verifier_state *async_cb;

+ if (state->speculative)
+ return 0;
/* there is no real recursion here. timer and workqueue callbacks are async */
+ /* there is no cgroup to take the storage from */
+ if (env->prog->aux->cgroup_storage[BPF_CGROUP_STORAGE_SHARED] ||
+ env->prog->aux->cgroup_storage[BPF_CGROUP_STORAGE_PERCPU]) {
+ verbose(env, "async callback in a program with cgroup storage\n");
+ return -EINVAL;
+ }
env->subprog_info[subprog].is_async_cb = true;
async_cb = push_async_cb(env, env->subprog_info[subprog].start,
insn_idx, subprog,
@@@ -20834,46 -21913,109 +21938,109 @@@ static int do_check_block(struct bpf_ve
env->insn_idx++;
}

- if (state->speculative && insn_aux->nospec_result) {
- /* If we are on a path that performed a jump-op, this
- * may skip a nospec patched-in after the jump. This can
- * currently never happen because nospec_result is only
- * used for the write-ops
- * `*(size*)(dst_reg+off)=src_reg|imm32` and helper
- * calls. These must never skip the following insn
- * (i.e., bpf_insn_successors()'s opcode_info.can_jump
- * is false). Still, add a warning to document this in
- * case nospec_result is used elsewhere in the future.
- *
- * All non-branch instructions have a single
- * fall-through edge. For these, nospec_result should
- * already work.
- */
- if (verifier_bug_if((BPF_CLASS(insn->code) == BPF_JMP ||
- BPF_CLASS(insn->code) == BPF_JMP32) &&
- BPF_OP(insn->code) != BPF_CALL, env,
- "speculation barrier after jump instruction may not have the desired effect"))
- return -EFAULT;
- /* only a store that stays gets it, see bpf_convert_ctx_accesses() */
++ /* End speculation at a retained store with a trailing barrier. */
+ if (state->speculative && insn_aux->nospec_result && !insn_aux->fastcall_pattern &&
+ bpf_is_mem_insn(insn) && BPF_MODE(insn->code) == BPF_MEM) {
process_bpf_exit:
account_current_path(env);
- mark_verifier_state_scratched(env);
- err = bpf_update_branch_counts(env, env->cur_state);
- if (err)
- return err;
- err = pop_stack(env, &prev_insn_idx, &env->insn_idx,
- pop_log);
- if (err < 0) {
- if (err != -ENOENT)
- return err;
- break;
- } else {
- do_print_state = true;
- continue;
- }
+ bpf_free_verifier_state(env, state, false);
+ memset(state, 0, sizeof(*state));
+ return flow_drain(env);
+ }
+
+ /* if the insn pushed a part, the current state is a part too */
+ for (elem = env->head; elem; elem = elem->next)
+ again |= elem->again;
+ err = flow_drain(env);
+ if (err)
+ return err;
+
+ /* the parts of a state meet at the next insn */
+ if (env->insn_idx < insn_cnt &&
+ (again || bpf_flow_is_bb_start(env, env->insn_idx))) {
+ account_current_path(env);
+ return bpf_flow_deliver(env, state, env->insn_idx, prev_insn_idx, false);
}
}
+ }

- return 0;
+ /* What the pass assumed about loops does not hold, see do_check_all() */
+ static bool pass_needs_restart(struct bpf_verifier_env *env)
+ {
+ return (env->restart && bpf_flow_loops_lost_bound(env)) || env->guards_late;
+ }
+
+ /*
+ * The loops that keep the current state apart pay for the work since the last state, but not
+ * a loop that the state enters. A trip that is peeled on the budget of a loop belongs to that
+ * loop. Such trips can use up the budget of an inner loop.
+ */
+ static void charge_loops(struct bpf_verifier_env *env, u64 cost)
+ {
+ const struct bpf_verifier_state *st = env->cur_state;
+ const struct loop_stack_entry *e;
+ struct bpf_loop *starved_loop = NULL;
+ int fr, i;
+
+ for (fr = st->curframe; env->pass && fr >= 0; fr--) {
+ for (i = st->frame[fr]->loop_stack_cnt - 1; i >= 0; i--) {
+ e = &st->frame[fr]->loop_stack[i];
+ if ((e->peeled || e->loop->disjoint_apart) &&
+ (e->trip || e->loop->header != st->insn_idx))
+ e->loop->this_pass.cost += cost;
+ if (e->peeled && e->trip >= e->loop->peel_cnt) {
+ if (starved_loop && e->loop->partitioned)
+ starved_loop->this_pass.starved =
+ e->loop->this_pass.starves = true;
+ return;
+ }
+ if (e->loop->partitioned && !bpf_loop_has_budget(e->loop))
+ starved_loop = e->loop;
+ }
+ }
+ }
+
+ static int do_check(struct bpf_verifier_env *env)
+ {
+ bool level2 = env->log.level & BPF_LOG_LEVEL2;
+ u64 log_pos = env->log.end_pos, diag_pos = 0;
+ u64 cost = env->cost;
+ int prev_insn_idx, err;
+
+ err = bpf_flow_deliver(env, env->cur_state, env->insn_idx, -1, false);
+ while (!err && !(env->path_sensitive && env->cost >= env->failing_path_max_cost)) {
+ err = bpf_flow_next(env, &prev_insn_idx, &log_pos, &diag_pos);
+ /* at the limit the work on equations is not complete, such a pass proves nothing */
+ if (err == -ENOENT)
+ return bpf_check_limits(env);
+ if (err)
+ break;
+ charge_loops(env, env->cost - cost);
+ cost = env->cost;
+ /* A pass logs one basic block at a time. A path-sensitive run logs a full path. */
+ bpf_diag_event_log_restore(env, diag_pos);
+ if (!level2) {
+ bpf_vlog_reset(&env->log, log_pos);
+ env->prev_linfo = NULL;
+ }
+ err = do_check_block(env, prev_insn_idx);
+ if (env->bug)
+ return -EFAULT;
+ /* a pass had no error at this insn, possibly with a state that has more values */
+ if (err && env->path_sensitive && is_error_of_state(env, err) &&
+ (env->cur_state->infeasible || env->cur_state->equations.infeasible ||
+ !bpf_failing_path_may_end_at(env, env->insn_idx))) {
+ bpf_free_verifier_state(env, env->cur_state, false);
+ memset(env->cur_state, 0, sizeof(*env->cur_state));
+ free_pushed_states(env);
+ err = 0;
+ }
+ }
+ /* bpf_flow_edge_unproven() noted it with the state that failed */
+ if (err && !bpf_insn_is_unproven(env))
+ note_error(env, err);
+ env->run_over_budget |= !err;
+ return err;
}

static int find_btf_percpu_datasec(struct btf *btf)

Attachment: signature.asc
Description: PGP signature