mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE()
@ 2026-06-11 15:57 Jens Remus
  2026-06-11 19:28 ` Peter Zijlstra
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jens Remus @ 2026-06-11 15:57 UTC (permalink / raw)
  To: Sami Tolvanen, Kees Cook, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-kernel, llvm
  Cc: Jens Remus, Heiko Carstens, Sashiko

Commit ccace936eec7 ("x86: Add types to indirectly called assembly
functions") introduced a x86-specific implementation of __CFI_TYPE()
using an asymmetric combination of SYM_START() and SYM_FUNC_END() to
add a symbol to the KCFI type identifier that precedes a function.

This asymmetric combination is an issue if SYM_FUNC_END() ever gets
extended in a way that requires it to be used symmetrically with
SYM_FUNC_START*().  For instance to emit DWARF CFI directives that
denote the start/end of a function. [1]

Use SYM_END() with SYM_T_FUNC instead.  No functional change, as the
generic implementation of SYM_FUNC_END(name) expands into
SYM_END(name, SYM_T_FUNC).

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260522110427.2816637-1-jremus@linux.ibm.com?part=3 [1]
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---

Notes (jremus):
    This patch applies on top of linus' tree (9716c086c8e8):
    
      git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git  master
    
    I verified as follows that in x86-64 builds of vmlinux using Clang with
    kCFI enabled without and with my patch applied vmlinux.o only differs in
    relocations targeting .rodata.str* and a few symbols in .rodata shifted
    (both likely due to differences in string merging):
    
    $ objdump -d vmlinux.o > vmlinux.o.{old|new}.objdump
    $ readelf -Wa vmlinux.o > vmlinux.o.{old|new}.readelf
    $ diff -u vmlinux.o.old.objdump vmlinux.o.new.objdump
    [no differences]
    $ diff -u0 vmlinux.o.old.readelf vmlinux.o.new.readelf | \
      grep --invert-match -E "\.rodata\.str|@@"
    [see above]

 arch/x86/include/asm/linkage.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h
index a7294656ad90..c9769a7b6e66 100644
--- a/arch/x86/include/asm/linkage.h
+++ b/arch/x86/include/asm/linkage.h
@@ -103,7 +103,7 @@
 	.byte 0xb8 ASM_NL					\
 	.long __kcfi_typeid_##name ASM_NL			\
 	CFI_POST_PADDING					\
-	SYM_FUNC_END(__cfi_##name)
+	SYM_END(__cfi_##name, SYM_T_FUNC)
 
 /* UML needs to be able to override memcpy() and friends for KASAN. */
 #ifdef CONFIG_UML
-- 
2.53.0


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

* Re: [PATCH] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE()
  2026-06-11 15:57 [PATCH] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE() Jens Remus
@ 2026-06-11 19:28 ` Peter Zijlstra
  2026-06-13 16:29 ` Nathan Chancellor
  2026-06-28 23:14 ` [tip: x86/cleanups] " tip-bot2 for Jens Remus
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2026-06-11 19:28 UTC (permalink / raw)
  To: Jens Remus
  Cc: Sami Tolvanen, Kees Cook, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-kernel, llvm, Heiko Carstens, Sashiko

On Thu, Jun 11, 2026 at 05:57:15PM +0200, Jens Remus wrote:
> Commit ccace936eec7 ("x86: Add types to indirectly called assembly
> functions") introduced a x86-specific implementation of __CFI_TYPE()
> using an asymmetric combination of SYM_START() and SYM_FUNC_END() to
> add a symbol to the KCFI type identifier that precedes a function.
> 
> This asymmetric combination is an issue if SYM_FUNC_END() ever gets
> extended in a way that requires it to be used symmetrically with
> SYM_FUNC_START*().  For instance to emit DWARF CFI directives that
> denote the start/end of a function. [1]
> 
> Use SYM_END() with SYM_T_FUNC instead.  No functional change, as the
> generic implementation of SYM_FUNC_END(name) expands into
> SYM_END(name, SYM_T_FUNC).
> 
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260522110427.2816637-1-jremus@linux.ibm.com?part=3 [1]
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE()
  2026-06-11 15:57 [PATCH] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE() Jens Remus
  2026-06-11 19:28 ` Peter Zijlstra
@ 2026-06-13 16:29 ` Nathan Chancellor
  2026-06-28 23:14 ` [tip: x86/cleanups] " tip-bot2 for Jens Remus
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2026-06-13 16:29 UTC (permalink / raw)
  To: Jens Remus
  Cc: Sami Tolvanen, Kees Cook, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kernel,
	llvm, Heiko Carstens, Sashiko

On Thu, Jun 11, 2026 at 05:57:15PM +0200, Jens Remus wrote:
> Commit ccace936eec7 ("x86: Add types to indirectly called assembly
> functions") introduced a x86-specific implementation of __CFI_TYPE()
> using an asymmetric combination of SYM_START() and SYM_FUNC_END() to
> add a symbol to the KCFI type identifier that precedes a function.
> 
> This asymmetric combination is an issue if SYM_FUNC_END() ever gets
> extended in a way that requires it to be used symmetrically with
> SYM_FUNC_START*().  For instance to emit DWARF CFI directives that
> denote the start/end of a function. [1]
> 
> Use SYM_END() with SYM_T_FUNC instead.  No functional change, as the
> generic implementation of SYM_FUNC_END(name) expands into
> SYM_END(name, SYM_T_FUNC).
> 
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260522110427.2816637-1-jremus@linux.ibm.com?part=3 [1]
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> Notes (jremus):
>     This patch applies on top of linus' tree (9716c086c8e8):
>     
>       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git  master
>     
>     I verified as follows that in x86-64 builds of vmlinux using Clang with
>     kCFI enabled without and with my patch applied vmlinux.o only differs in
>     relocations targeting .rodata.str* and a few symbols in .rodata shifted
>     (both likely due to differences in string merging):
>     
>     $ objdump -d vmlinux.o > vmlinux.o.{old|new}.objdump
>     $ readelf -Wa vmlinux.o > vmlinux.o.{old|new}.readelf
>     $ diff -u vmlinux.o.old.objdump vmlinux.o.new.objdump
>     [no differences]
>     $ diff -u0 vmlinux.o.old.readelf vmlinux.o.new.readelf | \
>       grep --invert-match -E "\.rodata\.str|@@"
>     [see above]
> 
>  arch/x86/include/asm/linkage.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h
> index a7294656ad90..c9769a7b6e66 100644
> --- a/arch/x86/include/asm/linkage.h
> +++ b/arch/x86/include/asm/linkage.h
> @@ -103,7 +103,7 @@
>  	.byte 0xb8 ASM_NL					\
>  	.long __kcfi_typeid_##name ASM_NL			\
>  	CFI_POST_PADDING					\
> -	SYM_FUNC_END(__cfi_##name)
> +	SYM_END(__cfi_##name, SYM_T_FUNC)
>  
>  /* UML needs to be able to override memcpy() and friends for KASAN. */
>  #ifdef CONFIG_UML
> -- 
> 2.53.0
> 

-- 
Cheers,
Nathan

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

* [tip: x86/cleanups] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE()
  2026-06-11 15:57 [PATCH] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE() Jens Remus
  2026-06-11 19:28 ` Peter Zijlstra
  2026-06-13 16:29 ` Nathan Chancellor
@ 2026-06-28 23:14 ` tip-bot2 for Jens Remus
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Jens Remus @ 2026-06-28 23:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Sashiko, Jens Remus, Borislav Petkov (AMD),
	Nathan Chancellor, Peter Zijlstra (Intel),
	x86, linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     0cfdf974f133e0ff17ed80e7895adbe7889d9522
Gitweb:        https://git.kernel.org/tip/0cfdf974f133e0ff17ed80e7895adbe7889d9522
Author:        Jens Remus <jremus@linux.ibm.com>
AuthorDate:    Thu, 11 Jun 2026 17:57:15 +02:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Sun, 28 Jun 2026 15:22:26 -07:00

x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE()

Commit

  ccace936eec7 ("x86: Add types to indirectly called assembly functions")

introduced a x86-specific implementation of __CFI_TYPE() using an asymmetric
combination of SYM_START() and SYM_FUNC_END() to add a symbol to the KCFI type
identifier that precedes a function.

This asymmetric combination is an issue if SYM_FUNC_END() ever gets extended
in a way that requires it to be used symmetrically with SYM_FUNC_START*().
For instance to emit DWARF CFI directives that denote the start/end of
a function. [1]

Use SYM_END() with SYM_T_FUNC instead.  No functional change, as the generic
implementation of SYM_FUNC_END(name) expands into SYM_END(name, SYM_T_FUNC).

Fixes: ccace936eec7 ("x86: Add types to indirectly called assembly functions")
Closes: https://sashiko.dev/#/patchset/20260522110427.2816637-1-jremus@linux.ibm.com?part=3 [1]
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260611155716.830563-1-jremus@linux.ibm.com
---
 arch/x86/include/asm/linkage.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h
index a729465..c9769a7 100644
--- a/arch/x86/include/asm/linkage.h
+++ b/arch/x86/include/asm/linkage.h
@@ -103,7 +103,7 @@
 	.byte 0xb8 ASM_NL					\
 	.long __kcfi_typeid_##name ASM_NL			\
 	CFI_POST_PADDING					\
-	SYM_FUNC_END(__cfi_##name)
+	SYM_END(__cfi_##name, SYM_T_FUNC)
 
 /* UML needs to be able to override memcpy() and friends for KASAN. */
 #ifdef CONFIG_UML

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

end of thread, other threads:[~2026-06-28 23:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-11 15:57 [PATCH] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE() Jens Remus
2026-06-11 19:28 ` Peter Zijlstra
2026-06-13 16:29 ` Nathan Chancellor
2026-06-28 23:14 ` [tip: x86/cleanups] " tip-bot2 for Jens Remus

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

all inboxes | Powered by JetHome®