Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH 0/6] s390: Add kCFI support
@ 2026-07-24 14:13 Heiko Carstens
  2026-07-24 14:13 ` [PATCH 1/6] s390/tools: Pass symbol name to do_relocs() Heiko Carstens
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Heiko Carstens @ 2026-07-24 14:13 UTC (permalink / raw)
  To: Stefan Schulze Frielinghaus, Juergen Christ, Ilya Leoshkevich,
	Dominik Steenken, Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
	Christian Borntraeger, Maxim Khmelevskii, Jens Remus,
	Sami Tolvanen, Kees Cook, Nathan Chancellor, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman,
	Kumar Kartikeya Dwivedi
  Cc: llvm, bpf, linux-s390, linux-kernel

Add s390 kCFI support using the generic support provided by clang.
This comes with a couple of limitations:

The generic kCFI implementation does not generate a .kcfi_traps section,
nor is a special instruction used in case a checksum mismatch is detected.

This means in case of a checksum mismatch the kernel just crashes.
It should be quite easy to tell by the surrounding code that a crash
happened because of a checksum mismatch.

If clang and/or gcc provide a .kcfi_traps section it will be possible to
print proper CFI messages instead of just crashing the kernel (enable
ARCH_USES_CFI_TRAPS).

In addition this also means that CFI_PERMISSIVE does not work. Even if the
option is selected the kernel will crash in case of a checksum mismatch.

However it seems to be acceptable to enable kCFI support to the kernel now
even if it is not perfect. Later s390 specific clang and gcc extensions are
required to improve this.

This passes all ftrace selftests. It also passes the kernel bpf selftests
(vmtest.sh), except those using the task work scheduling kfuncs. However
that appears to be a real bug and has been reported [1].

[1] https://lore.kernel.org/all/20260724112221.212464A3f-hca@linux.ibm.com/

Thanks,
Heiko

Heiko Carstens (6):
  s390/tools: Pass symbol name to do_relocs()
  s390/tools/relocs: Ignore __kcfi_typeid_ relocations
  s390: Add ftrace_stub_graph
  s390/diag: Generate CFI type information for assembly functions
  s390/Kconfig: Select ARCH_SUPPORTS_CFI
  s390/bpf: Add kCFI support

 arch/s390/Kconfig               |   1 +
 arch/s390/include/asm/cfi.h     |   7 ++
 arch/s390/kernel/mcount.S       |   7 +-
 arch/s390/kernel/text_amode31.S |  13 +--
 arch/s390/net/bpf_jit_comp.c    |  26 +++++-
 arch/s390/tools/relocs.c        | 158 +++++++++++++++++++++++++++++++-
 6 files changed, 198 insertions(+), 14 deletions(-)
 create mode 100644 arch/s390/include/asm/cfi.h

-- 
2.53.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-07-24 15:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 14:13 [PATCH 0/6] s390: Add kCFI support Heiko Carstens
2026-07-24 14:13 ` [PATCH 1/6] s390/tools: Pass symbol name to do_relocs() Heiko Carstens
2026-07-24 14:23   ` sashiko-bot
2026-07-24 15:14   ` bot+bpf-ci
2026-07-24 14:13 ` [PATCH 2/6] s390/tools/relocs: Ignore __kcfi_typeid_ relocations Heiko Carstens
2026-07-24 14:30   ` sashiko-bot
2026-07-24 14:13 ` [PATCH 3/6] s390: Add ftrace_stub_graph Heiko Carstens
2026-07-24 14:21   ` sashiko-bot
2026-07-24 15:14   ` bot+bpf-ci
2026-07-24 14:13 ` [PATCH 4/6] s390/diag: Generate CFI type information for assembly functions Heiko Carstens
2026-07-24 14:26   ` sashiko-bot
2026-07-24 14:13 ` [PATCH 5/6] s390/Kconfig: Select ARCH_SUPPORTS_CFI Heiko Carstens
2026-07-24 14:37   ` sashiko-bot
2026-07-24 14:13 ` [PATCH 6/6] s390/bpf: Add kCFI support Heiko Carstens
2026-07-24 14:34   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox