Bug 218887

Summary: RISCV kernel build fails with CONFIG_KASAN_INLINE=y
Product: Memory Management Reporter: Jason M. (jason)
Component: SanitizersAssignee: MM/Sanitizers virtual assignee (mm_sanitizers)
Status: RESOLVED PATCH_ALREADY_AVAILABLE    
Severity: normal CC: andreyknvl, kasan-dev
Priority: P3    
Hardware: RISC-V   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:
Attachments: config that fails to build

Description Jason M. 2024-05-24 23:12:17 UTC
Created attachment 306341 [details]
config that fails to build

Building a kernel for riscv64 with CONFIG_KASAN_INLINE=y set fails when tools/bpf/resolve_btfids/resolve_btfids is run with with the error message:
```
FAILED elf_update(WRITE): no error
make[2]: *** [scripts/Makefile.vmlinux:37: vmlinux] Error 255
make[2]: *** Deleting file 'vmlinux'
make[1]: *** [/home/jason/rpmbuild/BUILD/kernel-6.8.10/linux-6.8.10-300.1.riscv64.fc40.riscv64/Makefile:1174: vmlinux] Error 2
make: *** [Makefile:252: __sub-make] Error 2
```

The attached config is the kernel-riscv64-debug-fedora.config from the Fedora 40 riscv kernel package available at http://riscv.rocks/koji/buildinfo?buildID=305900

Initially, I was trying to build a fedora debug kernel package, but I have also tried this with vanilla 6.8.10, 6.9.1, and 2024-05-21 linux-next with the same result running
`make -j4 vmlinuz.efi` using this config with the same result.

If I switch from CONFIG_KASAN_INLINE=y to CONFIG_KASAN_OUTLINE=y the build succeeds.

I am building on Fedora 40 on a VisionFive 2, gcc 14.1.1-1, binutils 2.42.

Please let me know if there is other information I can gather.
Comment 1 Jason M. 2024-05-28 18:03:09 UTC
This is due to the issue described here:
https://lore.kernel.org/all/20240527153137.271933-1-alexghiti@rivosinc.com/T/#t

The vmlinux file was over 2GB with CONFIG_KASAN_INLINE=y
$ ls -l vmlinux && ls -lh vmlinux
-rwxr-xr-x. 1 jason jason 2455700072 May 27 18:17 vmlinux
-rwxr-xr-x. 1 jason jason 2.3G May 27 18:17 vmlinux

With the patch for resolve_btfids applied I was able to build and boot successfully.

$ uname -r && grep CONFIG_KASAN_INLINE /boot/config-6.8.11-300.1.riscv64.fc40.riscv64+debug 
6.8.11-300.1.riscv64.fc40.riscv64+debug
CONFIG_KASAN_INLINE=y
Comment 2 Andrey Konovalov 2024-05-29 22:46:47 UTC
Awesome, thank you for posting an update!

If everything is working as expected with the patch applied, please consider closing the issue.