This is an archive of the discontinued LLVM Phabricator instance.

[msan] Fix handling of ParamTLS overflow.
ClosedPublic

Authored by eugenis on Mar 24 2023, 6:10 PM.

Details

Summary

Ironically, MSan copies uninitialized data off the stack into
VAArgTLSCopy in the callee-side handling of va_start. Clamp the copy
size to the actual length of the buffer, and zero-initialize the
remainder.

Diff Detail

Event Timeline

eugenis created this revision.Mar 24 2023, 6:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2023, 6:10 PM
eugenis requested review of this revision.Mar 24 2023, 6:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2023, 6:10 PM
vitalybuka added inline comments.Mar 27 2023, 11:24 AM
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
5734

should the tail be poisoned instead?

eugenis added inline comments.Mar 29 2023, 11:40 AM
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
5734

no, the tail is for the arguments whose shadow did not fit in ParamTLS - we have to assume they are good to avoid false positives

vitalybuka accepted this revision.Mar 31 2023, 8:01 PM
This revision is now accepted and ready to land.Mar 31 2023, 8:01 PM
This revision was automatically updated to reflect the committed changes.