Re: [PATCH 2/2] x86/fineibt: Poison ENDBR at +0

From: Peter Zijlstra
Date: Wed Jun 21 2023 - 04:53:59 EST


On Tue, Jun 20, 2023 at 05:04:50PM -0700, Sami Tolvanen wrote:
> On Tue, Jun 20, 2023 at 2:55 PM Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> >
> > On Thu, Jun 15, 2023 at 09:35:48PM +0200, Peter Zijlstra wrote:
> > > Alyssa noticed that when building the kernel with CFI_CLANG+IBT and
> > > booting on IBT enabled hardware obtain FineIBT, the indirect functions
> > > look like:
> > >
> > > __cfi_foo:
> > > endbr64
> > > subl $hash, %r10d
> > > jz 1f
> > > ud2
> > > nop
> > > 1:
> > > foo:
> > > endbr64
> > >
> > > This is because clang currently does not supress ENDBR emission for
> > > functions it provides a __cfi prologue symbol for.
> >
> > Should this be considered a bug in Clang?
>
> The endbr is needed with KCFI if we have FineIBT disabled for some
> reason. There's some discussion here:
>
> https://github.com/ClangBuiltLinux/linux/issues/1735
>
> However, since the kernel handles FineIBT patching, it might be
> cleaner to let it also poison the extra endbr.

That's what I get for replying before reading all replies. Anyway, we're
in agreement.