Skip to contentSkip to conversation

kcsan-compiler_types-avoid-duplicate-type-issues-in-bpf-type-format.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Feb 8 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: kcsan, compiler_types: avoid duplicate type issues in BPF Type Format
has been removed from the -mm tree. Its filename was
kcsan-compiler_types-avoid-duplicate-type-issues-in-bpf-type-format.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Alan Maguire <[email protected]>
Subject: kcsan, compiler_types: avoid duplicate type issues in BPF Type Format
Date: Fri, 16 Jan 2026 09:17:30 +0000

Enabling KCSAN is causing a large number of duplicate types in BTF for core kernel structs like task_struct [1]. This is due to the definition in include/linux/compiler_types.h

`#ifdef __SANITIZE_THREAD__
...
`#define __data_racy volatile
..
`#else
...
`#define __data_racy
...
`#endif

Because some objects in the kernel are compiled without KCSAN flags (KCSAN_SANITIZE) we sometimes get the empty __data_racy annotation for objects; as a result we get multiple conflicting representations of the associated structs in DWARF, and these lead to multiple instances of core kernel types in BTF since they cannot be deduplicated due to the additional modifier in some instances.

Moving the __data_racy definition under CONFIG_KCSAN avoids this problem, since the volatile modifier will be present for both KCSAN and KCSAN_SANITIZE objects in a CONFIG_KCSAN=y kernel.

Fixes 31f605a308e6 ("kcsan, compiler_types: Introduce __data_racy type qualifier")
Cc Alexei Starovoitov <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Bart van Assche <[email protected]>
Cc Daniel Borkman <[email protected]>
Cc Eduard Zingerman <[email protected]>
Cc Hao Luo <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Jason A. Donenfeld <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc John Fastabend <[email protected]>
Cc Kees Cook <[email protected]>
Cc KP Singh <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Miguel Ojeda <[email protected]>
Cc Naman Jain <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc "Paul E . McKenney" <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stanislav Fomichev <[email protected]>
Cc Uros Bizjak <[email protected]>

---

 include/linux/compiler_types.h |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
include/linux/compiler_types.h renamed from include/linux/compiler_types.h~kcsan-compiler_types-avoid-duplicate-type-issues-in-bpf-type-format +16 -7
@@ -303,6 +303,22 @@ struct ftrace_likely_data {
 # define __no_kasan_or_inline __always_inline
 #endif
 
+#ifdef CONFIG_KCSAN
+/*
+ * Type qualifier to mark variables where all data-racy accesses should be
+ * ignored by KCSAN. Note, the implementation simply marks these variables as
+ * volatile, since KCSAN will treat such accesses as "marked".
+ *
+ * Defined here because defining __data_racy as volatile for KCSAN objects only
+ * causes problems in BPF Type Format (BTF) generation since struct members
+ * of core kernel data structs will be volatile in some objects and not in
+ * others.  Instead define it globally for KCSAN kernels.
+ */
+# define __data_racy volatile
+#else
+# define __data_racy
+#endif
+
 #ifdef __SANITIZE_THREAD__
 /*
  * Clang still emits instrumentation for __tsan_func_{entry,exit}() and builtin
@@ -314,16 +330,9 @@ struct ftrace_likely_data {
  * disable all instrumentation. See Kconfig.kcsan where this is mandatory.
  */
 # define __no_kcsan __no_sanitize_thread __disable_sanitizer_instrumentation
-/*
- * Type qualifier to mark variables where all data-racy accesses should be
- * ignored by KCSAN. Note, the implementation simply marks these variables as
- * volatile, since KCSAN will treat such accesses as "marked".
- */
-# define __data_racy volatile
 # define __no_sanitize_or_inline __no_kcsan notrace __maybe_unused
 #else
 # define __no_kcsan
-# define __data_racy
 #endif
 
 #ifdef __SANITIZE_MEMORY__

_

Patches currently in -mm which might be from [email protected] are