From e15b3560147ca404e11be4b05ab3f43c39b78a9e Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 14 Jun 2022 21:45:26 -0700 Subject: [PATCH] add WEBP_MSAN and use it to suppress a false positive related to data that passes through RGBA32PackedToPlanar_16b_SSE41(). Current versions (tested with clang 13.0.1, using -O0 and the build from oss-fuzz of enc_dec_fuzzer) model shuffles incorrectly reporting use of uninitialized data related to the alpha change that's removed when converting to YUV. valgrind behaves correctly, however. Bug: webp:573 Change-Id: If76997668dcdd436adf280a2e6dcffba766a2875 --- src/dsp/cpu.h | 6 ++++++ src/enc/picture_csp_enc.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/dsp/cpu.h b/src/dsp/cpu.h index 40711b2f..be0c280f 100644 --- a/src/dsp/cpu.h +++ b/src/dsp/cpu.h @@ -147,6 +147,12 @@ #endif #endif +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) +#define WEBP_MSAN +#endif +#endif + #if defined(WEBP_USE_THREAD) && !defined(_WIN32) #include // NOLINT diff --git a/src/enc/picture_csp_enc.c b/src/enc/picture_csp_enc.c index 5e60f5ba..fabebcf2 100644 --- a/src/enc/picture_csp_enc.c +++ b/src/enc/picture_csp_enc.c @@ -451,11 +451,20 @@ static WEBP_INLINE void AccumulateRGB(const uint8_t* const r_ptr, dst[0] = SUM4(r_ptr + j, step); dst[1] = SUM4(g_ptr + j, step); dst[2] = SUM4(b_ptr + j, step); + // MemorySanitizer may raise false positives with data that passes through + // RGBA32PackedToPlanar_16b_SSE41() due to incorrect modeling of shuffles. + // See https://crbug.com/webp/573. +#ifdef WEBP_MSAN + dst[3] = 0; +#endif } if (width & 1) { dst[0] = SUM2(r_ptr + j); dst[1] = SUM2(g_ptr + j); dst[2] = SUM2(b_ptr + j); +#ifdef WEBP_MSAN + dst[3] = 0; +#endif } }