[all-commits] [llvm/llvm-project] a05e73: [msan][x86] Fix shadow if vararg overflow beyond k...

Vitaly Buka via All-commits all-commits at lists.llvm.org
Fri Nov 17 15:13:26 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a05e736d288a7f2009ee9d057e78713d9adeeb5f
      https://github.com/llvm/llvm-project/commit/a05e736d288a7f2009ee9d057e78713d9adeeb5f
  Author: Vitaly Buka <vitalybuka at google.com>
  Date:   2023-11-17 (Fri, 17 Nov 2023)

  Changed paths:
    M compiler-rt/test/msan/vararg_shadow.cpp
    M llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
    M llvm/test/Instrumentation/MemorySanitizer/X86/vararg_shadow.ll

  Log Message:
  -----------
  [msan][x86] Fix shadow if vararg overflow beyond kParamTLSSize

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.

Reviewers: kstoimenov, thurstond

Reviewed By: thurstond

Pull Request: https://github.com/llvm/llvm-project/pull/72707




More information about the All-commits mailing list