[PATCH 2/3] arm64: Re-enable kernel BTI for compatible linkers

Nick Desaulniers ndesaulniers at google.com
Tue Nov 24 13:13:45 PST 2026


On Thu, Nov 19, 2026 at 3:38 PM Ard Biesheuvel <ardb at kernel.org> wrote:
>
>
>
> On Fri, 20 Nov 2026, at 00:22, Nick Desaulniers wrote:
> > On Thu, Nov 19, 2026 at 8:58 AM Ard Biesheuvel <ardb+git at google.com> wrote:
> >>
> >> From: Ard Biesheuvel <ardb at kernel.org>
> >>
> >> The compiler is permitted to omit BTI landing pads from static functions
> >> that never have their address taken, but are only called directly, even
> >> if those calls originate from other code sections. This causes problems
> >> for calls from .init.text into .text if those sections are placed far
> >> apart, as veneers involving indirect calls will be used in that case.
> >>
> >> Now that .text and .init.text are combined, this can no longer happen,
> >> and so we can re-enable kernel mode BTI under two conditions:
> >>
> >> - live patch is disabled - it also needs BTI landings pads on functions
> >>   with static linkage inside vmlinux that were never exported (and
> >>   therefore never had their address taken)
> >>
> >> - landings pads are emitted even in pathological cases where the size of
> >>   vmlinux's .text segment exceeds the range of a direct branch, and the
> >>   linker needs to emit landing pads at the callee end so that the
> >>   veneers can call them without causing a BTI fault.
> >>
> >> Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
> >> ---
> >>  arch/arm64/Kconfig | 17 +++++++++++------
> >>  1 file changed, 11 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> >> index 1075bc661833..f0fb2d7ff130 100644
> >> --- a/arch/arm64/Kconfig
> >> +++ b/arch/arm64/Kconfig
> >> @@ -2202,18 +2202,23 @@ config ARM64_BTI
> >>           BTI, such binaries can still run, but you get no additional
> >>           enforcement of branch destinations.
> >>
> >> +config LD_HAS_BTI_STUBS
> >> +       # A linker may need to insert a veneer when a call to a function with
> >> +       # static linkage in the same compilation unit but in a different
> >> +       # section is out of range for a direct branch instruction. Such a
> >> +       # veneer performs an indirect call, and thus requires a landing pad
> >> +       # under BTI, which the static function may lack. Only recent linkers
> >> +       # are guaranteed to emit those landing pads correctly in all cases.
> >> +       def_bool (LD_IS_BFD && LD_VERSION >= 24200) || \

IIUC, it looks like BFD 2.41 was the first release to contain the two
commits cited from your sourceware link below.

https://sourceware.org/git?p=binutils-gdb.git;a=commit;h=15b4f66b0a9a3be6caf1898d22a13c39e662006f
https://sourceware.org/git?p=binutils-gdb.git;a=commit;h=5834f36d93cabf1a8bcc7dd7654141aed3d296bc

$ cd binutils-gdb
$ git describe --contains "15b4f66b0a9a3be6caf1898d22a13c39e662006f"
binutils-2_41~1223
$ git describe --contains 5834f36d93cabf1a8bcc7dd7654141aed3d296bc
binutils-2_41~1222

So you might be able to relax that version check to be 24100 rather than 24200.

Unless there's another relevant issue?

LLD version check looks good.

Maybe other potentially useful trailers:

Link: https://github.com/ARM-software/abi-aa/issues/196
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671

> >> +                (LD_IS_LLD && LLD_VERSION >= 200000)
> >
> > A bit of a rock fetching quest (sorry), but it would make it easier
> > for reviewers to verify these version checks if you had git trailers
> > linking to commits (or bug reports) for these linkers with the
> > relevant fix.  I don't think that necessitates a v2, if the
> > maintainers you're expecting to pick up this series are kind enough to
> > manually re-add them (unless b4 can pick up `Link:` trailers like
> > that).
> >
>
> Fair point.
>
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=30076
> Link: https://github.com/llvm/llvm-project/pull/108989
>
>


-- 
Thanks,
~Nick Desaulniers



More information about the linux-arm-kernel mailing list