Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>
Cc: "Mark Brown" <broonie@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	linux-toolchains@vger.kernel.org, "Song Liu" <song@kernel.org>,
	"Petr Mladek" <pmladek@suse.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	live-patching@vger.kernel.org,
	"Joe Lawrence" <joe.lawrence@redhat.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Kees Cook" <kees@kernel.org>, "Miroslav Benes" <mbenes@suse.cz>,
	"Nick Desaulniers" <ndesaulniers@google.com>
Subject: Re: [PATCH 01/12] arm64/bti: Add BTI landing pad to __sdei_asm_handler()
Date: Sat, 15 Aug 2026 05:01:45 +0000	[thread overview]
Message-ID: <20260815050146.1C6D91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <99226432cc316215829655c787f71a70f06d1600.1786768375.git.jpoimboe@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing BTI landing pads (`bti j`) on indirect branch targets in the KPTI trampoline (`__sdei_asm_exit_trampoline` and `tramp_exit`).
- [High] The KPTI entry trampoline mapping at `TRAMP_VALIAS` lacks the BTI Guarded Page (`PTE_GP`) attribute, disabling hardware CFI checks.
--

--- Patch [1]: [PATCH 01/12] arm64/bti: Add BTI landing pad to __sdei_asm_handler() ---
commit 59fadd16326c687a5994c4bec81d9484edcc08f9
Author: Josh Poimboeuf <jpoimboe@kernel.org>

arm64/bti: Add BTI landing pad to __sdei_asm_handler()

With CONFIG_UNMAP_KERNEL_AT_EL0, __sdei_asm_entry_trampoline() indirect
jumps to __sdei_asm_handler(). Add "bti j" to prevent a Branch Target
exception.

> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index e0db14e9c843a..16c21fcb41976 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -976,6 +976,7 @@ NOKPROBE(__sdei_asm_exit_trampoline)

[Severity: High]
This is a pre-existing issue, but do we also need bti j landing pads on the
indirect branch targets for the exit paths?

For example, __sdei_asm_exit_trampoline() is called via an indirect branch
(br x5):

arch/arm64/kernel/entry.S:__sdei_asm_exit_trampoline() {
    SYM_CODE_START(__sdei_asm_exit_trampoline)
        ldr x4, [x4, #(SDEI_EVENT_INTREGS + S_SDEI_TTBR1)]
        ...
}

Similarly, tramp_exit() in the same file lacks a landing pad despite being
called via an indirect branch (br x29) on the EL0 exit path:

arch/arm64/kernel/entry.S:tramp_exit() {
    SYM_CODE_START_LOCAL(tramp_exit)
        tramp_unmap_kernel x29
        ...
}

Would it be better to add bti j annotations to these functions as well to
prevent Branch Target exceptions?


[Severity: High]
This isn't a bug introduced by this patch, but does the KPTI trampoline mapping
need the BTI Guarded Page (PTE_GP) attribute?

Looking at map_entry_trampoline() in arch/arm64/mm/mmu.c, it uses
kernel_exec_prot() to map the trampoline text:

arch/arm64/mm/mmu.c:map_entry_trampoline() {
    pgprot_t prot = kernel_exec_prot();
    ...
    early_create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS,
                             entry_tramp_text_size(), prot,
                             pgd_pgtable_alloc_init_mm, NO_BLOCK_MAPPINGS);
}

The prot variable is derived from PAGE_KERNEL_ROX, which does not appear to
contain the PTE_GP bit. Does this inadvertently disable hardware BTI enforcement
for the trampoline pages? If so, could this architectural gap be masking the
missing bti j annotations on the trampoline exit paths mentioned above?

>   * want them.
>   */
>  SYM_CODE_START(__sdei_asm_handler)
> +	bti	j
>  	stp     x2, x3, [x1, #SDEI_EVENT_INTREGS + S_PC]
>  	stp     x4, x5, [x1, #SDEI_EVENT_INTREGS + 16 * 2]
>  	stp     x6, x7, [x1, #SDEI_EVENT_INTREGS + 16 * 3]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1786768375.git.jpoimboe@kernel.org?part=1


  reply	other threads:[~2026-08-15  5:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15  4:45 [PATCH 00/12] arm64/bti: Fix kernel BTI issues with livepatch, large kernels, toolchains Josh Poimboeuf
2026-08-15  4:45 ` [PATCH 01/12] arm64/bti: Add BTI landing pad to __sdei_asm_handler() Josh Poimboeuf
2026-08-15  5:01   ` sashiko-bot [this message]
2026-08-15  4:45 ` [PATCH 02/12] arm64/module: Fix BTI exceptions caused by omitted landing pads in Clang 21 Josh Poimboeuf
2026-08-15  5:00   ` sashiko-bot
2026-08-15  9:56   ` Ard Biesheuvel
2026-08-15  4:45 ` [PATCH 03/12] arm64/bti: Fix BTI linker failures with long branches into .idmap.text Josh Poimboeuf
2026-08-15  4:45 ` [PATCH 04/12] arm64/bti: Work around ld crash caused by linker script aliases Josh Poimboeuf
2026-08-15  4:45 ` [PATCH 05/12] arm64/bti: Add link error for large kernels with BTI and unsupported toolchains Josh Poimboeuf
2026-08-15  4:45 ` [PATCH 06/12] arm64/bti: Add link error for large kernels with BTI and livepatch Josh Poimboeuf
2026-08-15  4:45 ` [PATCH 07/12] arm64/bti: Advertise BTI in assembly objects Josh Poimboeuf
2026-08-15  5:03   ` sashiko-bot
2026-08-15  4:45 ` [PATCH 08/12] arm64/bti: Enable BTI in the pi/ startup code Josh Poimboeuf
2026-08-15  4:45 ` [PATCH 09/12] efi/libstub: Preserve the GNU property note Josh Poimboeuf
2026-08-15  4:45 ` [PATCH 10/12] efi/libstub: Remove obsolete .note.gnu.property workaround Josh Poimboeuf
2026-08-15  4:45 ` [PATCH 11/12] arm64/bti: Force-enable BTI linker veneers Josh Poimboeuf
2026-08-15  5:00   ` sashiko-bot
2026-08-15  4:45 ` [PATCH 12/12] arm64/bti: Enable kernel BTI for GCC Josh Poimboeuf

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=20260815050146.1C6D91F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ardb@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mbenes@suse.cz \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=pmladek@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=song@kernel.org \
    --cc=will@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