All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Xu Yunxiang" <xyx2021@mail.ustc.edu.cn>, <bpf@vger.kernel.org>
Cc: <daniel@iogearbox.net>, <andrii@kernel.org>, <eddyz87@gmail.com>,
	<memxor@gmail.com>, <ameryhung@gmail.com>,
	<sashiko-bot@kernel.org>
Subject: Re: [PATCH bpf-next v4 1/2] bpf: Destroy callee-local dynptrs on subprog return
Date: Thu, 17 Sep 2026 14:48:02 +0000	[thread overview]
Message-ID: <DLHO9Y7TLIK7.HLZOCWK5B3I8@gmail.com> (raw)
In-Reply-To: <20260917052000.1589643-2-xyx2021@mail.ustc.edu.cn>

On Thu, Sep 17, 2026 at 01:19 PM Xu Yunxiang <xyx2021@mail.ustc.edu.cn> wrote:

>  static int destroy_if_dynptr_stack_slot(struct bpf_verifier_env *env,
> -				        struct bpf_func_state *state, int spi)
> +					struct bpf_func_state *state, int spi,
> +					bool on_func_exit)
>  {
>  	int err = 0;
>
> @@ -867,6 +894,15 @@ static int destroy_if_dynptr_stack_slot(struct bpf_verifier_env *env,
>  	 */
>  	if (dynptr_type_referenced(state->stack[spi].spilled_ptr.dynptr.type) &&
>  	    dynptr_ref_cnt(env, state->stack[spi].spilled_ptr.parent_id) <= 1) {
> +		if (on_func_exit) {
> +			verbose(env, "cannot return with referenced dynptr in callee stack\n");
> +			bpf_diag_res(env, env->insn_idx,
> +				     "referenced dynptr on function return",
> +				     "The departing stack frame contains the last dynptr that can release a referenced resource.",
> +				     "Release the referenced resource before returning from this function.");
> +			return -EINVAL;
> +		}

Pls
 don't add a bool to destroy_if_dynptr_stack_slot() and touch all of
its callers just to print a different message.

pw-bot: cr

  parent reply	other threads:[~2026-09-17 14:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  5:19 [PATCH bpf-next v4 0/2] bpf: Destroy callee-local dynptrs on subprog return Xu Yunxiang
2026-09-17  5:19 ` [PATCH bpf-next v4 1/2] " Xu Yunxiang
2026-09-17  6:15   ` bot+bpf-ci
2026-09-17 14:48   ` Alexei Starovoitov [this message]
2026-09-17  5:20 ` [PATCH bpf-next v4 2/2] selftests/bpf: Test dynptr teardown " Xu Yunxiang

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=DLHO9Y7TLIK7.HLZOCWK5B3I8@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=memxor@gmail.com \
    --cc=sashiko-bot@kernel.org \
    --cc=xyx2021@mail.ustc.edu.cn \
    /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.