All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Luis Gerhorst <luis.gerhorst@fau.de>,
	Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko	 <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu	 <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	KP Singh	 <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Hao Luo	 <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>,
	Kumar Kartikeya Dwivedi	 <memxor@gmail.com>,
	Henriette Herzog <henriette.herzog@rub.de>,
		bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: syzbot+b5eb72a560b8149a1885@syzkaller.appspotmail.com
Subject: Re: [PATCH bpf-next] bpf: Fix state use-after-free on push_stack() err
Date: Wed, 11 Jun 2025 15:23:06 -0700	[thread overview]
Message-ID: <01c816691c132dd6c8c2588f396b240f033ce201.camel@gmail.com> (raw)
In-Reply-To: <20250611210728.266563-1-luis.gerhorst@fau.de>

On Wed, 2025-06-11 at 23:07 +0200, Luis Gerhorst wrote:

[...]

> Signed-off-by: Luis Gerhorst <luis.gerhorst@fau.de>

I reproduced the error locally and this patch fixes it.
Also double-checked places where free_verifier_state is called
and error codes used in error_recoverable_with_nospec() are used.
Looks like env->cur_state should be always ok if
error_recoverable_with_nospec() recovers, env internal structures
in healthy state.

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

> ---
>  kernel/bpf/verifier.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index b1f797616f20..d3bff0385a55 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -14229,7 +14229,7 @@ static int sanitize_err(struct bpf_verifier_env *env,
>  	case REASON_STACK:
>  		verbose(env, "R%d could not be pushed for speculative verification, %s\n",
>  			dst, err);
> -		break;
> +		return -ENOMEM;

Good catch, I would have probably missed it.

>  	default:
>  		verbose(env, "verifier internal error: unknown reason (%d)\n",
>  			reason);
> @@ -19753,7 +19753,7 @@ static int do_check(struct bpf_verifier_env *env)
>  			goto process_bpf_exit;
>  
>  		err = do_check_insn(env, &do_print_state);
> -		if (state->speculative && error_recoverable_with_nospec(err)) {
> +		if (error_recoverable_with_nospec(err) && state->speculative) {
>  			/* Prevent this speculative path from ever reaching the
>  			 * insn that would have been unsafe to execute.
>  			 */
> 
> base-commit: 2d72dd14d77f31a7caa619fe0b889304844e612e

  reply	other threads:[~2025-06-11 22:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 12:36 [syzbot] [bpf?] KASAN: slab-use-after-free Read in do_check syzbot
2025-06-11 13:02 ` Eduard Zingerman
2025-06-11 14:03   ` Luis Gerhorst
2025-06-11 17:20     ` Eduard Zingerman
2025-06-11 21:07       ` [PATCH bpf-next] bpf: Fix state use-after-free on push_stack() err Luis Gerhorst
2025-06-11 22:23         ` Eduard Zingerman [this message]
2025-06-11 23:10         ` patchwork-bot+netdevbpf
2025-06-11 21:14       ` [PATCH bpf-next] bpf: Remove redundant free_verifier_state()/pop_stack() Luis Gerhorst
2025-06-11 22:36         ` Eduard Zingerman
2025-06-13  9:01           ` [PATCH bpf-next v2] " Luis Gerhorst
2025-06-13 21:17             ` Eduard Zingerman
2025-06-13 22:06               ` Alexei Starovoitov
2025-06-13  9:07           ` [PATCH bpf-next] " Luis Gerhorst
2025-06-11 21:32       ` [syzbot] [bpf?] KASAN: slab-use-after-free Read in do_check Luis Gerhorst
2025-06-11 21:43         ` Eduard Zingerman
2025-06-11 21:40 ` Eduard Zingerman
2025-06-11 23:00   ` syzbot

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=01c816691c132dd6c8c2588f396b240f033ce201.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=haoluo@google.com \
    --cc=henriette.herzog@rub.de \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luis.gerhorst@fau.de \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=syzbot+b5eb72a560b8149a1885@syzkaller.appspotmail.com \
    --cc=yonghong.song@linux.dev \
    /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.