Skip to content

Commit 6522fe5

Browse files
keesjmberg-intel
authored andcommitted
um: Disable GCOV_PROFILE_ALL on 32-bit UML with Clang 20/21
Clang 20 and 21 miscompute __builtin_object_size() when -fprofile-arcs is active on 32-bit UML targets, which passes incorrect object size calculations for local variables through always_inline copy_to_user() and check_copy_size(), causing spurious compile-time errors: include/linux/ucopysize.h:52:4: error: call to '__bad_copy_from' declared with 'error' attribute: copy source size is too small The regression was introduced in LLVM commit 02b8ee281947 ("[llvm] Improve llvm.objectsize computation by computing GEP, alloca and malloc parameters bound"), which shipped in Clang 20. It was fixed in LLVM by commit 45b697e610fd ("[MemoryBuiltins] Consider index type size when aggregating gep offsets"), which was backported to the LLVM 22.x release branch. The bug requires 32-bit UML + GCOV_PROFILE_ALL (which uses -fprofile-arcs), though the exact trigger depends on optimizer decisions influenced by other enabled configs. Prevent the bad combination by disabling UML's ARCH_HAS_GCOV_PROFILE_ALL on 32-bit when using Clang 20.x or 21.x. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Suggested-by: Nathan Chancellor <[email protected]> Assisted-by: Claude:claude-opus-4-6[1m] Signed-off-by: Kees Cook <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 91e901c commit 6522fe5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

arch/um/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ config UML
1111
select ARCH_HAS_CACHE_LINE_SIZE
1212
select ARCH_HAS_CPU_FINALIZE_INIT
1313
select ARCH_HAS_FORTIFY_SOURCE
14-
select ARCH_HAS_GCOV_PROFILE_ALL
14+
# Clang 20 & 21 miscompute __builtin_object_size() under -fprofile-arcs
15+
# on 32-bit, causing spurious compile-time errors in check_copy_size().
16+
select ARCH_HAS_GCOV_PROFILE_ALL if !(!64BIT && CLANG_VERSION >= 200000 && CLANG_VERSION < 220100)
1517
select ARCH_HAS_KCOV
1618
select ARCH_HAS_STRNCPY_FROM_USER
1719
select ARCH_HAS_STRNLEN_USER

0 commit comments

Comments
 (0)