On Tue, Sep 05, 2023 at 12:12:11PM +0200, Lukas Bulwahn wrote:
Dear Andrey, dear Nick, dear Greg, dear Sasha,
Compiling the kernel with UBSAN enabled and with gcc-8 and later fails when:
commit 1e1b6d63d634 ("lib/string.c: implement stpcpy") is applied, and commit bac7a1fff792 ("lib/ubsan: remove returns-nonnull-attribute checks") is not applied.
To reproduce, run:
tuxmake -r docker -a arm64 -t gcc-13 -k allnoconfig --kconfig-add CONFIG_UBSAN=y
It then fails with:
aarch64-linux-gnu-ld: lib/string.o: in function `stpcpy': string.c:(.text+0x694): undefined reference to `__ubsan_handle_nonnull_return_v1' string.c:(.text+0x694): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__ubsan_handle_nonnull_return_v1'
Below you find a complete list of architectures, compiler versions and kernel versions that I have tested with.
As commit bac7a1fff792 ("lib/ubsan: remove returns-nonnull-attribute checks") is included in v4.16, and commit 1e1b6d63d634 ("lib/string.c: implement stpcpy") is included in v5.9, this is not an issue that can happen on any mainline release or the stable releases v4.19.y and later.
In the v4.14.y branch, however, commit 1e1b6d63d634 ("lib/string.c: implement stpcpy") was included with v4.14.200 as commit b6d38137c19f and commit bac7a1fff792 ("lib/ubsan: remove returns-nonnull-attribute checks") from mainline was not included yet. Hence, this reported failure with UBSAN can be observed on v4.14.y with recent gcc versions.
Greg, once checked and confirmed by Andrey or Nick, could you please include commit bac7a1fff792 ("lib/ubsan: remove returns-nonnull-attribute checks") into the linux-4.14.y branch?
Now queued up, thanks.
greg k-h