New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 593540 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Spake2AuthenticatorTest fails on MSAN

Project Member Reported by thestig@chromium.org, Mar 10 2016

Issue description

https://chromium.googlesource.com/chromium/src/+/bf336334ba59ae7cd150e9cb36a9b248d174a4eb added new SPAKE2 tests, and they have been failing since:

https://build.chromium.org/p/chromium.memory.fyi/builders/Linux%20MSan%20Tests/builds/14316

MSAN does not support suppressions. Please fix or revert.

WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x14bb0fd in ?? third_party/modp_b64/modp_b64.cc:91:20
    #1 0xdcf2f6 in Base64Encode base/base64.cc:18:24
    #2 0x12d6e6c in EncodeBinaryValueToXml remoting/protocol/spake2_authenticator.cc:47:3
    #3 0x12d6e6c in GetNextMessage remoting/protocol/spake2_authenticator.cc:269:0
    #4 0xa1e727 in ContinueAuthExchangeWith remoting/protocol/authenticator_test_base.cc:104:13
    #5 0xa1fad7 in ContinueAuthExchangeWith remoting/protocol/authenticator_test_base.cc:109:3
    #6 0xc7e9b2 in TestBody remoting/protocol/spake2_authenticator_unittest.cc:79:3

 
Cc: chrishall@chromium.org
Similarly, Valgrind detected this error:

https://build.chromium.org/p/chromium.memory.fyi/builders/Chromium%20OS%20%28valgrind%29%283%29/builds/41797

Use of uninitialised value of size 8
modp_b64_encode (third_party/modp_b64/modp_b64.cc:91)
base::Base64Encode(base::BasicStringPiece<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*) (base/base64.cc:18)
remoting::protocol::(anonymous namespace)::EncodeBinaryValueToXml(buzz::StaticQName const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (remoting/protocol/spake2_authenticator.cc:47)
remoting::protocol::Spake2Authenticator::GetNextMessage() (remoting/protocol/spake2_authenticator.cc:269)
remoting::protocol::AuthenticatorTestBase::ContinueAuthExchangeWith(remoting::protocol::Authenticator*, remoting::protocol::Authenticator*, bool, bool) (remoting/protocol/authenticator_test_base.cc:104)
Suppression (error hash=#99578F322FD96DEF#):
For more info on using suppressions see http://dev.chromium.org/developers/tree-sheriffs/sheriff-details-chromium/memory-sheriff#TOC-Suppressing-memory-reports
{
<insert_a_suppression_name_here>
Memcheck:Uninitialized
fun:modp_b64_encode
fun:_ZN4base12Base64EncodeERKNS_16BasicStringPieceISsEEPSs
fun:_ZN8remoting8protocol12_GLOBAL__N_122EncodeBinaryValueToXmlERKN4buzz11StaticQNameERKSs
fun:_ZN8remoting8protocol19Spake2Authenticator14GetNextMessageEv
fun:_ZN8remoting8protocol21AuthenticatorTestBase24ContinueAuthExchangeWithEPNS0_13AuthenticatorES3_bb
}

UninitCondition
Conditional jump or move depends on uninitialised value(s)
remoting::protocol::Spake2Authenticator::ProcessMessageInternal(buzz::XmlElement const*) (remoting/protocol/spake2_authenticator.cc:235)
remoting::protocol::Spake2Authenticator::ProcessMessage(buzz::XmlElement const*, base::Callback<void ()> const&) (remoting/protocol/spake2_authenticator.cc:154)
remoting::protocol::AuthenticatorTestBase::ContinueAuthExchangeWith(remoting::protocol::Authenticator*, remoting::protocol::Authenticator*, bool, bool) (remoting/protocol/authenticator_test_base.cc:109)
Suppression (error hash=#17DC1A8F9E43A2F4#):
For more info on using suppressions see http://dev.chromium.org/developers/tree-sheriffs/sheriff-details-chromium/memory-sheriff#TOC-Suppressing-memory-reports
{
<insert_a_suppression_name_here>
Memcheck:Uninitialized
fun:_ZN8remoting8protocol19Spake2Authenticator22ProcessMessageInternalEPKN4buzz10XmlElementE
fun:_ZN8remoting8protocol19Spake2Authenticator14ProcessMessageEPKN4buzz10XmlElementERKN4base8CallbackIFvvEEE
fun:_ZN8remoting8protocol21AuthenticatorTestBase24ContinueAuthExchangeWithEPNS0_13AuthenticatorES3_bb
}

Labels: Stability-Valgrind
Cc: -davidben@chromium.org sergeyu@chromium.org arnarb@google.com
Components: Internals>Network>SSL
Labels: -OS-Linux -OS-Chrome OS-All
Owner: davidben@chromium.org
Actually reassigning to davidben. Please work with arnarb to work this out:

MSAN gave a nice explanation of why this is happening - in third_party/boringssl/src/crypto/curve25519/curve25519.c, x25519_ge_scalarmult() declares a struct ge_cached named |selected|. |selected| is initialized via cmov_cached(), which just calls fe_cmov() for each struct member. struct fe is initialized in fe_cmov() as |f|, where we have:

----
int32_t x = f[i] ^ g[i];
x &= b;
f[i] ^= x;
----

... the value we set in f[i] depends on the uninitialized value in f[i]. :\ Should |selected| be zeroed out before calling cmov_cached() ?
FTR, https://codereview.chromium.org/1778223003/ reverted the tests, so the memory.fyi remoting tests should go green.
This is constant-time code which is always a little funny like this. equal(j, index) will be one for exactly one iteration of the loop. At that iteration in the loop, fe_cmov will set f to g and in the other iterations it will leave it alone.

But, sure, we can initialize it to zero to shut the sanitizers up.
Status: Started (was: Untriaged)
https://boringssl-review.googlesource.com/7415
Project Member

Comment 8 by bugdroid1@chromium.org, Mar 10 2016

The following revision refers to this bug:
  https://boringssl.googlesource.com/boringssl.git/+/08791e6756c3fbee0ef1bdc104a74ab212501bb6

commit 08791e6756c3fbee0ef1bdc104a74ab212501bb6
Author: David Benjamin <davidben@google.com>
Date: Thu Mar 10 17:41:19 2016

Appease sanitizers in x25519_ge_scalarmult.

Although exactly one iteration of cmov_cached will always initialize selected,
it ends up messing with uninitialized memory. Initialize |selected| before the
loop.

BUG= 593540 

Change-Id: I5921843f68c6dd1dc7f752538825bc43ba75df4a
Reviewed-on: https://boringssl-review.googlesource.com/7415
Reviewed-by: Arnar Birgisson <arnarb@google.com>
Reviewed-by: David Benjamin <davidben@google.com>

[modify] https://crrev.com/08791e6756c3fbee0ef1bdc104a74ab212501bb6/crypto/curve25519/curve25519.c

I'll roll BoringSSL shortly and then this will get picked up.
Cc: davidben@chromium.org arnarb@chromium.org agl@chromium.org
 Issue 593912  has been merged into this issue.
Status: Fixed (was: Started)
This should be fixed now.

Sign in to add a comment