This is an archive of the discontinued LLVM Phabricator instance.

[MSan] Make sure variadic function arguments do not overflow __msan_va_arg_tls
ClosedPublic

Authored by glider on Sep 4 2018, 6:33 AM.

Details

Summary

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.

Diff Detail

Event Timeline

glider created this revision.Sep 4 2018, 6:33 AM
glider updated this revision to Diff 163808.Sep 4 2018, 7:08 AM
glider edited the summary of this revision. (Show Details)

Replaced assert() with report_fatal_error(), added a test.

eugenis accepted this revision.Sep 4 2018, 1:36 PM

LGTM

This revision is now accepted and ready to land.Sep 4 2018, 1:36 PM
eugenis requested changes to this revision.Sep 4 2018, 1:37 PM
This revision now requires changes to proceed.Sep 4 2018, 1:37 PM

In fact, getShadow() already checks for kParamTLSSize and returns clean shadow if the argument does not fit.
We just need to skip storing argument shadow for such arguments instead of asserting.

glider updated this revision to Diff 163989.Sep 5 2018, 2:39 AM
glider retitled this revision from [MSan] Check that variadic function arguments do not overflow __msan_va_arg_tls to [MSan] Make sure variadic function arguments do not overflow __msan_va_arg_tls.
glider edited the summary of this revision. (Show Details)

Skip storing argument shadow instead of asserting, added tests for AArch64, Mips, PPC64

eugenis accepted this revision.Sep 5 2018, 1:19 PM

LGTM

This revision is now accepted and ready to land.Sep 5 2018, 1:19 PM
glider closed this revision.Sep 6 2018, 1:24 AM

Landed r341525, thanks!