summaryrefslogtreecommitdiff
path: root/lib/test_fortify
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-06-17 00:48:19 +0300
committerKees Cook <keescook@chromium.org>2022-02-14 03:50:06 +0300
commit938a000e3f9bead24ea753286b3e4d2423275c9e (patch)
treef3cdcabaea66b2f14b5488b6180cf552814b5aec /lib/test_fortify
parentf68f2ff91512c199ec24883001245912afc17873 (diff)
downloadlinux-938a000e3f9bead24ea753286b3e4d2423275c9e.tar.xz
fortify: Detect struct member overflows in memmove() at compile-time
As done for memcpy(), also update memmove() to use the same tightened compile-time checks under CONFIG_FORTIFY_SOURCE. Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'lib/test_fortify')
-rw-r--r--lib/test_fortify/read_overflow2_field-memmove.c5
-rw-r--r--lib/test_fortify/write_overflow_field-memmove.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/test_fortify/read_overflow2_field-memmove.c b/lib/test_fortify/read_overflow2_field-memmove.c
new file mode 100644
index 000000000000..6cc2724c8f62
--- /dev/null
+++ b/lib/test_fortify/read_overflow2_field-memmove.c
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#define TEST \
+ memmove(large, instance.buf, sizeof(instance.buf) + 1)
+
+#include "test_fortify.h"
diff --git a/lib/test_fortify/write_overflow_field-memmove.c b/lib/test_fortify/write_overflow_field-memmove.c
new file mode 100644
index 000000000000..377fcf9bb2fd
--- /dev/null
+++ b/lib/test_fortify/write_overflow_field-memmove.c
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#define TEST \
+ memmove(instance.buf, large, sizeof(instance.buf) + 1)
+
+#include "test_fortify.h"