From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>, bpf@vger.kernel.org
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
<linux-kernel@vger.kernel.org>
Subject: Re: [BUG] bpf: x86 timed may_goto corrupts private-stack JIT state
Date: Tue, 25 Aug 2026 18:09:56 -0700 [thread overview]
Message-ID: <DKYH3KM93BDY.1MR4WLZSWGEU8@gmail.com> (raw)
In-Reply-To: <20260824213158.3755932-2-Jeremy.Jean@oss.cyber.gouv.fr>
On Mon Aug 24, 2026 at 2:31 PM PDT, Jérémy Jean wrote:
> Hello,
>
> With the help of AI models, I found a bug in the x86 timed may_goto path that
> leads to a verifier/JIT state mismatch on private-stack programs.
>
> The root cause is that timed may_goto fixups pass a stack offset in BPF_REG_AX
> and the x86 trampoline reconstructs the counter pointer from native %rbp. That
> is incorrect once private-stack JIT mode is enabled: ordinary BPF frame pointer
> accesses are remapped from %rbp to %r9, but arch_bpf_timed_may_goto() still
> uses %rbp and ends up reading and writing the native JIT frame instead of the
> private BPF stack.
>
> The bug was introduced by 2fb761823ead ("bpf, x86: Add x86 JIT support for timed
> may_goto"). I reproduced it on a KASAN-enabled x86_64 kernel based on v7.2,
> however KASAN does not trigger because the bad write stays inside the native
> JIT frame. Yet, the saved-register corruption is observable.
>
> I have not included a patch here because the fix seems subtle to me and would
> likely touch many files for different arch.
>
> I can share the minimal reproducer and other details privately with maintainers
> if useful.
Just send a fix and a selftest to the list.
prev parent reply other threads:[~2026-08-26 1:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 21:31 [BUG] bpf: x86 timed may_goto corrupts private-stack JIT state Jérémy Jean
2026-08-26 1:09 ` Alexei Starovoitov [this message]
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=DKYH3KM93BDY.1MR4WLZSWGEU8@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=Jeremy.Jean@oss.cyber.gouv.fr \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox