public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer
@ 2026-03-16  9:28 Vincent Donnefort
  2026-03-16 11:06 ` Arnd Bergmann
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Vincent Donnefort @ 2026-03-16  9:28 UTC (permalink / raw)
  To: maz
  Cc: rostedt, arnd, nathan, linux-trace-kernel, kvmarm, kernel-team,
	Vincent Donnefort

Compiler and tooling-generated symbols are difficult to maintain
across all supported architectures. Make the allowlist more robust by
replacing the harcoded list with a mechanism that automatically detects
these symbols.

This mechanism generates a C function designed to trigger common
compiler-inserted symbols.

Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

---

Changes in v3:

  - Enforce KASAN to ensure FORTIFY_SOURCE isn't disabled on some arch (Nathan) 

Changes in v2:

  - Use filechk (Nathan)
  - Removed deprecated extra-y (Nathan)
  - Added simple_ring_buffer in allowlist (Nathan)
  - Added memcpy() to generate more symbols (Nathan)
  - Added __sancov 

diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index beb15936829d..f4503a001d4c 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -136,17 +136,47 @@ obj-$(CONFIG_TRACE_REMOTE_TEST) += remote_test.o
 # simple_ring_buffer is used by the pKVM hypervisor which does not have access
 # to all kernel symbols. Fail the build if forbidden symbols are found.
 #
-UNDEFINED_ALLOWLIST := memset alt_cb_patch_nops __x86 __ubsan __asan __kasan __gcov __aeabi_unwind
-UNDEFINED_ALLOWLIST += __stack_chk_fail stackleak_track_stack __ref_stack __sanitizer llvm_gcda llvm_gcov
-UNDEFINED_ALLOWLIST += .TOC\. __clear_pages_unrolled __memmove copy_page warn_slowpath_fmt
-UNDEFINED_ALLOWLIST += ftrace_likely_update __hwasan_load __hwasan_store __hwasan_tag_memory
-UNDEFINED_ALLOWLIST += warn_bogus_irq_restore __stack_chk_guard
-UNDEFINED_ALLOWLIST := $(addprefix -e , $(UNDEFINED_ALLOWLIST))
+# undefsyms_base generates a set of compiler and tooling-generated symbols that can
+# safely be ignored for simple_ring_buffer.
+#
+filechk_undefsyms_base = \
+	echo '$(pound)include <linux/atomic.h>'; \
+	echo '$(pound)include <linux/string.h>'; \
+	echo '$(pound)include <asm/page.h>'; \
+	echo 'static char page[PAGE_SIZE] __aligned(PAGE_SIZE);'; \
+	echo 'void undefsyms_base(void *p, int n);'; \
+	echo 'void undefsyms_base(void *p, int n) {'; \
+	echo '	char buffer[256] = { 0 };'; \
+	echo '	u32 u = 0;'; \
+	echo '	memset((char * volatile)page, 8, PAGE_SIZE);'; \
+	echo '	memset((char * volatile)buffer, 8, sizeof(buffer));'; \
+	echo '	memcpy((void * volatile)p, buffer, sizeof(buffer));'; \
+	echo '	cmpxchg((u32 * volatile)&u, 0, 8);'; \
+	echo '	WARN_ON(n == 0xdeadbeef);'; \
+	echo '}'
+
+$(obj)/undefsyms_base.c: FORCE
+	$(call filechk,undefsyms_base)
+
+clean-files += undefsyms_base.c
+
+$(obj)/undefsyms_base.o: $(obj)/undefsyms_base.c
+
+targets += undefsyms_base.o
+
+# Ensure KASAN is enabled to avoid logic that may disable FORTIFY_SOURCE when
+# KASAN is not enabled. undefsyms_base.o does not automatically get KASAN flags
+# because it is not linked into vmlinux.
+KASAN_SANITIZE_undefsyms_base.o := y
+
+UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov __sanitizer __tsan __ubsan __x86_indirect_thunk \
+		      simple_ring_buffer \
+		      $(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '{print $$2}')
 
 quiet_cmd_check_undefined = NM      $<
-      cmd_check_undefined = test -z "`$(NM) -u $< | grep -v $(UNDEFINED_ALLOWLIST)`"
+      cmd_check_undefined = test -z "`$(NM) -u $< | grep -v $(addprefix -e , $(UNDEFINED_ALLOWLIST))`"
 
-$(obj)/%.o.checked: $(obj)/%.o FORCE
+$(obj)/%.o.checked: $(obj)/%.o $(obj)/undefsyms_base.o FORCE
 	$(call if_changed,check_undefined)
 
 always-$(CONFIG_SIMPLE_RING_BUFFER) += simple_ring_buffer.o.checked

base-commit: 33f2e266515717c4b2df585dadefa0525557726c
-- 
2.53.0.851.ga537e3e6e9-goog


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

* Re: [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer
  2026-03-16  9:28 [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer Vincent Donnefort
@ 2026-03-16 11:06 ` Arnd Bergmann
  2026-03-16 14:09 ` Steven Rostedt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2026-03-16 11:06 UTC (permalink / raw)
  To: Vincent Donnefort, Marc Zyngier
  Cc: Steven Rostedt, Nathan Chancellor, linux-trace-kernel, kvmarm,
	kernel-team

On Mon, Mar 16, 2026, at 10:28, Vincent Donnefort wrote:
> Compiler and tooling-generated symbols are difficult to maintain
> across all supported architectures. Make the allowlist more robust by
> replacing the harcoded list with a mechanism that automatically detects
> these symbols.
>
> This mechanism generates a C function designed to trigger common
> compiler-inserted symbols.
>
> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> Tested-by: Nathan Chancellor <nathan@kernel.org>

Added to my randconfig build setup now, I'll let you know if
any regressions remain.

      Arnd

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

* Re: [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer
  2026-03-16  9:28 [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer Vincent Donnefort
  2026-03-16 11:06 ` Arnd Bergmann
@ 2026-03-16 14:09 ` Steven Rostedt
  2026-03-17  9:04   ` Marc Zyngier
  2026-03-16 20:47 ` Arnd Bergmann
  2026-03-17  9:03 ` Marc Zyngier
  3 siblings, 1 reply; 8+ messages in thread
From: Steven Rostedt @ 2026-03-16 14:09 UTC (permalink / raw)
  To: Vincent Donnefort
  Cc: maz, arnd, nathan, linux-trace-kernel, kvmarm, kernel-team

On Mon, 16 Mar 2026 09:28:45 +0000
Vincent Donnefort <vdonnefort@google.com> wrote:

> Compiler and tooling-generated symbols are difficult to maintain
> across all supported architectures. Make the allowlist more robust by
> replacing the harcoded list with a mechanism that automatically detects
> these symbols.
> 
> This mechanism generates a C function designed to trigger common
> compiler-inserted symbols.
> 
> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> Tested-by: Nathan Chancellor <nathan@kernel.org>

I take it that Marc will take this?

Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve

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

* Re: [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer
  2026-03-16  9:28 [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer Vincent Donnefort
  2026-03-16 11:06 ` Arnd Bergmann
  2026-03-16 14:09 ` Steven Rostedt
@ 2026-03-16 20:47 ` Arnd Bergmann
  2026-03-16 20:48   ` Arnd Bergmann
  2026-03-17  9:03 ` Marc Zyngier
  3 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2026-03-16 20:47 UTC (permalink / raw)
  To: Vincent Donnefort, Marc Zyngier
  Cc: Steven Rostedt, Nathan Chancellor, linux-trace-kernel, kvmarm,
	kernel-team

On Mon, Mar 16, 2026, at 10:28, Vincent Donnefort wrote:
> Compiler and tooling-generated symbols are difficult to maintain
> across all supported architectures. Make the allowlist more robust by
> replacing the harcoded list with a mechanism that automatically detects
> these symbols.
>
> This mechanism generates a C function designed to trigger common
> compiler-inserted symbols.
>
> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> Tested-by: Nathan Chancellor <nathan@kernel.org>

Tested-by: Arnd Bergmann <arnd@arndb.de>

A few hundred randconfig builds in, I came across a single build failure
that you missed:

> +UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov 
> __sanitizer __tsan __ubsan __x86_indirect_thunk \
> +		      simple_ring_buffer \

This needs "__kmsan" as well, for these symbols:

                 U __msan_chain_origin
                 U __msan_get_context_state
                 U __msan_instrument_asm_store
                 U __msan_metadata_ptr_for_load_4
                 U __msan_metadata_ptr_for_load_8
                 U __msan_metadata_ptr_for_store_4
                 U __msan_metadata_ptr_for_store_8
                 U __msan_warning

     Arnd

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

* Re: [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer
  2026-03-16 20:47 ` Arnd Bergmann
@ 2026-03-16 20:48   ` Arnd Bergmann
  2026-03-17  9:04     ` Marc Zyngier
  0 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2026-03-16 20:48 UTC (permalink / raw)
  To: Vincent Donnefort, Marc Zyngier
  Cc: Steven Rostedt, Nathan Chancellor, linux-trace-kernel, kvmarm,
	kernel-team

On Mon, Mar 16, 2026, at 21:47, Arnd Bergmann wrote:
>
> This needs "__kmsan" as well, for these symbols:
>

"__msan" of course, not "__kmsan".

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

* Re: [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer
  2026-03-16  9:28 [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer Vincent Donnefort
                   ` (2 preceding siblings ...)
  2026-03-16 20:47 ` Arnd Bergmann
@ 2026-03-17  9:03 ` Marc Zyngier
  3 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2026-03-17  9:03 UTC (permalink / raw)
  To: Vincent Donnefort
  Cc: rostedt, arnd, nathan, linux-trace-kernel, kvmarm, kernel-team

On Mon, 16 Mar 2026 09:28:45 +0000, Vincent Donnefort wrote:
> Compiler and tooling-generated symbols are difficult to maintain
> across all supported architectures. Make the allowlist more robust by
> replacing the harcoded list with a mechanism that automatically detects
> these symbols.
> 
> This mechanism generates a C function designed to trigger common
> compiler-inserted symbols.
> 
> [...]

Applied to next, thanks!

[1/1] tracing: Generate undef symbols allowlist for simple_ring_buffer
      commit: 1211907ac0b5f35e5720620c50b7ca3c72d81f7e

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.



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

* Re: [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer
  2026-03-16 20:48   ` Arnd Bergmann
@ 2026-03-17  9:04     ` Marc Zyngier
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2026-03-17  9:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Vincent Donnefort, Steven Rostedt, Nathan Chancellor,
	linux-trace-kernel, kvmarm, kernel-team

On Mon, 16 Mar 2026 20:48:09 +0000,
"Arnd Bergmann" <arnd@arndb.de> wrote:
> 
> On Mon, Mar 16, 2026, at 21:47, Arnd Bergmann wrote:
> >
> > This needs "__kmsan" as well, for these symbols:
> >
> 
> "__msan" of course, not "__kmsan".

Folded that in the patch.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

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

* Re: [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer
  2026-03-16 14:09 ` Steven Rostedt
@ 2026-03-17  9:04   ` Marc Zyngier
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2026-03-17  9:04 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Vincent Donnefort, arnd, nathan, linux-trace-kernel, kvmarm,
	kernel-team

On Mon, 16 Mar 2026 14:09:29 +0000,
Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Mon, 16 Mar 2026 09:28:45 +0000
> Vincent Donnefort <vdonnefort@google.com> wrote:
> 
> > Compiler and tooling-generated symbols are difficult to maintain
> > across all supported architectures. Make the allowlist more robust by
> > replacing the harcoded list with a mechanism that automatically detects
> > these symbols.
> > 
> > This mechanism generates a C function designed to trigger common
> > compiler-inserted symbols.
> > 
> > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> > Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> > Tested-by: Nathan Chancellor <nathan@kernel.org>
> 
> I take it that Marc will take this?

Yup, now merged.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

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

end of thread, other threads:[~2026-03-17  9:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16  9:28 [PATCH v3] tracing: Generate undef symbols allowlist for simple_ring_buffer Vincent Donnefort
2026-03-16 11:06 ` Arnd Bergmann
2026-03-16 14:09 ` Steven Rostedt
2026-03-17  9:04   ` Marc Zyngier
2026-03-16 20:47 ` Arnd Bergmann
2026-03-16 20:48   ` Arnd Bergmann
2026-03-17  9:04     ` Marc Zyngier
2026-03-17  9:03 ` Marc Zyngier

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