From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249701; b=QN9BrWiHDrLDeG2RlkqEjUiJ73Az7UHR56XFd9RKZnP0gLW1gI6TL6aDHktspGoGdvXq 07fvYieJ3N0YY4LbCstCayrRpKJkgh9OCLcdmDLjZ4u+HTn1GUpNb0yWOwMBYwGymL1w1 yO+1WomNY/iZ4pnu+waULYwdvBc4mzp+4mlJfGxXCbvExb3/9XvoYaeOjHWa+REhnmN6J 03pj/ZVNuGNyzSyZ5Nj0gw5OWuirJJKjkfx/p5t2KzFGjNQK04x37gEzoQIbo+XSXmBIL DLgJ/3bq8Em5ia6vaIKyFPw27a/aJ9tMyC9AgTmOyTYA1Zy4oP5Cfu/ezKUZRDfFNcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249701; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=rQHC0UOq3J1n+3s7OYER3JlhS/nvjRRFMB5Sv5KFyR4=; b=nX8h2rlIy1B12g8t/CPc5RURh+sjLJJIug+0BmGWtMpvB3weyUFsjMoSVuwl4mjkfxK5 ZqSfKTy1WCMGTdIpaDt6DGVsyjBDNODdh9ugkEeHwGTGMK7F7W0j2W35Sal+Vg67H6AhJ +t9Vdfkg3vTBDTdgGeEYLrF8bVli4tjH5ubvMzHGgSRuySF7/urIjWwQ6R1WabqieMMqt hhOm+83XWnPt21du8nhVovTkux008qeywzHwp2K3zFwJ+qx3lZ/KiacSawcBEOx8oIfPc VlmDuBlpHzr1lY6fK8eUFsLxB6BqhMkGnnpVOamzhalk+CJgIpoaoZyloGr8L96JjRw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dzdfT3Im; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41857606A334 for ; Wed, 2 Dec 2026 22:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dzdfT3Im Received: by smtp.kernel.org (Postfix) with ESMTPSA id C190B1F000C1; Wed, 2 Dec 2026 22:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796249700; bh=rQHC0UOq3J1n+3s7OYER3JlhS/nvjRRFMB5Sv5KFyR4=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=dzdfT3Im5xVFAuwDijh5x55RE/v+SLqWUwLeiedgFTdf8zUDiuvjyNVDKUVZX1hx8 LUnUO/ykoOrNrHrDEJMQQvq0hdJCTPZK07rHnFxjb82NicmZDKiLSB0DP2VEsYqspC u2KX/nIVbpMfMtGV/cIEUDjHYLglomXxu4J/eebj2hrJsQDNoH7YzGTRdzMLmQio/m UKZviGYd0akrA78e2Cv+HVZ6FV/q6Etvcddm5hvFhbpBJj5hEuFnXOlthpCcfhY4Wz Sf9IKn9mo6M83KWU1EkTfFG6x2Ro6UN7G+FJKLsXbbGctwz3Vkyn1DheEBp4lFDMhq 7UG9P3mti73DQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 bpf-next 2/7] bpf: Check many main programs in one set of insns Reply-To: sashiko-reviews@lists.linux.dev To: "Alexei Starovoitov" , bpf@vger.kernel.org In-Reply-To: <20261202212743.647706-3-alexei.starovoitov@gmail.com> References: <20261202212743.647706-1-alexei.starovoitov@gmail.com> <20261202212743.647706-3-alexei.starovoitov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 22:15:00 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] bpf: missing sleepable_async_cb propagation in mark_sleepable_async_cb() - [Low] bpf: unreturned env->mem charges in bpf_precision_free() across main progs -- commit e92d07122046139421d58da32ed44b43dd2f289e Author: Alexei Starovoitov bpf: Check many main programs in one set of insns This commit extends the BPF verifier to verify multiple main program entry points within a single shared instruction image. > diff --git a/kernel/bpf/precision.c b/kernel/bpf/precision.c > index 0a2923505308b..725de358f5ca8 100644 > --- a/kernel/bpf/precision.c > +++ b/kernel/bpf/precision.c > @@ -1826,6 +1826,8 @@ void bpf_precision_free(struct bpf_verifier_env *en= v) > =20 > if (!prec) > return; > + if (prec->data_deps) > + env->mem -=3D 18 * prec->words * sizeof(long) + 5 * env->prog->len * s= izeof(u16); > kvfree(prec->func); > kvfree(prec->loops); > kvfree(prec->hops_to_err); [Severity: Low] As reported by bot+bpf-ci@kernel.org on v1 [1], does bpf_precision_free() leave bytes charged to env->mem across main programs when prec->seen is allocated or when alloc_masks() fails before setting prec->data_deps? In bpf_failing_path_was_here(), growing prec->seen charges env->mem +=3D size * sizeof(*set), and alloc_masks() leaves 5 * env->prog->len * sizeof(u16) charged for prec->hops_to_err when bpf_check_limits() or kvcalloc() fails with prec->data_deps still NULL. Because do_check_mains() carries env->mem across entries, these unreturned charges can accumulate and cause later main programs in the load to fail with -E2BIG. > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > index b753d6c7a00b5..2c6dc44f4e74e 100644 > --- a/kernel/bpf/verifier.c > +++ b/kernel/bpf/verifier.c [ ... ] > @@ -25328,14 +25478,50 @@ static int do_check_all(struct bpf_verifier_env= *env) > restart_log(env, &log); > if (err && (!path_err || guess) && (limit || (env->for_log && !env->err= ))) > verbose(env, "the limit on cost or memory ended pass %u\n", env->pass); > - if (!err && env->sleepable_async_cb) > - mark_sleepable_async_cb(env); > bpf_precision_free(env); > free_snapshot(env, initial); > free_snapshot(env, good_pass); > return err; > } > =20 > +/* > + * A main prog that is proven is not checked again. The ones after it mu= st not add a site that its > + * states went past, or take away a site at which they were cancelled. > + */ > +static int check_proven_mains(struct bpf_verifier_env *env) > +{ > + struct bpf_insn_aux_data *aux =3D env->insn_aux_data; > + int i; > + > + for (i =3D 0; i < env->prog->len; i++) { > + if (aux[i].needs_guard && aux[i].no_guard_edges) { > + verbose(env, "loop at insn %d needs may_goto for some programs only\n= ", i); > + return -EINVAL; > + } > + } > + return 0; > +} > + > +/* Each main prog has passes of its own. They start from what the progs = before it wrote. */ > +static int do_check_mains(struct bpf_verifier_env *env) > +{ > + u64 cost =3D env->cost, max_cost =3D env->max_cost, max_mem =3D env->ma= x_mem; > + int err =3D 0; > + > + for (; env->pass_main < env->main_cnt && !err; env->pass_main++) { > + env->cost =3D cost; > + env->max_cost =3D max_cost; > + env->max_mem =3D max_mem; > + bpf_flow_new_main(env); > + err =3D do_check_all(env); > + if (!err && env->main_cnt > 1) > + err =3D check_proven_mains(env); > + } > + if (!err && env->sleepable_async_cb) > + mark_sleepable_async_cb(env); > + return err; > +} [Severity: Medium] Can a non-sleepable struct_ops entry miss sleepable_async_cb and map sleepable_refcnt increments when the first entry is sleepable? can_share_subprogs() allows a struct_ops load to mix sleepable and non-sleepable entries. When the first entry is sleepable (env->prog->sleep= able is true) and the load schedules a sleepable async callback, mark_sleepable_async_cb() returns early before setting env->prog->aux->sleepable_async_cb =3D true: kernel/bpf/verifier.c:mark_sleepable_async_cb() { if (bpf_prog_runs_sleepable(env->prog)) return; env->prog->aux->sleepable_async_cb =3D true; ... } finish_entry() then copies from->sleepable_async_cb (false) into each entry's aux, so for any non-sleepable entry bpf_prog_runs_sleepable(entry) is false. As a result, finish_entry() skips incrementing map->sleepable_refcnt for that entry's used_maps and the entry is freed via call_rcu() instead of call_rcu_tasks_trace(), allowing map->sleepable_refcnt to drop to zero and skip RCU Tasks Trace synchronization while the non-sleepable entry and its sleepable async callback remain active. [1] https://lore.kernel.org/r/a0639de449fd4f8ca45a82936271218bb746b417c8aee= efa92cdd3258174303f@mail.kernel.org --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202212743.6477= 06-1-alexei.starovoitov@gmail.com?part=3D2