⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 292901 in webkit


Ignore:
Timestamp:
Apr 14, 2022, 11:08:27 PM (4 years ago)
Author:
Martin Robinson
Message:

[GTK] AddressSanitizer: heap-buffer-overflow in WebCore::Length::ref()
https://bugs.webkit.org/show_bug.cgi?id=237389

Reviewed by Žan Doberšek.

  • platform/graphics/nicosia/NicosiaAnimation.cpp:

(Nicosia::createThreadsafeKeyFrames): Convert Length members of transform functions to
the fixed variety before they are moved to separate threads.
(Nicosia::Animation::Animation): Use the new helper.

  • platform/graphics/transforms/TranslateTransformOperation.h: Added setters.
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r292900 r292901  
     12022-04-14  Martin Robinson  <mrobinson@webkit.org>
     2
     3        [GTK] AddressSanitizer: heap-buffer-overflow in WebCore::Length::ref()
     4        https://bugs.webkit.org/show_bug.cgi?id=237389
     5
     6        Reviewed by Žan Doberšek.
     7
     8        * platform/graphics/nicosia/NicosiaAnimation.cpp:
     9        (Nicosia::createThreadsafeKeyFrames): Convert Length members of transform functions to
     10        the fixed variety before they are moved to separate threads.
     11        (Nicosia::Animation::Animation): Use the new helper.
     12        * platform/graphics/transforms/TranslateTransformOperation.h: Added setters.
     13
    1142022-04-14  Zan Dobersek  <zdobersek@igalia.com>
    215
  • trunk/Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp

    r290667 r292901  
    2222
    2323#include "LayoutSize.h"
     24#include "TranslateTransformOperation.h"
    2425
    2526namespace Nicosia {
     
    139140}
    140141
     142static KeyframeValueList createThreadsafeKeyFrames(const KeyframeValueList& originalKeyframes, const FloatSize& boxSize)
     143{
     144    if (originalKeyframes.property() != AnimatedPropertyTransform)
     145        return originalKeyframes;
     146
     147    // Currently translation operations are the only transform operations that store a non-fixed
     148    // Length. Some Lengths, in particular those for calc() operations, are not thread-safe or
     149    // multiprocess safe, because they maintain indices into a shared HashMap of CalculationValues.
     150    // This code converts all possible unsafe Length parameters to fixed Lengths, which are safe to
     151    // use in other threads and across IPC channels.
     152    KeyframeValueList keyframes = originalKeyframes;
     153    for (unsigned i = 0; i < keyframes.size(); i++) {
     154        const auto& transformValue = static_cast<const TransformAnimationValue&>(keyframes.at(i));
     155        for (auto& operation : transformValue.value().operations()) {
     156            if (is<TranslateTransformOperation>(operation)) {
     157                TranslateTransformOperation* translation = static_cast<TranslateTransformOperation*>(operation.get());
     158                translation->setX(Length(translation->xAsFloat(boxSize), LengthType::Fixed));
     159                translation->setY(Length(translation->yAsFloat(boxSize), LengthType::Fixed));
     160                translation->setZ(Length(translation->zAsFloat(), LengthType::Fixed));
     161            }
     162        }
     163    }
     164
     165    return keyframes;
     166}
     167
    141168Animation::Animation(const String& name, const KeyframeValueList& keyframes, const FloatSize& boxSize, const WebCore::Animation& animation, MonotonicTime startTime, Seconds pauseTime, AnimationState state)
    142169    : m_name(name.isSafeToSendToAnotherThread() ? name : name.isolatedCopy())
    143     , m_keyframes(keyframes)
     170    , m_keyframes(createThreadsafeKeyFrames(keyframes, boxSize))
    144171    , m_boxSize(boxSize)
    145172    , m_timingFunction(animation.timingFunction()->clone())
  • trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h

    r289032 r292901  
    5959    Length z() const { return m_z; }
    6060
     61    void setX(Length newX) { m_x = newX; }
     62    void setY(Length newY) { m_y = newY; }
     63    void setZ(Length newZ) { m_z = newZ; }
     64
    6165    OperationType primitiveType() const final { return isRepresentableIn2D() ? TRANSLATE : TRANSLATE_3D; }
    6266
Note: See TracChangeset for help on using the changeset viewer.