From: Peter Zijlstra <peterz@infradead.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Soheil Hassas Yeganeh <soheil.kdev@gmail.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
X86 ML <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
LKML <linux-kernel@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
stable <stable@vger.kernel.org>
Subject: Re: [PATCH] x86/cfi: Fix FineIBT hash offset in cfi_get_func_hash()
Date: Wed, 9 Sep 2026 00:13:57 +0200 [thread overview]
Message-ID: <20260908221357.GY4120091@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAADnVQLu-XiLxz_k02YK9xCgM8guoszby3O_m00_vdq5X8-w5A@mail.gmail.com>
On Tue, Sep 08, 2026 at 09:37:46AM -0700, Alexei Starovoitov wrote:
> On Tue, Sep 8, 2026 at 6:22 AM Soheil Hassas Yeganeh
> <soheil.kdev@gmail.com> wrote:
> >
> > On Mon, Aug 31, 2026 at 10:49 AM Soheil Hassas Yeganeh
> > <soheil.kdev@gmail.com> wrote:
> > >
> > > The switch of the FineIBT preamble from "subl $hash, %r10d" to the
> > > shorter "subl $hash, %eax" moved the hash immediate from offset 7 to
> > > offset 5 of the preamble. fineibt_preamble_hash was updated to match,
> > > but the open-coded offset in cfi_get_func_hash() was missed and it
> > > still reads the hash at offset 7.
> > >
> > > cfi_get_func_hash() is used by the BPF JIT to give a struct_ops
> > > trampoline the CFI hash of the stub function it stands in for. With
> > > FineIBT the trampoline now gets the upper half of the real hash
> > > followed by the first two bytes of the next instruction, so the first
> > > indirect call from the kernel into a struct_ops program,
> > > tcp_init_congestion_control() calling ->init() of a BPF congestion
> > > control for example, fails the FineIBT check and the kernel dies with
> > > a CFI failure.
> > >
> > > Move the FineIBT preamble template and its offset defines above
> > > cfi_get_func_hash() and use fineibt_preamble_hash there, so every
> > > reader of the preamble shares one definition of its layout. The
> > > CFI_FINEIBT arm is only built with CONFIG_FINEIBT, the only
> > > configuration in which cfi_mode can take that value.
> > > cfi_get_func_arity() does not need the same treatment: the __bhi_args
> > > call whose displacement it reads still ends at the function address.
> > >
> > > Fixes: 85a2d4a890dc ("x86,ibt: Use UDB instead of 0xEA")
> >
> > Gentle ping on this one. To recap: since 85a2d4a890dc the FineIBT preamble
> > stores the hash at +5, but cfi_get_func_hash() still reads it at +7, so BPF
> > struct_ops trampolines are emitted with a wrong hash and the first indirect call
> > through them (e.g. a bpf tcp_congestion_ops .cong_control) hits a FineIBT #CP.
> >
> > We have large scale panics when we use BPF congestion control.
> > Happy to respin if a different shape is preferred (e.g. moving the
> > offset next to
> > the preamble definition), but this seemed like the best way to fix the issue.
>
> Looks fine to me. I guess it will go via tip tree?
Yes, I'll pick it up. Thanks!
next prev parent reply other threads:[~2026-09-08 22:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 14:48 Soheil Hassas Yeganeh
2026-09-08 13:22 ` Soheil Hassas Yeganeh
2026-09-08 16:37 ` Alexei Starovoitov
2026-09-08 22:13 ` Peter Zijlstra [this message]
2026-09-10 9:07 ` [tip: x86/urgent] " tip-bot2 for Soheil Hassas Yeganeh
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=20260908221357.GY4120091@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=bp@alien8.de \
--cc=daniel@iogearbox.net \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=soheil.kdev@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=x86@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
all inboxes | Powered by JetHome®