Closed Bug 1292402 Opened 8 years ago Closed 8 years ago

Use of uninitialised value in [@mozilla::gfx::FilterProcessing::DoUnpremultiplicationCalculation_SSE2]

Categories

(Core :: Graphics: Canvas2D, defect)

x86_64
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: tsmith, Assigned: eflores)

References

(Blocks 1 open bug)

Details

(Keywords: csectype-uninitialized, testcase, Whiteboard: [gfx-noted][adv-main51-])

Attachments

(3 files, 1 obsolete file)

Attached file log.txt
Found with Valgrind.

Use of uninitialised value of size 8
   at 0x11BB8017: _mm_set_epi16 (emmintrin.h:593)
   by 0x11BB8017: _mm_setr_epi16 (emmintrin.h:660)
   by 0x11BB8017: FromU16<__vector(2) long long int> (SIMD.h:837)
   by 0x11BB8017: DoUnpremultiplicationCalculation_SIMD<__vector(2) long long int, __vector(2) long long int> (FilterProcessingSIMD-inl.h:940)
   by 0x11BB8017: mozilla::gfx::FilterProcessing::DoUnpremultiplicationCalculation_SSE2(mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits> const&, unsigned char*, int, unsigned char*, int) (FilterProcessingSSE2.cpp:95)

Uninitialised value was created by a heap allocation
   at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x11BF0C70: Realloc (Tools.h:181)
   by 0x11BF0C70: mozilla::gfx::SourceSurfaceAlignedRawData::Init(mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits> const&, mozilla::gfx::SurfaceFormat, bool) (SourceSurfaceRawData.cpp:61)

see log.txt for full log.
Attached file test_case.html
Summary: Use of uninitialised in [@mozilla::gfx::FilterProcessing::DoUnpremultiplicationCalculation_SSE2] → Use of uninitialised value in [@mozilla::gfx::FilterProcessing::DoUnpremultiplicationCalculation_SSE2]
In DoUnpremultiplicationCalculation_SSE2 and friends, should we be verifying the size is actually a multiple of 4? We don't seem to be doing so, but in the test case the size requested for the canvas is definitely not.
Flags: needinfo?(mstange)
Whiteboard: [gfx-noted]
Flags: in-testsuite?
This code is somewhat intentionally using uninitialized values and may even propagate values derived from them into other surfaces, but the idea is that all those values will be ignored in the final surface (and during the final draw operation) because they'll be outside the declared size of the surface.

That said, it probably wouldn't hurt too much to zero out just the alignment padding at the right edge of the surface after allocation.
Flags: needinfo?(mstange)
Assignee: nobody → edwin
Attached patch 1292402.patch (obsolete) — Splinter Review
I can't reproduce the warning, but this patch should fix it.
Attachment #8780169 - Flags: review?(mstange)
Comment on attachment 8780169 [details] [diff] [review]
1292402.patch

On second thought, this happens a bunch of times in that file. I'll go through and put up a more exhaustive patch.
Attachment #8780169 - Flags: review?(mstange)
Comment on attachment 8780169 [details] [diff] [review]
1292402.patch

Review of attachment 8780169 [details] [diff] [review]:
-----------------------------------------------------------------

thanks

::: gfx/2d/FilterNodeSoftware.cpp
@@ +1724,5 @@
>        }
>      }
> +
> +    // Zero padding to keep valgrind happy.
> +    memset(&targetData[y * targetStride + sourceStride * BytesPerPixel], 0,

Could you use PodZero instead?
Attached patch 1292402.patchSplinter Review
This should be all of it.

There was a bug in the original patch as well, which assumed that the stride was in pixels instead of bytes. Then valgrind would have had two things to complain about. :)
Attachment #8780169 - Attachment is obsolete: true
Attachment #8780471 - Flags: review?(mstange)
Attachment #8780471 - Flags: review?(mstange) → review+
https://hg.mozilla.org/mozilla-central/rev/b0e580940a42
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Group: gfx-core-security → core-security-release
Whiteboard: [gfx-noted] → [gfx-noted][adv-main51-]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: