[RFC PATCH] x86/Kconfig: Fix allyesconfig

Guenter Roeck posted 1 patch 8 months, 1 week ago
There is a newer version of this series
lib/Kconfig.kasan | 5 +++++
1 file changed, 5 insertions(+)
[RFC PATCH] x86/Kconfig: Fix allyesconfig
Posted by Guenter Roeck 8 months, 1 week ago
64-bit allyesconfig builds fail with

x86_64-linux-ld: kernel image bigger than KERNEL_IMAGE_SIZE

Bisect points to commit 6f110a5e4f99 ("Disable SLUB_TINY for build
testing") as the responsible commit. Reverting that patch does indeed
fix the problem. Further analysis shows that disabling SLUB_TINY enables
CONFIG_KASAN, and that CONFIG_KASAN is responsible for the image size
increase.

Solve the test build problem by selectively disabling CONFIG_KASAN for
'allyesconfig' build tests of 64-bit X86 builds.

Fixes: 6f110a5e4f99 ("Disable SLUB_TINY for build testing")
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
RFC: Maybe there is a better solution for the problem.
     Even increasing the maximum image size to 1.5GB did not help.
     Also, maybe there is a better way to determine if this is an
     "allyesconfig" build test.
     On top of that, I am not sure if the "Fixes" tag is really
     appropriate.

 lib/Kconfig.kasan | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index f82889a830fa..fb87c40798cd 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -31,6 +31,10 @@ config CC_HAS_KASAN_SW_TAGS
 config CC_HAS_WORKING_NOSANITIZE_ADDRESS
 	def_bool !CC_IS_GCC || GCC_VERSION >= 80300
 
+config KASAN_COMPILE_TEST
+	tristate "KASAN compile test"
+	depends on COMPILE_TEST && 64BIT && X86
+
 menuconfig KASAN
 	bool "KASAN: dynamic memory safety error detector"
 	depends on (((HAVE_ARCH_KASAN && CC_HAS_KASAN_GENERIC) || \
@@ -38,6 +42,7 @@ menuconfig KASAN
 		    CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \
 		   HAVE_ARCH_KASAN_HW_TAGS
 	depends on SYSFS && !SLUB_TINY
+	depends on KASAN_COMPILE_TEST!=y
 	select STACKDEPOT_ALWAYS_INIT
 	help
 	  Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety
-- 
2.45.2
Re: [RFC PATCH] x86/Kconfig: Fix allyesconfig
Posted by Linus Torvalds 8 months, 1 week ago
On Sun, 13 Apr 2025 at 18:13, Guenter Roeck <linux@roeck-us.net> wrote:
>
> Solve the test build problem by selectively disabling CONFIG_KASAN for
> 'allyesconfig' build tests of 64-bit X86 builds.

I think we might as well just disable KASAN for COMPILE_TEST entirely
- not artificially limit it to just x86-64.

Apparently it was effectively disabled anyway due to that SLUB_TINY
interaction, so while it would be nice to have bigger build coverage,
clearly we haven't had it before, and it causes problems.

            Linus
Re: [RFC PATCH] x86/Kconfig: Fix allyesconfig
Posted by Guenter Roeck 8 months, 1 week ago
On 4/14/25 12:59, Linus Torvalds wrote:
> On Sun, 13 Apr 2025 at 18:13, Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> Solve the test build problem by selectively disabling CONFIG_KASAN for
>> 'allyesconfig' build tests of 64-bit X86 builds.
> 
> I think we might as well just disable KASAN for COMPILE_TEST entirely
> - not artificially limit it to just x86-64.
> 
> Apparently it was effectively disabled anyway due to that SLUB_TINY
> interaction, so while it would be nice to have bigger build coverage,
> clearly we haven't had it before, and it causes problems.
> 

sgtm. I'll wait another day or two to give others time to provide feedback
and then send v2.

Guenter