All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>,
	bpf@vger.kernel.org,  ast@kernel.org, andrii@kernel.org,
	daniel@iogearbox.net, kafai@meta.com,  kernel-team@meta.com,
	memxor@gmail.com
Cc: Mykyta Yatsenko <yatsenko@meta.com>
Subject: Re: [PATCH bpf-next v4 4/8] bpf: verifier: permit non-zero returns from async callbacks
Date: Mon, 15 Sep 2025 14:24:24 -0700	[thread overview]
Message-ID: <86b6cedafb94f1663d963fed6ff13352f2bb02aa.camel@gmail.com> (raw)
In-Reply-To: <20250915201820.248977-5-mykyta.yatsenko5@gmail.com>

On Mon, 2025-09-15 at 21:18 +0100, Mykyta Yatsenko wrote:
> From: Mykyta Yatsenko <yatsenko@meta.com>
> 
> The verifier currently enforces a zero return value for all async
> callbacks—a constraint originally introduced for bpf_timer. That
> restriction is too narrow for other async use cases.
> 
> Relax the rule by allowing non-zero return codes from async callbacks in
> general, while preserving the zero-return requirement for bpf_timer to
> maintain its existing semantics.
> 
> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
> ---

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

>  kernel/bpf/verifier.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index ede511ac7908..102e72c8d070 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -10863,7 +10863,7 @@ static int set_timer_callback_state(struct bpf_verifier_env *env,
>  	__mark_reg_not_init(env, &callee->regs[BPF_REG_4]);
>  	__mark_reg_not_init(env, &callee->regs[BPF_REG_5]);
>  	callee->in_async_callback_fn = true;
> -	callee->callback_ret_range = retval_range(0, 1);
> +	callee->callback_ret_range = retval_range(0, 0);

Discussed this with Mykyta off-list, note for reviewers:

  For function frame states with ->in_async_callback_fn set to true
  verifier ignores ->callback_ret_range. So the above hunk does not
  change verifier behavior.
  A change below is necessary to take ->callback_ret_range into account.

>  	return 0;
>  }
>  
> @@ -17148,9 +17148,8 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
>  	}
>  
>  	if (frame->in_async_callback_fn) {
> -		/* enforce return zero from async callbacks like timer */
>  		exit_ctx = "At async callback return";
> -		range = retval_range(0, 0);
> +		range = frame->callback_ret_range;
>  		goto enforce_retval;
>  	}
>  

  reply	other threads:[~2025-09-15 21:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15 20:18 [PATCH bpf-next v4 0/8] bpf: Introduce deferred task context execution Mykyta Yatsenko
2025-09-15 20:18 ` [PATCH bpf-next v4 1/8] bpf: refactor special field-type detection Mykyta Yatsenko
2025-09-15 20:18 ` [PATCH bpf-next v4 2/8] bpf: extract generic helper from process_timer_func() Mykyta Yatsenko
2025-09-15 21:19   ` Eduard Zingerman
2025-09-16 11:43     ` Mykyta Yatsenko
2025-09-15 20:18 ` [PATCH bpf-next v4 3/8] bpf: htab: extract helper for freeing special structs Mykyta Yatsenko
2025-09-15 20:18 ` [PATCH bpf-next v4 4/8] bpf: verifier: permit non-zero returns from async callbacks Mykyta Yatsenko
2025-09-15 21:24   ` Eduard Zingerman [this message]
2025-09-15 20:18 ` [PATCH bpf-next v4 5/8] bpf: bpf task work plumbing Mykyta Yatsenko
2025-09-15 21:40   ` Eduard Zingerman
2025-09-15 20:18 ` [PATCH bpf-next v4 6/8] bpf: extract map key pointer calculation Mykyta Yatsenko
2025-09-15 20:18 ` [PATCH bpf-next v4 7/8] bpf: task work scheduling kfuncs Mykyta Yatsenko
2025-09-15 21:52   ` Eduard Zingerman
2025-09-16 20:08   ` Kumar Kartikeya Dwivedi
2025-09-15 20:18 ` [PATCH bpf-next v4 8/8] selftests/bpf: BPF task work scheduling tests Mykyta Yatsenko
2025-09-15 22:08   ` Eduard Zingerman
2025-09-16  7:36 ` [syzbot ci] Re: bpf: Introduce deferred task context execution syzbot ci

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=86b6cedafb94f1663d963fed6ff13352f2bb02aa.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@meta.com \
    --cc=kernel-team@meta.com \
    --cc=memxor@gmail.com \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=yatsenko@meta.com \
    /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.