-
Notifications
You must be signed in to change notification settings - Fork 14
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__mulodi4 from u32_u32__int_overflow_test in lib/overflow_kunit.c #1711
Comments
Can we simply omit the test for clang < 12? |
Sure, that would fix this immediate issue. However, it is still going to be possible for someone to call these overflow macros in a driver or core kernel code with the same types as the test (that was the original motivation for the change), which would cause this error at that point. |
Maybe something like: diff --git a/lib/overflow_kunit.c b/lib/overflow_kunit.c
index f385ca652b74..9240533e0283 100644
--- a/lib/overflow_kunit.c
+++ b/lib/overflow_kunit.c
@@ -716,12 +716,22 @@ static struct kunit_case overflow_test_cases[] = {
KUNIT_CASE(u32_u32__u32_overflow_test),
KUNIT_CASE(s32_s32__s32_overflow_test),
/* Clang 13 and earlier generate unwanted libcalls on 32-bit. */
-#if BITS_PER_LONG == 64
+#if defined(CONFIG_CC_IS_GCC) || \
+ (defined(CONFIG_CC_IS_CLANG) && \
+ (__clang_major__ > 13 || BITS_PER_LONG == 64))
KUNIT_CASE(u64_u64__u64_overflow_test),
KUNIT_CASE(s64_s64__s64_overflow_test),
#endif
- KUNIT_CASE(u32_u32__u8_overflow_test),
+/* Clang 11 and earlier generate unwanted libcalls for signed output, unsigned
+ * input.
+ * https://github.com/llvm/llvm-project/commit/3203143f1356a4e4e3ada231156fc6da6e1a9f9d
+ * */
+#if defined(CONFIG_CC_IS_GCC) || \
+ (defined(CONFIG_CC_IS_CLANG) && \
+ (__clang_major__ > 11 || BITS_PER_LONG == 64))
KUNIT_CASE(u32_u32__int_overflow_test),
+#endif
+ KUNIT_CASE(u32_u32__u8_overflow_test),
KUNIT_CASE(u8_u8__int_overflow_test),
KUNIT_CASE(int_int__u8_overflow_test),
KUNIT_CASE(shift_sane_test), |
This is now in mainline: https://github.com/ClangBuiltLinux/continuous-integration2/actions/runs/3179910972 I will try to test the above diff. |
Ah! Shall I take the above patch for it? |
I'll send a formal patch today. |
Building the overflow kunit tests with clang-11 fails with: $ ./tools/testing/kunit/kunit.py run --arch=arm --make_options LLVM=1 \ overflow ... ld.lld: error: undefined symbol: __mulodi4 ... Clang 11 and earlier generate unwanted libcalls for signed output, unsigned input. Disable these tests for now, but should these become used in the kernel we might consider that as justification for dropping clang-11 support. Keep the clang-11 build alive a little bit longer. Avoid -Wunused-function warnings via __maybe_unused. Link: ClangBuiltLinux#1711 Link: llvm/llvm-project@3203143 Reported-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Building the overflow kunit tests with clang-11 fails with: $ ./tools/testing/kunit/kunit.py run --arch=arm --make_options LLVM=1 \ overflow ... ld.lld: error: undefined symbol: __mulodi4 ... Clang 11 and earlier generate unwanted libcalls for signed output, unsigned input. Disable these tests for now, but should these become used in the kernel we might consider that as justification for dropping clang-11 support. Keep the clang-11 build alive a little bit longer. Avoid -Wunused-function warnings via __maybe_unused. To test W=1: $ make LLVM=1 -j128 defconfig $ ./scripts/config -e KUNIT -e KUNIT_ALL $ make LLVM=1 -j128 olddefconfig lib/overflow_kunit.o W=1 Link: ClangBuiltLinux#1711 Link: llvm/llvm-project@3203143 Reported-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20221006171751.3444575-1-ndesaulniers@google.com
Building the overflow kunit tests with clang-11 fails with: $ ./tools/testing/kunit/kunit.py run --arch=arm --make_options LLVM=1 \ overflow ... ld.lld: error: undefined symbol: __mulodi4 ... Clang 11 and earlier generate unwanted libcalls for signed output, unsigned input. Disable these tests for now, but should these become used in the kernel we might consider that as justification for dropping clang-11 support. Keep the clang-11 build alive a little bit longer. Avoid -Wunused-function warnings via __maybe_unused. To test W=1: $ make LLVM=1 -j128 defconfig $ ./scripts/config -e KUNIT -e KUNIT_ALL $ make LLVM=1 -j128 olddefconfig lib/overflow_kunit.o W=1 Link: ClangBuiltLinux#1711 Link: llvm/llvm-project@3203143 Reported-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20221006171751.3444575-1-ndesaulniers@google.com
Are those changes scheduled for 6.1 or 6.2? CI is still failing with this on mainline so it is needed there. I can just apply it to the relevant branches in CI for the time being if necessary. |
Hi! I originally wanted to get them out of the door for -next, and if they were happy, get them sent to Linus for 6.1 shortly. |
Building the overflow kunit tests with clang-11 fails with: $ ./tools/testing/kunit/kunit.py run --arch=arm --make_options LLVM=1 \ overflow ... ld.lld: error: undefined symbol: __mulodi4 ... Clang 11 and earlier generate unwanted libcalls for signed output, unsigned input. Disable these tests for now, but should these become used in the kernel we might consider that as justification for dropping clang-11 support. Keep the clang-11 build alive a little bit longer. Avoid -Wunused-function warnings via __maybe_unused. To test W=1: $ make LLVM=1 -j128 defconfig $ ./scripts/config -e KUNIT -e KUNIT_ALL $ make LLVM=1 -j128 olddefconfig lib/overflow_kunit.o W=1 Link: ClangBuiltLinux#1711 Link: llvm/llvm-project@3203143 Reported-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20221006171751.3444575-1-ndesaulniers@google.com
Building the overflow kunit tests with clang-11 fails with: $ ./tools/testing/kunit/kunit.py run --arch=arm --make_options LLVM=1 \ overflow ... ld.lld: error: undefined symbol: __mulodi4 ... Clang 11 and earlier generate unwanted libcalls for signed output, unsigned input. Disable these tests for now, but should these become used in the kernel we might consider that as justification for dropping clang-11 support. Keep the clang-11 build alive a little bit longer. Avoid -Wunused-function warnings via __maybe_unused. To test W=1: $ make LLVM=1 -j128 defconfig $ ./scripts/config -e KUNIT -e KUNIT_ALL $ make LLVM=1 -j128 olddefconfig lib/overflow_kunit.o W=1 Link: ClangBuiltLinux/linux#1711 Link: llvm/llvm-project@3203143 Reported-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20221006171751.3444575-1-ndesaulniers@google.com
Reported by CI with LLVM 11 (newer versions do not show this):
https://builds.tuxbuild.com/2EqpS04tCKn154FmyeYYpl7WJJ2/build.log
"Caused" by commit d219d2a9a92e ("overflow: Allow mixed type arguments") (cc @kees). A simplified reproducer on top of allnoconfig:
My reverse bisect of LLVM shows commit 3203143f1356 ("CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)") resolved this, which appears to be this exact case. I wonder if it is worth bumping the minimum version of LLVM to 12.0.0 over this?
The text was updated successfully, but these errors were encountered: