mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
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>
This commit is contained in:
parent
890a64810d
commit
ae1a863bcd
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user