Title: [293643] trunk/Source/ThirdParty/libwebrtc
Revision
293643
Author
[email protected]
Date
2022-04-30 00:26:02 -0700 (Sat, 30 Apr 2022)

Log Message

[Mac] VTVideoDecoderClass object pointers can become unaligned on x86
https://bugs.webkit.org/show_bug.cgi?id=239916
<rdar://92445366>

Reviewed by Eric Carlson.

Both the base class and the derived class must be 4-byte aligned on x86, or there
is a chance that a pointer member of that struct will cross a page boundary, and
dereferencing that pointer will fail.

* Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp:
* Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp:

Modified Paths

Diff

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (293642 => 293643)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2022-04-30 06:07:26 UTC (rev 293642)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2022-04-30 07:26:02 UTC (rev 293643)
@@ -1,3 +1,18 @@
+2022-04-30  Jer Noble  <[email protected]>
+
+        [Mac] VTVideoDecoderClass object pointers can become unaligned on x86
+        https://bugs.webkit.org/show_bug.cgi?id=239916
+        <rdar://92445366>
+
+        Reviewed by Eric Carlson.
+
+        Both the base class and the derived class must be 4-byte aligned on x86, or there
+        is a chance that a pointer member of that struct will cross a page boundary, and
+        dereferencing that pointer will fail.
+
+        * Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp:
+        * Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp:
+
 2022-04-25  Tim Horton  <[email protected]>
 
         Fix duplicate headers warning in libwebrtc Copy Headers phase

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp (293642 => 293643)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp	2022-04-30 06:07:26 UTC (rev 293642)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP8Decoder.cpp	2022-04-30 07:26:02 UTC (rev 293643)
@@ -55,12 +55,12 @@
 #endif
 
 #pragma pack(push, 4)
-struct DecoderClass {
+struct DecoderBaseClass {
     uint8_t pad[padSize];
     CMBaseClass alignedClass;
 };
 
-static const DecoderClass WebKitVP8Decoder_BaseClass {
+static const DecoderBaseClass WebKitVP8Decoder_BaseClass {
     { },
     {
         kCMBaseObject_ClassVersion_1,
@@ -82,31 +82,49 @@
 #else
     static_assert(sizeof(WebKitVP8Decoder_BaseClass.alignedClass.version) == sizeof(uintptr_t), "CMBaseClass fixup is not required!");
 #endif
-static_assert(offsetof(DecoderClass, alignedClass) == padSize, "CMBaseClass offset is incorrect!");
-static_assert(alignof(DecoderClass) == 4, "CMBaseClass must have 4 byte alignment");
+static_assert(offsetof(DecoderBaseClass, alignedClass) == padSize, "CMBaseClass offset is incorrect!");
+static_assert(alignof(DecoderBaseClass) == 4, "CMBaseClass must have 4 byte alignment");
 
 static OSStatus startVP8DecoderSession(VTVideoDecoderRef, VTVideoDecoderSession, CMVideoFormatDescriptionRef);
 static OSStatus decodeVP8DecoderFrame(VTVideoDecoderRef, VTVideoDecoderFrame, CMSampleBufferRef, VTDecodeFrameFlags, VTDecodeInfoFlags*);
 
-static const VTVideoDecoderClass WebKitVP8Decoder_VideoDecoderClass =
+#pragma pack(push, 4)
+struct DecoderClass {
+    uint8_t pad[padSize];
+    VTVideoDecoderClass alignedClass;
+};
+
+static const DecoderClass WebKitVP8Decoder_VideoDecoderClass =
 {
-    kVTVideoDecoder_ClassVersion_1,
-    startVP8DecoderSession,
-    decodeVP8DecoderFrame,
-    nullptr, // VTVideoDecoderFunction_CopySupportedPropertyDictionary,
-    nullptr, // VTVideoDecoderFunction_SetProperties
-    nullptr, // VTVideoDecoderFunction_CopySerializableProperties
-    nullptr, // VTVideoDecoderFunction_CanAcceptFormatDescription
-    nullptr, // VTVideoDecoderFunction_FinishDelayedFrames
-    nullptr, // VTVideoDecoderFunction_StartTileSession
-    nullptr, // VTVideoDecoderFunction_DecodeTile
-    nullptr // VTVideoDecoderFunction_FinishDelayedTiles
+    { },
+    {
+        kVTVideoDecoder_ClassVersion_1,
+        startVP8DecoderSession,
+        decodeVP8DecoderFrame,
+        nullptr, // VTVideoDecoderFunction_CopySupportedPropertyDictionary,
+        nullptr, // VTVideoDecoderFunction_SetProperties
+        nullptr, // VTVideoDecoderFunction_CopySerializableProperties
+        nullptr, // VTVideoDecoderFunction_CanAcceptFormatDescription
+        nullptr, // VTVideoDecoderFunction_FinishDelayedFrames
+        nullptr, // VTVideoDecoderFunction_StartTileSession
+        nullptr, // VTVideoDecoderFunction_DecodeTile
+        nullptr // VTVideoDecoderFunction_FinishDelayedTiles
+    }
 };
+#pragma pack(pop)
 
+#if defined(CMBASE_OBJECT_NEEDS_ALIGNMENT) && CMBASE_OBJECT_NEEDS_ALIGNMENT
+    static_assert(sizeof(WebKitVP8Decoder_VideoDecoderClass.alignedClass.version) == sizeof(uint32_t), "CMBaseClass fixup is required!");
+#else
+    static_assert(sizeof(WebKitVP8Decoder_VideoDecoderClass.alignedClass.version) == sizeof(uintptr_t), "CMBaseClass fixup is not required!");
+#endif
+static_assert(offsetof(DecoderClass, alignedClass) == padSize, "CMBaseClass offset is incorrect!");
+static_assert(alignof(DecoderClass) == 4, "CMBaseClass must have 4 byte alignment");
+
 static const VTVideoDecoderVTable WebKitVP8DecoderVTable =
 {
     { nullptr, &WebKitVP8Decoder_BaseClass.alignedClass },
-    &WebKitVP8Decoder_VideoDecoderClass
+    &WebKitVP8Decoder_VideoDecoderClass.alignedClass
 };
 
 OSStatus createWebKitVP8Decoder(FigVideoCodecType, CFAllocatorRef allocator, VTVideoDecoderRef* decoderOut)

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp (293642 => 293643)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp	2022-04-30 06:07:26 UTC (rev 293642)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp	2022-04-30 07:26:02 UTC (rev 293643)
@@ -55,12 +55,12 @@
 #endif
 
 #pragma pack(push, 4)
-struct DecoderClass {
+struct DecoderBaseClass {
     uint8_t pad[padSize];
     CMBaseClass alignedClass;
 };
 
-static const DecoderClass WebKitVP9Decoder_BaseClass {
+static const DecoderBaseClass WebKitVP9Decoder_BaseClass {
     { },
     {
         kCMBaseObject_ClassVersion_1,
@@ -82,31 +82,41 @@
 #else
     static_assert(sizeof(WebKitVP9Decoder_BaseClass.alignedClass.version) == sizeof(uintptr_t), "CMBaseClass fixup is not required!");
 #endif
-static_assert(offsetof(DecoderClass, alignedClass) == padSize, "CMBaseClass offset is incorrect!");
-static_assert(alignof(DecoderClass) == 4, "CMBaseClass must have 4 byte alignment");
+static_assert(offsetof(DecoderBaseClass, alignedClass) == padSize, "CMBaseClass offset is incorrect!");
+static_assert(alignof(DecoderBaseClass) == 4, "CMBaseClass must have 4 byte alignment");
 
 static OSStatus startVP9DecoderSession(VTVideoDecoderRef, VTVideoDecoderSession, CMVideoFormatDescriptionRef);
 static OSStatus decodeVP9DecoderFrame(VTVideoDecoderRef, VTVideoDecoderFrame, CMSampleBufferRef, VTDecodeFrameFlags, VTDecodeInfoFlags*);
 
-static const VTVideoDecoderClass WebKitVP9Decoder_VideoDecoderClass =
+#pragma pack(push, 4)
+struct DecoderClass {
+    uint8_t pad[padSize];
+    VTVideoDecoderClass alignedClass;
+};
+
+static const DecoderClass WebKitVP9Decoder_VideoDecoderClass =
 {
-    kVTVideoDecoder_ClassVersion_1,
-    startVP9DecoderSession,
-    decodeVP9DecoderFrame,
-    nullptr, // VTVideoDecoderFunction_CopySupportedPropertyDictionary,
-    nullptr, // VTVideoDecoderFunction_SetProperties
-    nullptr, // VTVideoDecoderFunction_CopySerializableProperties
-    nullptr, // VTVideoDecoderFunction_CanAcceptFormatDescription
-    nullptr, // VTVideoDecoderFunction_FinishDelayedFrames
-    nullptr, // VTVideoDecoderFunction_StartTileSession
-    nullptr, // VTVideoDecoderFunction_DecodeTile
-    nullptr // VTVideoDecoderFunction_FinishDelayedTiles
+    { },
+    {
+        kVTVideoDecoder_ClassVersion_1,
+        startVP9DecoderSession,
+        decodeVP9DecoderFrame,
+        nullptr, // VTVideoDecoderFunction_CopySupportedPropertyDictionary,
+        nullptr, // VTVideoDecoderFunction_SetProperties
+        nullptr, // VTVideoDecoderFunction_CopySerializableProperties
+        nullptr, // VTVideoDecoderFunction_CanAcceptFormatDescription
+        nullptr, // VTVideoDecoderFunction_FinishDelayedFrames
+        nullptr, // VTVideoDecoderFunction_StartTileSession
+        nullptr, // VTVideoDecoderFunction_DecodeTile
+        nullptr // VTVideoDecoderFunction_FinishDelayedTiles
+    }
 };
+#pragma pack(pop)
 
 static const VTVideoDecoderVTable WebKitVP9DecoderVTable =
 {
     { nullptr, &WebKitVP9Decoder_BaseClass.alignedClass },
-    &WebKitVP9Decoder_VideoDecoderClass
+    &WebKitVP9Decoder_VideoDecoderClass.alignedClass
 };
 
 OSStatus createWebKitVP9Decoder(FigVideoCodecType, CFAllocatorRef allocator, VTVideoDecoderRef* decoderOut)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to