summaryrefslogtreecommitdiffstats
path: root/lib/test_fortify
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-06-16 23:42:23 +0200
committerKees Cook <keescook@chromium.org>2022-02-14 01:50:06 +0100
commit28e77cc1c0686621a4d416f599cee5ab369daa0a (patch)
treec58b0cfacdeab1d3f46cbd12f91ebcfb37a7ab56 /lib/test_fortify
parentfortify: Detect struct member overflows in memmove() at compile-time (diff)
downloadlinux-28e77cc1c0686621a4d416f599cee5ab369daa0a.tar.xz
linux-28e77cc1c0686621a4d416f599cee5ab369daa0a.zip
fortify: Detect struct member overflows in memset() at compile-time
As done for memcpy(), also update memset() to use the same tightened compile-time bounds checking under CONFIG_FORTIFY_SOURCE. Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'lib/test_fortify')
-rw-r--r--lib/test_fortify/write_overflow_field-memset.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/test_fortify/write_overflow_field-memset.c b/lib/test_fortify/write_overflow_field-memset.c
new file mode 100644
index 000000000000..2331da26909e
--- /dev/null
+++ b/lib/test_fortify/write_overflow_field-memset.c
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#define TEST \
+ memset(instance.buf, 0x42, sizeof(instance.buf) + 1)
+
+#include "test_fortify.h"