projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
890a648
)
kunit/fortify: Fix memcmp() test to be amplitude agnostic
author
Kees Cook
<keescook@chromium.org>
Sat, 18 May 2024 18:40:23 +0000
(11:40 -0700)
committer
Kees Cook
<keescook@chromium.org>
Sat, 18 May 2024 20:46:10 +0000
(13:46 -0700)
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>
lib/fortify_kunit.c
patch
|
blob
|
history
diff --git
a/lib/fortify_kunit.c
b/lib/fortify_kunit.c
index d2377e00caab43883a5e1516d029cc28109c1872..39da5b3bc649c28896e60d9dac974b98973da8d0 100644
(file)
--- 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. */