[llvm-branch-commits] [llvm] [compiler-rt] [msan][x86] Fix shadow if vararg overflow beyond kParamTLSSize (PR #72707)

Vitaly Buka via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 17 13:58:07 PST 2023


https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/72707

Caller puts argument shadow one by one into __msan_va_arg_tls, until it
reaches kParamTLSSize. After that it still increment OverflowOffset but
does not store the shadow.

Callee needs OverflowOffset to prepare a shadow for the entire overflow
area. It's done by creating "varargs shadow copy" for complete list of
args, copying available shadow from __msan_va_arg_tls, and clearing the
rest.

However callee does not know if the tail of __msan_va_arg_tls was not
able to fit an argument, and callee will copy tail shadow into "varargs
shadow copy", and later used as a shadow for an omitted argument.

So that unused tail of the __msan_va_arg_tls must be cleared if left
unused.

This allows us to enable compiler-rt/test/msan/vararg_shadow.cpp for
x86.





More information about the llvm-branch-commits mailing list