The reproducer did what you said on an IBT amd64 box and I confirm the 
SIGILL.

But the same reproducer did not SIGILL for me on my BT aarch64 laptop. 
Does it need a different reproducer to trigger it on that platform?


On Sat, 12 Sep 2026, Theo Buehler wrote:

> running ruff on a modern intel laptop results in this:
> 
> PSIG  SIGILL SIG_DFL code=ILL_BTCFI addr=0x1f232ae9cc0 trapno=21
> 
> Program terminated with signal SIGILL, Illegal instruction.
> #0  rust_psm_stack_pointer () at src/arch/x86_64.s:42
> 
> Diff below fixes it. It's taken from volker's PR:
> https://github.com/rust-lang/stacker/pull/81
> 
> I don't have a bti-capable arm64 machine, so it's only compile tested
> there.
> 
> To reproduce: 
> 
> $ echo 'print("boo")' > boo.py
> $ ruff check boo.py
> Illegal instruction (core dumped)
> 
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/devel/ruff/Makefile,v
> diff -u -p -r1.19 Makefile
> --- Makefile  9 Sep 2026 09:23:23 -0000       1.19
> +++ Makefile  12 Sep 2026 16:20:08 -0000
> @@ -4,6 +4,7 @@ NOT_FOR_ARCHS =       sparc64
>  COMMENT =    Python linter and code formatter
>  
>  MODPY_DISTV =        0.16.6
> +REVISION =   0
>  
>  GH_ACCOUNT = astral-sh
>  GH_PROJECT = ruff
> Index: patches/patch-modcargo-crates_psm-0_1_32_src_arch_aarch64_armasm_asm
> ===================================================================
> RCS file: patches/patch-modcargo-crates_psm-0_1_32_src_arch_aarch64_armasm_asm
> diff -N patches/patch-modcargo-crates_psm-0_1_32_src_arch_aarch64_armasm_asm
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-modcargo-crates_psm-0_1_32_src_arch_aarch64_armasm_asm      
> 12 Sep 2026 15:58:25 -0000
> @@ -0,0 +1,38 @@
> +Missing BTI landing pads
> +https://github.com/rust-lang/stacker/pull/81
> +
> +Index: modcargo-crates/psm-0.1.32/src/arch/aarch64_armasm.asm
> +--- modcargo-crates/psm-0.1.32/src/arch/aarch64_armasm.asm.orig
> ++++ modcargo-crates/psm-0.1.32/src/arch/aarch64_armasm.asm
> +@@ -3,6 +3,7 @@
> +     GLOBAL |rust_psm_stack_direction|
> +     ALIGN 4
> + |rust_psm_stack_direction| PROC
> ++    bti c
> +     orr w0, wzr, #2
> +     ret
> +     ENDP
> +@@ -11,6 +12,7 @@
> +     GLOBAL |rust_psm_stack_pointer|
> +     ALIGN 4
> + |rust_psm_stack_pointer| PROC
> ++    bti c
> +     mov x0, sp
> +     ret
> +     ENDP
> +@@ -19,6 +21,7 @@
> +     GLOBAL |rust_psm_replace_stack|
> +     ALIGN 4
> + |rust_psm_replace_stack| PROC
> ++    bti c
> +     mov sp, x2
> +     br x1
> +     ENDP
> +@@ -26,6 +29,7 @@
> +     GLOBAL |rust_psm_on_stack|
> +     ALIGN 4
> + |rust_psm_on_stack| PROC
> ++    bti c
> +     stp x29, x30, [sp, #-16]!
> +     mov x29, sp
> +     mov sp, x3
> Index: patches/patch-modcargo-crates_psm-0_1_32_src_arch_aarch_aapcs64_s
> ===================================================================
> RCS file: patches/patch-modcargo-crates_psm-0_1_32_src_arch_aarch_aapcs64_s
> diff -N patches/patch-modcargo-crates_psm-0_1_32_src_arch_aarch_aapcs64_s
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-modcargo-crates_psm-0_1_32_src_arch_aarch_aapcs64_s 12 Sep 
> 2026 15:58:36 -0000
> @@ -0,0 +1,38 @@
> +Missing bti landing pads
> +https://github.com/rust-lang/stacker/pull/81
> +
> +Index: modcargo-crates/psm-0.1.32/src/arch/aarch_aapcs64.s
> +--- modcargo-crates/psm-0.1.32/src/arch/aarch_aapcs64.s.orig
> ++++ modcargo-crates/psm-0.1.32/src/arch/aarch_aapcs64.s
> +@@ -33,6 +33,7 @@ TYPE(rust_psm_stack_direction)
> + FUNCTION(rust_psm_stack_direction):
> + /* extern "C" fn() -> u8 */
> + .cfi_startproc
> ++    bti c
> +     orr w0, wzr, #STACK_DIRECTION_DESCENDING
> +     ret
> + END_FUNCTION(rust_psm_stack_direction)
> +@@ -45,6 +46,7 @@ TYPE(rust_psm_stack_pointer)
> + FUNCTION(rust_psm_stack_pointer):
> + /* extern "C" fn() -> *mut u8 */
> + .cfi_startproc
> ++    bti c
> +     mov x0, sp
> +     ret
> + END_FUNCTION(rust_psm_stack_pointer)
> +@@ -58,6 +60,7 @@ FUNCTION(rust_psm_replace_stack):
> + /* extern "C" fn(r0: usize, r1: extern "C" fn(usize), r2: *mut u8) */
> + .cfi_startproc
> + /* All we gotta do is set the stack pointer to %rdx & tail-call the 
> callback in %rsi */
> ++    bti c
> +     mov sp, x2
> +     br x1
> + END_FUNCTION(rust_psm_replace_stack)
> +@@ -70,6 +73,7 @@ TYPE(rust_psm_on_stack)
> + FUNCTION(rust_psm_on_stack):
> + /* extern "C" fn(r0: usize, r1: usize, r2: extern "C" fn(usize, usize), r3: 
> *mut u8) */
> + .cfi_startproc
> ++    bti c
> +     stp x29, x30, [sp, #-16]!
> +     .cfi_def_cfa sp, 16
> +     mov x29, sp
> Index: patches/patch-modcargo-crates_psm-0_1_32_src_arch_x86_64_s
> ===================================================================
> RCS file: patches/patch-modcargo-crates_psm-0_1_32_src_arch_x86_64_s
> diff -N patches/patch-modcargo-crates_psm-0_1_32_src_arch_x86_64_s
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-modcargo-crates_psm-0_1_32_src_arch_x86_64_s        12 Sep 
> 2026 16:31:47 -0000
> @@ -0,0 +1,51 @@
> +Missing ibt landing pads
> +https://github.com/rust-lang/stacker/pull/81
> +
> +Index: modcargo-crates/psm-0.1.32/src/arch/x86_64.s
> +--- modcargo-crates/psm-0.1.32/src/arch/x86_64.s.orig
> ++++ modcargo-crates/psm-0.1.32/src/arch/x86_64.s
> +@@ -2,6 +2,12 @@
> + #include "gnu_stack_note.s"
> + /* NOTE: sysv64 calling convention is used on all x86_64 targets, including 
> Windows! */
> + 
> ++#ifdef __CET__
> ++#include <cet.h>
> ++#else
> ++#define _CET_ENDBR
> ++#endif
> ++
> + .text
> + 
> + #if defined(CFG_TARGET_OS_darwin) || defined(CFG_TARGET_OS_macos) || 
> defined(CFG_TARGET_OS_ios) || defined(CFG_TARGET_OS_tvos)
> +@@ -27,6 +33,7 @@ TYPE(rust_psm_stack_direction)
> + FUNCTION(rust_psm_stack_direction):
> + /* extern "sysv64" fn() -> u8 (%al) */
> + .cfi_startproc
> ++    _CET_ENDBR
> +     movb $STACK_DIRECTION_DESCENDING, %al # always descending on x86_64
> +     retq
> + END_FUNCTION(rust_psm_stack_direction)
> +@@ -39,6 +46,7 @@ TYPE(rust_psm_stack_pointer)
> + FUNCTION(rust_psm_stack_pointer):
> + /* extern "sysv64" fn() -> *mut u8 (%rax) */
> + .cfi_startproc
> ++    _CET_ENDBR
> +     leaq 8(%rsp), %rax
> +     retq
> + .rust_psm_stack_pointer_end:
> +@@ -58,6 +66,7 @@ FUNCTION(rust_psm_replace_stack):
> +     8-byte offset necessary to account for the "return" pointer that would 
> otherwise be placed onto
> +     stack with a regular call
> + */
> ++    _CET_ENDBR
> +     leaq -8(%rdx), %rsp
> +     jmpq *%rsi
> + .rust_psm_replace_stack_end:
> +@@ -71,6 +80,7 @@ TYPE(rust_psm_on_stack)
> + FUNCTION(rust_psm_on_stack):
> + /* extern "sysv64" fn(%rdi: usize, %rsi: usize, %rdx: extern "sysv64" 
> fn(usize, usize), %rcx: *mut u8) */
> + .cfi_startproc
> ++    _CET_ENDBR
> +     pushq %rbp
> +     .cfi_def_cfa %rsp, 16
> +     .cfi_offset %rbp, -16
> 
> 

Reply via email to