aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Kees Cook <keescook@chromium.org> 2024-05-18 11:40:23 -0700
committerGravatar Kees Cook <keescook@chromium.org> 2024-05-18 13:46:10 -0700
commitae1a863bcdbd6ea2abc93519a82ab5d715d5dcbc (patch)
tree4887904fb36d08b6973405fbafe133a1b032660a /lib
parentubsan: Restore dependency on ARCH_HAS_UBSAN (diff)
downloadlinux-ae1a863bcdbd6ea2abc93519a82ab5d715d5dcbc.tar.gz
linux-ae1a863bcdbd6ea2abc93519a82ab5d715d5dcbc.tar.bz2
linux-ae1a863bcdbd6ea2abc93519a82ab5d715d5dcbc.zip
kunit/fortify: Fix memcmp() test to be amplitude agnostic
When memcmp() returns a non-zero value, only the signed bit has any meaning. The actual value may differ between implementations. Reported-by: Nathan Chancellor <nathan@kernel.org> Closes: https://github.com/ClangBuiltLinux/linux/issues/2025 Tested-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20240518184020.work.604-kees@kernel.org Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/fortify_kunit.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/fortify_kunit.c b/lib/fortify_kunit.c
index d2377e00caab..39da5b3bc649 100644
--- a/lib/fortify_kunit.c
+++ b/lib/fortify_kunit.c
@@ -990,7 +990,7 @@ static void fortify_test_memcmp(struct kunit *test)
KUNIT_ASSERT_EQ(test, memcmp(one, two, one_len), 0);
KUNIT_EXPECT_EQ(test, fortify_read_overflows, 0);
/* Still in bounds, but no longer matching. */
- KUNIT_ASSERT_EQ(test, memcmp(one, two, one_len + 1), -32);
+ KUNIT_ASSERT_LT(test, memcmp(one, two, one_len + 1), 0);
KUNIT_EXPECT_EQ(test, fortify_read_overflows, 0);
/* Catch too-large ranges. */