diff options
author | Kees Cook <kees@kernel.org> | 2024-06-19 13:31:05 -0700 |
---|---|---|
committer | Kees Cook <kees@kernel.org> | 2024-06-19 13:32:04 -0700 |
commit | 2003e483a81cc235e29f77da3f6b256cb4b348e7 (patch) | |
tree | f271aeae5cf006dedb24065559b463e7ec405f2a /lib | |
parent | d6f635bcaca8d38dfa47ee20658705f9eff156b5 (diff) | |
download | lwn-2003e483a81cc235e29f77da3f6b256cb4b348e7.tar.gz lwn-2003e483a81cc235e29f77da3f6b256cb4b348e7.zip |
fortify: Do not special-case 0-sized destinations
All fake flexible arrays should have been removed now, so remove the
special casing that was avoiding checking them. If a destination claims
to be 0 sized, believe it. This is especially important for cases where
__counted_by is in use and may have a 0 element count.
Link: https://lore.kernel.org/r/20240619203105.work.747-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fortify_kunit.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/fortify_kunit.c b/lib/fortify_kunit.c index f9cc467334ce..f0c64b9e9b46 100644 --- a/lib/fortify_kunit.c +++ b/lib/fortify_kunit.c @@ -910,10 +910,9 @@ static void fortify_test_##memfunc(struct kunit *test) \ memfunc(zero.buf, srcB, 0 + unconst); \ KUNIT_EXPECT_EQ(test, fortify_read_overflows, 0); \ KUNIT_EXPECT_EQ(test, fortify_write_overflows, 0); \ - /* We currently explicitly ignore zero-sized dests. */ \ memfunc(zero.buf, srcB, 1 + unconst); \ KUNIT_EXPECT_EQ(test, fortify_read_overflows, 0); \ - KUNIT_EXPECT_EQ(test, fortify_write_overflows, 0); \ + KUNIT_EXPECT_EQ(test, fortify_write_overflows, 1); \ } __fortify_test(memcpy) __fortify_test(memmove) |