Closed Bug 1177763 Opened 11 years ago Closed 10 years ago

use-of-uninitialized-value in intel_AES_GCM_DecryptUpdate

Categories

(NSS :: Libraries, defect)

x86_64
Unspecified
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: tsmith, Assigned: franziskus)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 2 obsolete files)

Attached file msan trace —
This was found running the test with a Memory Sanitizer build.
Tyson, do you know if the Memory Sanitizer is also checking assembler code? The relevant code here is: intel_aes_gcmTAG( gcm->Htbl, gcm->T, gcm->Mlen, gcm->Alen, gcm->X0, T); if (NSS_SecureMemcmp(T, intag, tagBytes) != 0) { The complaint is about using uninitialized T with NSS_SecureMemcmp. The only time T is being used prior to NSS_SecureMemcmp is with function call intel_aes_gcmTAG. intel_aes_gcmTAG is implemented in assembler code, I found three different platform specific implementations. I don't know the assembler syntax, so I haven't yet checked if function intel_aes_gcmTAG filss the contents of the T array (which I'd expect it to do, because otherwise the existence of array T would be pointless).
Kai, I believe Memory Sanitizer does handle some assembler code but not all instructions. In this case it could very well be a false positive. I'll let you make the call.
Mass cc to get some NSS eyes on these bugs.
Group: core-security → crypto-core-security
Hardware: Unspecified → x86_64
Keywords: sec-moderate
Note: MSAN + Assembly is notably 'rough'. For BoringSSL builds, when running under MSAN instrumentation we disable the optimized assembly for this reason ( https://code.google.com/p/chromium/issues/detail?id=488708 ) We also documented this on https://www.chromium.org/developers/testing/memorysanitizer - "Inline assembly is also likely to cause bogus reports. Consequently, assembly-optimized third-party code (such as libjpeg_turbo, libvpx, libyuv, ffmpeg) will have those optimizations disabled in MSan builds." So I'm more inclined to believe this is a 'false positive' rather than sec-moderate. So I agree with Kai's assessment, but we need another set of eyes on the assembly, since my eyes start to bleed when staring at GAS too long and I miss things. That said, previous assembly contributions did have subtle correctness issues, so it's not entirely unreasonable to believe this could be a real bug in the original contribution. I'm going to ask Bob to take a look at the assembly, given the report, to make sure that T is initialized. The only other person that comes to mind to review and make a final call is possibly wtc.
Flags: needinfo?(rrelyea)
Looking at all three implementations of intel_aes_gcmTAG in intel-gcm.s, intel-gcm-x86-masm.asm, and intel-gcm-x64-masm.asm, they all set T, such that I'm pretty confident that Kai and Ryan are right and this is a false positive. Unless Wan-Teh or Bob has a different opinion I'd close this as invalid.
Flags: needinfo?(wtc)
Franziskus: we still need to decide whether we want to suppress the MSan errors in intel_AES_GCM_DecryptUpdate, or use the pure C implementation when building under MSan. If the latter, this requires a patch for the makefiles in nss/lib/freebl.
Flags: needinfo?(wtc)
Attached patch disable-msan.patch (obsolete) — — Splinter Review
This disables msan for the functions using assembler. (It contains another minor fix for selfserv.)
Assignee: nobody → franziskuskiefer
Attachment #8812171 - Flags: review?(ttaubert)
Comment on attachment 8812171 [details] [diff] [review] disable-msan.patch Review of attachment 8812171 [details] [diff] [review]: ----------------------------------------------------------------- ::: lib/freebl/intel-gcm-wrap.c @@ +150,5 @@ > } > } > > +/* msan can't handle the assembler code in T here */ > +__attribute__((no_sanitize("memory"))) This needs some more checks, for clang and the attribute, like here: https://searchfox.org/nss/source/lib/freebl/blapii.h#54 Otherwise we might again break clang < 3.7 on one of the buildbots: https://bugzilla.mozilla.org/show_bug.cgi?id=1307590#c4
Attachment #8812171 - Flags: review?(ttaubert) → feedback+
Attached patch disable-msan.patch (obsolete) — — Splinter Review
Attachment #8812171 - Attachment is obsolete: true
Attachment #8812694 - Flags: review?(ttaubert)
Comment on attachment 8812694 [details] [diff] [review] disable-msan.patch Review of attachment 8812694 [details] [diff] [review]: ----------------------------------------------------------------- ::: lib/freebl/blapii.h @@ +55,5 @@ > #else > #define NO_SANITIZE_ALIGNMENT > #endif > > +#if defined HAVE_NO_SANITIZE_ATTR && __clang__ HAVE_NO_SANITIZE_ATTR implies __clang__. And HAVE_NO_SANITIZE_ATTR will always be defined, so it should be: #if HAVE_NO_SANITIZE_ATTR
Attachment #8812694 - Flags: review?(ttaubert) → review+
As it turns out this is not enough. With this patch we don't use the intel-gcm-wrap at all when building with msan.
Attachment #8812694 - Attachment is obsolete: true
Attachment #8813071 - Flags: review?(ttaubert)
Attachment #8813071 - Flags: review?(ttaubert) → review+
msan builds (with gyp) don't build intel gcm now. Happy fuzzing. https://hg.mozilla.org/projects/nss/rev/f4ee45f7764472a44392f7a8d9d87927aca3111d Opening up the bug as there's no security issue here.
Group: crypto-core-security
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: needinfo?(rrelyea)
Keywords: sec-moderate
Resolution: --- → FIXED
Target Milestone: --- → 3.29
Comment on attachment 8813071 [details] [diff] [review] disable-msan.patch Review of attachment 8813071 [details] [diff] [review]: ----------------------------------------------------------------- ::: lib/freebl/freebl.gyp @@ +374,5 @@ > 'MP_ASSEMBLY_MULTIPLY', > 'NSS_USE_COMBA', > + ], > + }], > + [ 'target_arch=="x64" and use_msan==0', { Please add a comment. It can be as simple as a link to this bug report. Otherwise it's not clear why we disable only some assembly code but not the above assembly code when use_msan is 1.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: