From: Andrey Konovalov <andreyk...@google.com>

commit 69ca372c100fba99c78ef826a1795aa86e4f01a8 upstream.

A compiler can optimize away memset calls by replacing them with mov
instructions.  There are KASAN tests that specifically test that KASAN
correctly handles memset calls so we don't want this optimization to
happen.

The solution is to add -fno-builtin flag to test_kasan.ko

Link: 
http://lkml.kernel.org/r/105ec9a308b2abedb1a0d1fdced0c22d765e4732.1519924383.git.andreyk...@google.com
Signed-off-by: Andrey Konovalov <andreyk...@google.com>
Acked-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
Cc: Alexander Potapenko <gli...@google.com>
Cc: Dmitry Vyukov <dvyu...@google.com>
Cc: Geert Uytterhoeven <ge...@linux-m68k.org>
Cc: Nick Terrell <terre...@fb.com>
Cc: Chris Mason <c...@fb.com>
Cc: Yury Norov <yno...@caviumnetworks.com>
Cc: Al Viro <v...@zeniv.linux.org.uk>
Cc: "Luis R . Rodriguez" <mcg...@kernel.org>
Cc: Palmer Dabbelt <pal...@dabbelt.com>
Cc: "Paul E . McKenney" <paul...@linux.vnet.ibm.com>
Cc: Jeff Layton <jlay...@redhat.com>
Cc: "Jason A . Donenfeld" <ja...@zx2c4.com>
Cc: Kostya Serebryany <k...@google.com>
Signed-off-by: Andrew Morton <a...@linux-foundation.org>
Signed-off-by: Linus Torvalds <torva...@linux-foundation.org>
Signed-off-by: Andrey Konovalov <andreyk...@google.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 lib/Makefile |    1 +
 1 file changed, 1 insertion(+)

--- a/lib/Makefile
+++ b/lib/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_TEST_BPF) += test_bpf.o
 obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o
 obj-$(CONFIG_TEST_HASH) += test_hash.o
 obj-$(CONFIG_TEST_KASAN) += test_kasan.o
+CFLAGS_test_kasan.o += -fno-builtin
 obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
 obj-$(CONFIG_TEST_LKM) += test_module.o
 obj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o


Reply via email to