[MSan] Make sure variadic function arguments do not overflow __msan_va_arg_tls
authorAlexander Potapenko <glider@google.com>
Thu, 6 Sep 2018 08:21:54 +0000 (08:21 +0000)
committerAlexander Potapenko <glider@google.com>
Thu, 6 Sep 2018 08:21:54 +0000 (08:21 +0000)
commitd518c5fc87f8dc8617671702af3bbdcea426c808
treed91012078e7169f479d9e9cc76451cf749f511b7
parent0a875b2f15b1285d36d1d9ce92404f75bd10e99a
[MSan] Make sure variadic function arguments do not overflow __msan_va_arg_tls

Turns out that calling a variadic function with too many (e.g. >100 i64's)
arguments overflows __msan_va_arg_tls, which leads to smashing other TLS
data with function argument shadow values.

getShadow() already checks for kParamTLSSize and returns clean shadow if
the argument does not fit, so just skip storing argument shadow for such
arguments.

llvm-svn: 341525
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/AArch64/vararg.ll
llvm/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64.ll
llvm/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64el.ll
llvm/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64.ll
llvm/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64le.ll
llvm/test/Instrumentation/MemorySanitizer/X86/vararg-too-large.ll [new file with mode: 0644]